Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions compiler-rt/lib/profile/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,6 @@ if(COMPILER_RT_PROFILE_BAREMETAL)
-DCOMPILER_RT_PROFILE_BAREMETAL=1)
endif()

if(COMPILER_RT_BUILD_PROFILE_ROCM)
set(EXTRA_FLAGS
${EXTRA_FLAGS}
-DCOMPILER_RT_BUILD_PROFILE_ROCM=1)
endif()

# The HIP host interceptor in InstrProfilingPlatformROCm.cpp pulls in
# RTInterception + sanitizer_common object libs. Those targets are only created
# when COMPILER_RT_BUILD_SANITIZERS / _MEMPROF / _XRAY / _CTX_PROFILE is enabled
Expand All @@ -190,6 +184,17 @@ if(NOT PROFILE_HAS_HIP_INTERCEPTOR)
list(REMOVE_ITEM PROFILE_SOURCES InstrProfilingPlatformROCm.cpp)
endif()

# Only advertise the ROCm interceptor to InstrProfilingFile.c when its
# definition (InstrProfilingPlatformROCm.cpp) is actually compiled into the
# archive. Otherwise InstrProfilingFile.c references
# __llvm_profile_hip_collect_device_data with no definition; on COFF/Windows
# there is no weak-undefined fallback, so the link fails (see PR #200111).
if(COMPILER_RT_BUILD_PROFILE_ROCM AND PROFILE_HAS_HIP_INTERCEPTOR)
set(EXTRA_FLAGS
${EXTRA_FLAGS}
-DCOMPILER_RT_BUILD_PROFILE_ROCM=1)
endif()

if("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "amdgcn|nvptx")
append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding EXTRA_FLAGS)
append_list_if(COMPILER_RT_HAS_NOGPULIB_FLAG -nogpulib EXTRA_FLAGS)
Expand Down