From 96b31d92c319dd79b67c10d9dd566b5ddbda9cde Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Mon, 5 May 2025 21:49:46 -0400 Subject: [PATCH] Fix build failure for the openmp-target example when building in docker. (#197) - Add cmake formatting rule for `rocprofiler-systems-custom-compilation` - Resolve build failure observed with the `openmp-target` example when building in some environments - Observed in our docker images - Ensure `libomptarget-amdgpu-gfx*.bc` files are found --- .cmake-format.yaml | 9 +++++++++ examples/openmp/CMakeLists.txt | 12 ++++++------ examples/openmp/target/CMakeLists.txt | 8 ++++---- scripts/rocprof-sys-launch-compiler | 7 +++++++ 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/.cmake-format.yaml b/.cmake-format.yaml index 8ece7156ed..d9504a2789 100644 --- a/.cmake-format.yaml +++ b/.cmake-format.yaml @@ -231,6 +231,15 @@ parse: TIMEMORY_FILE: '*' TIMEMORY_METRIC: '*' EXIST_FILES: '*' + rocprofiler_systems_custom_compilation: + flags: + - GLOBAL + - PROJECT + kwargs: + COMPILER: '*' + DIRECTORY: '*' + TARGET: '*' + SOURCE: '*' override_spec: {} vartags: [] proptags: [] diff --git a/examples/openmp/CMakeLists.txt b/examples/openmp/CMakeLists.txt index 2b3c7e6199..29de7fdc11 100644 --- a/examples/openmp/CMakeLists.txt +++ b/examples/openmp/CMakeLists.txt @@ -38,12 +38,12 @@ else() AND USE_CLANG_OMP) target_compile_options(openmp-common PUBLIC -W -Wall -fopenmp=libomp) target_link_libraries(openmp-common PUBLIC ${LIBOMP_LIBRARY}) - rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET - openmp-common) - rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET - openmp-cg) - rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} TARGET - openmp-lu) + rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} + TARGET openmp-common) + rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} + TARGET openmp-cg) + rocprofiler_systems_custom_compilation(COMPILER ${CLANGXX_EXECUTABLE} + TARGET openmp-lu) set(ROCPROFSYS_OPENMP_USING_LIBOMP_LIBRARY ON CACHE INTERNAL "Used by rocprofiler-systems testing" FORCE) diff --git a/examples/openmp/target/CMakeLists.txt b/examples/openmp/target/CMakeLists.txt index ddb971a10e..93612bf7b7 100644 --- a/examples/openmp/target/CMakeLists.txt +++ b/examples/openmp/target/CMakeLists.txt @@ -92,8 +92,8 @@ set_target_properties( OUTPUT_NAME "openmp-target" POSITION_INDEPENDENT_CODE ON) -rocprofiler_systems_custom_compilation(TARGET openmp-target-lib COMPILER - ${OMP_TARGET_COMPILER}) +rocprofiler_systems_custom_compilation(TARGET openmp-target-lib + COMPILER ${OMP_TARGET_COMPILER}) add_executable(openmp-target) target_sources(openmp-target PRIVATE main.cpp) @@ -106,5 +106,5 @@ set_target_properties( "${OMP_TARGET_COMPILER_DIR}/llvm/lib:${OMP_TARGET_COMPILER_DIR}/lib" POSITION_INDEPENDENT_CODE ON) -rocprofiler_systems_custom_compilation(TARGET openmp-target COMPILER - ${OMP_TARGET_COMPILER}) +rocprofiler_systems_custom_compilation(TARGET openmp-target + COMPILER ${OMP_TARGET_COMPILER}) diff --git a/scripts/rocprof-sys-launch-compiler b/scripts/rocprof-sys-launch-compiler index cb5fc04881..cf04eabf57 100755 --- a/scripts/rocprof-sys-launch-compiler +++ b/scripts/rocprof-sys-launch-compiler @@ -93,6 +93,13 @@ else # discard the compiler from the command shift + if [ -n "$(basename ${ROCPROFSYS_COMPILER} | egrep 'amdclang|amdllvm')" ]; then + # this ensures the libomptarget-amdgpu-gfx*.bc files are found + LLVM_LIB_DIR=$(cd $(dirname $(realpath ${ROCPROFSYS_COMPILER}))/../lib && pwd) + debug-message export LIBRARY_PATH=${LLVM_LIB_DIR}:${LIBRARY_PATH} + export LIBRARY_PATH=${LLVM_LIB_DIR}:${LIBRARY_PATH} + fi + debug-message ${ROCPROFSYS_COMPILER} $@ # execute ${ROCPROFSYS_COMPILER} (again, usually nvcc_wrapper) ${ROCPROFSYS_COMPILER} $@