Build libhipcxx from source#

2026-10-23

2 min read time

Applies to Linux and Windows

To build libhipcxx as part of the ROCm Core SDK, see Install AMD ROCm. TheRock is the recommended way to build ROCm components from source.

Alternatively, you can build libhipcxx standalone using the following instructions.

libhipcxx build prerequisites#

On Linux, ROCm must be installed before libhipcxx is built.

libhipcxx has the following prerequisites:

libhipcxx has these additional prerequisites to build and run the tests:

  • LLVM version 18.1.8 or higher. Only its CMake modules are required.

  • lit version 18.1.8

  • Ninja

  • sccache

Get the libhipcxx source code#

The libhipcxx source code is available from the libhipcxx GitHub repository. Clone the repository:

git clone https://github.com/ROCm/libhipcxx.git
cd libhipcxx

Then use git checkout to check out the branch you need.

The amd-develop branch is intended for users who want to preview new features or contribute to the libhipcxx code base.

If you don’t intend to contribute to the libhipcxx code base and won’t be previewing features, use a branch that matches the version of ROCm installed on your system.

Build with CMake#

Set CXX to the absolute path of amdclang++ before configuring. CMake uses it as the C++ compiler, and the lit test suite uses the same compiler to build the tests. For example:

export CXX=/opt/rocm/bin/amdclang++

Alternatively, pass -DCMAKE_CXX_COMPILER=/opt/rocm/bin/amdclang++ to the cmake command below.

Create the build directory under the libhipcxx root directory, then change directory to the build directory:

mkdir build
cd build

Generate the libhipcxx build files using the cmake command:

cmake -GNinja ../. [-D<OPTION1=VALUE1> [-D<OPTION2=VALUE2>] ...]

The build options are:

  • LIBHIPCXX_TEST_WITH_HIPRTC: Set this to ON to build and run the tests with HIPRTC support. Default is OFF.

  • LIBCUDACXX_ENABLE_LIBCUDACXX_TESTS: Set this to OFF to skip configuring the lit test suite. Default is ON.

  • libhipcxx_ENABLE_INSTALL_RULES: Set this to OFF to skip generating install rules. Default is ON when libhipcxx is the top-level project.

  • libhipcxx_ENABLE_CODEGEN: Set this to ON to enable the atomics backend code generation and its tests. Default is OFF.

  • CMAKE_HIP_ARCHITECTURES: Set this to the GPU architectures to build for, for example gfx942. AMDGPU_TARGETS and GPU_TARGETS are also accepted.

  • CMAKE_INSTALL_PREFIX: Set this to the installation directory. For example, use /opt/rocm to install alongside ROCm.

  • LIBHIPCXX_INSTALL_INCLUDE_SUBDIR: Set this to the subdirectory of the install include directory that receives the libhipcxx headers. Default is hipccl, which matches the ROCm layout. Set it to an empty string to install the headers directly into the include directory. find_package(libhipcxx) finds the headers for any value.

Build libhipcxx using the generated build files:

ninja

After you’ve built libhipcxx, you can optionally generate TGZ, ZIP, and DEB packages:

cpack .

To generate an RPM package, run:

cpack -G RPM .

Finally, install libhipcxx:

ninja install