Skip to content

[PGO][HIP] Skip ROCm interceptor in profile-only compiler-rt builds - #200111

Merged
yxsamliu merged 1 commit into
llvm:mainfrom
yxsamliu:amd/dev/yaxunl/profile-cmake-rtinterception-target-guard
May 29, 2026
Merged

[PGO][HIP] Skip ROCm interceptor in profile-only compiler-rt builds#200111
yxsamliu merged 1 commit into
llvm:mainfrom
yxsamliu:amd/dev/yaxunl/profile-cmake-rtinterception-target-guard

Conversation

@yxsamliu

Copy link
Copy Markdown
Contributor

PR #177665 made libclang_rt.profile.a merge RTInterception and sanitizer_common object libs to support the hipModuleLoad* host interceptor added in InstrProfilingPlatformROCm.cpp. Those object-lib targets are only created when COMPILER_RT_BUILD_SANITIZERS / _MEMPROF / _XRAY / _CTX_PROFILE is enabled (see compiler-rt/lib/CMakeLists.txt), so a profile-only configuration fails at configure time:

CMake Error at cmake/Modules/AddCompilerRT.cmake:365 (add_library):
  Error evaluating generator expression:
    $<TARGET_OBJECTS:RTInterception.x86_64>
  Objects of target "RTInterception.x86_64" referenced but no such target
  exists.
Call Stack (most recent call first):
  lib/profile/CMakeLists.txt:233 (add_compiler_rt_runtime)

Fix: gate the object-lib merge on the RTInterception.<arch> / RTSanitizerCommon*.<arch> targets actually existing, and drop InstrProfilingPlatformROCm.cpp from PROFILE_SOURCES in that case so the static archive stays self-contained. The host-side hook __llvm_profile_hip_collect_device_data is already declared weak in InstrProfilingFile.c (PR #200101), so its absence is fine at link time.

Verified:

  • Profile-only standalone compiler-rt build (-DCOMPILER_RT_BUILD_SANITIZERS=OFF -DCOMPILER_RT_BUILD_MEMPROF=OFF -DCOMPILER_RT_BUILD_XRAY=OFF -DCOMPILER_RT_BUILD_CTX_PROFILE=OFF -DCOMPILER_RT_BUILD_PROFILE=ON) now configures and links cleanly.
  • Default runtimes build still merges the object libs and produces the interceptor; check-profile 134/134 pass.

@llvmorg-github-actions llvmorg-github-actions Bot added compiler-rt PGO Profile Guided Optimizations labels May 28, 2026
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-pgo

Author: Yaxun (Sam) Liu (yxsamliu)

Changes

PR #177665 made libclang_rt.profile.a merge RTInterception and sanitizer_common object libs to support the hipModuleLoad* host interceptor added in InstrProfilingPlatformROCm.cpp. Those object-lib targets are only created when COMPILER_RT_BUILD_SANITIZERS / _MEMPROF / _XRAY / _CTX_PROFILE is enabled (see compiler-rt/lib/CMakeLists.txt), so a profile-only configuration fails at configure time:

CMake Error at cmake/Modules/AddCompilerRT.cmake:365 (add_library):
  Error evaluating generator expression:
    $&lt;TARGET_OBJECTS:RTInterception.x86_64&gt;
  Objects of target "RTInterception.x86_64" referenced but no such target
  exists.
Call Stack (most recent call first):
  lib/profile/CMakeLists.txt:233 (add_compiler_rt_runtime)

Fix: gate the object-lib merge on the RTInterception.&lt;arch&gt; / RTSanitizerCommon*.&lt;arch&gt; targets actually existing, and drop InstrProfilingPlatformROCm.cpp from PROFILE_SOURCES in that case so the static archive stays self-contained. The host-side hook __llvm_profile_hip_collect_device_data is already declared weak in InstrProfilingFile.c (PR #200101), so its absence is fine at link time.

Verified:

  • Profile-only standalone compiler-rt build (-DCOMPILER_RT_BUILD_SANITIZERS=OFF -DCOMPILER_RT_BUILD_MEMPROF=OFF -DCOMPILER_RT_BUILD_XRAY=OFF -DCOMPILER_RT_BUILD_CTX_PROFILE=OFF -DCOMPILER_RT_BUILD_PROFILE=ON) now configures and links cleanly.
  • Default runtimes build still merges the object libs and produces the interceptor; check-profile 134/134 pass.

Full diff: https://github.com/llvm/llvm-project/pull/200111.diff

1 Files Affected:

  • (modified) compiler-rt/lib/profile/CMakeLists.txt (+17-2)
diff --git a/compiler-rt/lib/profile/CMakeLists.txt b/compiler-rt/lib/profile/CMakeLists.txt
index 36e6b5a6a21c1..2b09548bb3a1e 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -156,8 +156,18 @@ if(COMPILER_RT_PROFILE_BAREMETAL)
      -DCOMPILER_RT_PROFILE_BAREMETAL=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
+# (see lib/CMakeLists.txt). In a profile-only build the targets do not exist;
+# skip both the object-lib merge and the ROCm source file so the static archive
+# remains self-contained.
 set(PROFILE_OBJECT_LIBS)
-if(COMPILER_RT_HAS_INTERCEPTION AND NOT COMPILER_RT_PROFILE_BAREMETAL)
+set(PROFILE_HAS_HIP_INTERCEPTOR FALSE)
+if(COMPILER_RT_HAS_INTERCEPTION AND NOT COMPILER_RT_PROFILE_BAREMETAL
+   AND TARGET RTInterception.${COMPILER_RT_DEFAULT_TARGET_ARCH}
+   AND TARGET RTSanitizerCommon.${COMPILER_RT_DEFAULT_TARGET_ARCH}
+   AND TARGET RTSanitizerCommonLibc.${COMPILER_RT_DEFAULT_TARGET_ARCH})
   # RTInterception references __sanitizer_internal_{memcpy,memset,memmove} and other
   # sanitizer_common symbols; merge the same object libs as clang_rt.cfi (without
   # coverage/symbolizer) so -fprofile-instr-generate links stay self-contained.
@@ -165,6 +175,11 @@ if(COMPILER_RT_HAS_INTERCEPTION AND NOT COMPILER_RT_PROFILE_BAREMETAL)
     RTInterception
     RTSanitizerCommon
     RTSanitizerCommonLibc)
+  set(PROFILE_HAS_HIP_INTERCEPTOR TRUE)
+endif()
+
+if(NOT PROFILE_HAS_HIP_INTERCEPTOR)
+  list(REMOVE_ITEM PROFILE_SOURCES InstrProfilingPlatformROCm.cpp)
 endif()
 
 if("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "amdgcn|nvptx")
@@ -185,7 +200,7 @@ if(MSVC)
   # built with MultiThreadedDLL (/MD) — see interception/CMakeLists.txt and
   # sanitizer_common/CMakeLists.txt. Mixing /MD objects into a /MT libclang_rt.profile
   # yields LNK2019 (__imp__stricmp from interception_win.cpp) and LNK4098 in Profile-*.
-  if(COMPILER_RT_HAS_INTERCEPTION AND NOT COMPILER_RT_PROFILE_BAREMETAL)
+  if(PROFILE_HAS_HIP_INTERCEPTOR)
     set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
   else()
     set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)

PR llvm#177665 made libclang_rt.profile.a merge RTInterception + sanitizer_common
object libs to support InstrProfilingPlatformROCm.cpp's hipModuleLoad
interceptor. Those object-lib targets are only created when
COMPILER_RT_BUILD_SANITIZERS / _MEMPROF / _XRAY / _CTX_PROFILE is enabled
(see lib/CMakeLists.txt), so a profile-only configuration fails at configure
time:

  Error evaluating generator expression:
    $<TARGET_OBJECTS:RTInterception.x86_64>
  Objects of target "RTInterception.x86_64" referenced but no such target
  exists.

Gate the object-lib merge on the targets actually existing, and drop
InstrProfilingPlatformROCm.cpp from PROFILE_SOURCES in that case so the static
archive stays self-contained. The host-side hook
__llvm_profile_hip_collect_device_data is already declared weak in
InstrProfilingFile.c, so its absence is fine at link time.
@yxsamliu
yxsamliu force-pushed the amd/dev/yaxunl/profile-cmake-rtinterception-target-guard branch from feb727e to fc23037 Compare May 28, 2026 22:48
@yxsamliu
yxsamliu merged commit 4c33844 into llvm:main May 29, 2026
16 of 18 checks passed
@llvm-ci

llvm-ci commented May 29, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder sanitizer-aarch64-linux running on sanitizer-buildbot7 while building compiler-rt at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/37444

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
[203/208] Generating MSAN_INST_GTEST.gtest-all.cc.aarch64.o
[204/208] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64-with-call.o
[205/208] Generating Msan-aarch64-with-call-Test
[206/208] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64.o
[207/208] Generating Msan-aarch64-Test
[207/208] Running compiler_rt regression tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:273: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/interception/Unit' contained no tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:273: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/Unit' contained no tests
-- Testing: 3246 of 6441 tests, 72 workers --
Testing:  0.. 10.. 20.
FAIL: MemorySanitizer-AARCH64 :: poison_in_signal.cpp (900 of 3246)
******************** TEST 'MemorySanitizer-AARCH64 :: poison_in_signal.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 3
/home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang  --driver-mode=g++ -fsanitize=memory -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls   -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   -gline-tables-only -std=c++11 -O2 /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/msan/poison_in_signal.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp &&  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp
# executed command: /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang --driver-mode=g++ -fsanitize=memory -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -gline-tables-only -std=c++11 -O2 /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/msan/poison_in_signal.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp
# note: command had no output on stdout or stderr
# executed command: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp
# note: command had no output on stdout or stderr
# RUN: at line 4
/home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang  --driver-mode=g++ -fsanitize=memory -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls   -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   -gline-tables-only -fsanitize-memory-track-origins=2 -std=c++11 -O2 /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/msan/poison_in_signal.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp &&  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp
# executed command: /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang --driver-mode=g++ -fsanitize=memory -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -gline-tables-only -fsanitize-memory-track-origins=2 -std=c++11 -O2 /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/msan/poison_in_signal.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp
# note: command had no output on stdout or stderr
# executed command: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp
# .---command stderr------------
# | MemorySanitizer:DEADLYSIGNAL
# | ==3617075==ERROR: MemorySanitizer: SEGV on unknown address 0x7cfffff7a9c084 (pc 0xfffff7bf6304 bp 0xfffff34cf150 sp 0xfffff34cf150 T3617224)
# | ==3617075==The signal is caused by a READ memory access.
# | MemorySanitizer:DEADLYSIGNAL
# | MemorySanitizer: nested bug in the same thread, aborting.
# `-----------------------------
# error: command failed with exit status: 1

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 

2 warning(s) in tests
Slowest Tests:
--------------------------------------------------------------------------
76.04s: ThreadSanitizer-aarch64 :: deadlock_detector_stress_test.cpp
35.39s: ThreadSanitizer-aarch64 :: bench_threads.cpp
32.57s: ThreadSanitizer-aarch64 :: restore_stack.cpp
22.39s: ThreadSanitizer-aarch64 :: compare_exchange_acquire_fence.cpp
18.82s: ThreadSanitizer-aarch64 :: signal_thread.cpp
Step 11 (test compiler-rt debug) failure: test compiler-rt debug (failure)
...
[203/208] Generating MSAN_INST_GTEST.gtest-all.cc.aarch64.o
[204/208] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64-with-call.o
[205/208] Generating Msan-aarch64-with-call-Test
[206/208] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64.o
[207/208] Generating Msan-aarch64-Test
[207/208] Running compiler_rt regression tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:273: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/interception/Unit' contained no tests
llvm-lit: /home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:273: warning: input '/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/Unit' contained no tests
-- Testing: 3246 of 6441 tests, 72 workers --
Testing:  0.. 10.. 20.
FAIL: MemorySanitizer-AARCH64 :: poison_in_signal.cpp (900 of 3246)
******************** TEST 'MemorySanitizer-AARCH64 :: poison_in_signal.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 3
/home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang  --driver-mode=g++ -fsanitize=memory -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls   -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   -gline-tables-only -std=c++11 -O2 /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/msan/poison_in_signal.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp &&  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp
# executed command: /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang --driver-mode=g++ -fsanitize=memory -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -gline-tables-only -std=c++11 -O2 /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/msan/poison_in_signal.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp
# note: command had no output on stdout or stderr
# executed command: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp
# note: command had no output on stdout or stderr
# RUN: at line 4
/home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang  --driver-mode=g++ -fsanitize=memory -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls   -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   -gline-tables-only -fsanitize-memory-track-origins=2 -std=c++11 -O2 /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/msan/poison_in_signal.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp &&  /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp
# executed command: /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang --driver-mode=g++ -fsanitize=memory -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -gline-tables-only -fsanitize-memory-track-origins=2 -std=c++11 -O2 /home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/msan/poison_in_signal.cpp -o /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp
# note: command had no output on stdout or stderr
# executed command: /home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/msan/AARCH64/Output/poison_in_signal.cpp.tmp
# .---command stderr------------
# | MemorySanitizer:DEADLYSIGNAL
# | ==3617075==ERROR: MemorySanitizer: SEGV on unknown address 0x7cfffff7a9c084 (pc 0xfffff7bf6304 bp 0xfffff34cf150 sp 0xfffff34cf150 T3617224)
# | ==3617075==The signal is caused by a READ memory access.
# | MemorySanitizer:DEADLYSIGNAL
# | MemorySanitizer: nested bug in the same thread, aborting.
# `-----------------------------
# error: command failed with exit status: 1

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..

2 warning(s) in tests
Slowest Tests:
--------------------------------------------------------------------------
76.04s: ThreadSanitizer-aarch64 :: deadlock_detector_stress_test.cpp
35.39s: ThreadSanitizer-aarch64 :: bench_threads.cpp
32.57s: ThreadSanitizer-aarch64 :: restore_stack.cpp
22.39s: ThreadSanitizer-aarch64 :: compare_exchange_acquire_fence.cpp
18.82s: ThreadSanitizer-aarch64 :: signal_thread.cpp

@llvm-ci

llvm-ci commented Jun 1, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder clang-ppc64le-linux-test-suite running on ppc64le-clang-test-suite while building compiler-rt at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/95/builds/20868

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: 1200 seconds without output running [b'ninja', b'check-all'], attempting to kill
...
PASS: Clang :: Driver/arm-cortex-cpus-1.c (111048 of 111058)
PASS: Clang :: Driver/amdgpu-mcpu.cl (111049 of 111058)
PASS: LLVM :: Transforms/LoopUnroll/branch-weights-freq/unroll-complete.ll (111050 of 111058)
PASS: Clang :: Preprocessor/x86_target_features.c (111051 of 111058)
PASS: LLVM :: CodeGen/AMDGPU/directive-amdgcn-target.ll (111052 of 111058)
PASS: Clang :: Driver/debug-options.c (111053 of 111058)
PASS: Clang :: Driver/linux-ld.c (111054 of 111058)
PASS: LLVM :: tools/llvm-readobj/ELF/file-header-machine-types.test (111055 of 111058)
PASS: Clang :: OpenMP/target_update_codegen.cpp (111056 of 111058)
PASS: Clang :: Preprocessor/riscv-target-features.c (111057 of 111058)
command timed out: 1200 seconds without output running [b'ninja', b'check-all'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=12746.261989

@zmodem

zmodem commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

This broke our builds on Windows. I guess it relates to this:

The host-side hook __llvm_profile_hip_collect_device_data is already declared weak in InstrProfilingFile.c (PR #200101), so its absence is fine at link time.

because we get undefined symbol errors for __llvm_profile_hip_collect_device_data and looking at #200101 it does not declare that symbol weak on Windows.

Here's a reproducer:

cmake -Bbuild.foo -GNinja -DCMAKE_BUILD_TYPE=Release -DCOMPILER_RT_BUILD_CRT=ON -DCOMPILER_RT_BUILD_LIBFUZZER=OFF -DCOMPILER_RT_BUILD_CTX_PROFILE=OFF -DCOMPILER_RT_BUILD_MEMPROF=OFF -DCOMPILER_RT_BUILD_ORC=OFF -DCOMPILER_RT_BUILD_PROFILE=ON -DCOMPILER_RT_BUILD_SANITIZERS=OFF -DCOMPILER_RT_BUILD_XRAY=OFF -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_RUNTIMES=compiler-rt -DCLANG_ENABLE_STATIC_ANALYZER=OFF -DCLANG_ENABLE_ARCMT=OFF llvm && ninja -C build.foo check-runtimes
...
********************
FAIL: Profile-x86_64 :: Windows/instrprof-multiprocess.test (404 of 405, 3 of 3 attempts)
******************** TEST 'Profile-x86_64 :: Windows/instrprof-multiprocess.test' FAILED ********************
Exit Code: 1120

Command Output (stdout):
--
# RUN: at line 1
C:/src/llvm-project/build.foo/./bin/clang.exe    -D_MT -D_DLL -Wl,-nodefaultlib:libcmt,-defaultlib:msvcrt,-defaultlib:oldnames  -Wl,-incremental:no  -fprofile-instr-generate C:\src\llvm-project\compiler-rt\test\profile\Windows/Inputs/instrprof-multiprocess.c -o C:\src\llvm-project\build.foo\runtimes\runtimes-bins\compiler-rt\test\profile\Profile-x86_64\Windows\Output\instrprof-multiprocess.test.tmp
# executed command: C:/src/llvm-project/build.foo/./bin/clang.exe -D_MT -D_DLL -Wl,-nodefaultlib:libcmt,-defaultlib:msvcrt,-defaultlib:oldnames -Wl,-incremental:no -fprofile-instr-generate 'C:\src\llvm-project\compiler-rt\test\profile\Windows/Inputs/instrprof-multiprocess.c' -o 'C:\src\llvm-project\build.foo\runtimes\runtimes-bins\compiler-rt\test\profile\Profile-x86_64\Windows\Output\instrprof-multiprocess.test.tmp'
# .---command stdout------------
# | clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj) : error LNK2019: unresolved external symbol __llvm_profile_hip_collect_device_data referenced in function __llvm_profile_write_file
# | C:\src\llvm-project\build.foo\runtimes\runtimes-bins\compiler-rt\test\profile\Profile-x86_64\Windows\Output\instrprof-multiprocess.test.tmp : fatal error LNK1120: 1 unresolved externals
# `-----------------------------
# .---command stderr------------
# | C:\src\llvm-project\compiler-rt\test\profile\Windows/Inputs/instrprof-multiprocess.c:12:3: warning: '_itow' is deprecated: This function or variable may be unsafe. Consider using _itow_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
# |    12 |   _itow(child_num, child_str, 10);
# |       |   ^
# | C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\corecrt_wstdlib.h:68:5: note: '_itow' has been explicitly marked deprecated here
# |    68 |     __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1(
# |       |     ^
# | C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\corecrt.h:847:5: note: expanded from macro '__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1'
# |   847 |     __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _HType1, _HArg1, _SalAttributeDst, _DstType, _Dst, _TType1, _TArg1)
# |       |     ^
# | C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\corecrt.h:1906:17: note: expanded from macro '__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1_EX'
# |  1906 |                 _CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_HType1 _HArg1, _SalAttributeDst _DstType *_Dst, _TType1 _TArg1);
# |       |                 ^
# | C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\vcruntime.h:320:55: note: expanded from macro '_CRT_INSECURE_DEPRECATE'
# |   320 |         #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT(    \
# |       |                                                       ^
# | C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\vcruntime.h:310:47: note: expanded from macro '_CRT_DEPRECATE_TEXT'
# |   310 | #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
# |       |                                               ^
# | C:\src\llvm-project\compiler-rt\test\profile\Windows/Inputs/instrprof-multiprocess.c:68:21: warning: 'getenv' is deprecated: This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
# |    68 |   char *child_str = getenv("CHILD_NUM");
# |       |                     ^
# | C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\stdlib.h:1183:20: note: 'getenv' has been explicitly marked deprecated here
# |  1183 |     _Check_return_ _CRT_INSECURE_DEPRECATE(_dupenv_s)
# |       |                    ^
# | C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\vcruntime.h:320:55: note: expanded from macro '_CRT_INSECURE_DEPRECATE'
# |   320 |         #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT(    \
# |       |                                                       ^
# | C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\vcruntime.h:310:47: note: expanded from macro '_CRT_DEPRECATE_TEXT'
# |   310 | #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
# |       |                                               ^
# | 2 warnings generated.
# | clang: error: linker command failed with exit code 1120 (use -v to see invocation)
# `-----------------------------
# error: command failed with exit status: 0x460

--

********************
********************
Failed Tests (42):
  Profile-x86_64 :: ContinuousSyncMode/runtime-counter-relocation.c
  Profile-x86_64 :: Windows/coverage-linkage.cpp
  Profile-x86_64 :: Windows/instrprof-multiprocess.test
  Profile-x86_64 :: coverage-inline.cpp
  Profile-x86_64 :: coverage_comments.cpp
  Profile-x86_64 :: coverage_emptylines.cpp
  Profile-x86_64 :: gcc-flag-compatibility.test
  Profile-x86_64 :: infinite_loop.c
  Profile-x86_64 :: instrprof-api.c
  Profile-x86_64 :: instrprof-basic.c
  Profile-x86_64 :: instrprof-binary-correlate.c
  Profile-x86_64 :: instrprof-block-coverage.c
  Profile-x86_64 :: instrprof-bufferio.c
  Profile-x86_64 :: instrprof-dump.c
  Profile-x86_64 :: instrprof-entry-coverage.c
  Profile-x86_64 :: instrprof-error.c
  Profile-x86_64 :: instrprof-get-filename.c
  Profile-x86_64 :: instrprof-groups.c
  Profile-x86_64 :: instrprof-merge-empty-data.test
  Profile-x86_64 :: instrprof-merge-error.c
  Profile-x86_64 :: instrprof-no-mmap-during-merging.c
  Profile-x86_64 :: instrprof-override-filename-then-reset-default.c
  Profile-x86_64 :: instrprof-override-filename-with-env.c
  Profile-x86_64 :: instrprof-override-filename.c
  Profile-x86_64 :: instrprof-path.c
  Profile-x86_64 :: instrprof-reset-counters.c
  Profile-x86_64 :: instrprof-set-file-object-merging.c
  Profile-x86_64 :: instrprof-set-file-object.c
  Profile-x86_64 :: instrprof-set-filename-then-reset-default.c
  Profile-x86_64 :: instrprof-set-filename.c
  Profile-x86_64 :: instrprof-timestamp.c
  Profile-x86_64 :: instrprof-tmpdir.c
  Profile-x86_64 :: instrprof-value-prof-2.c
  Profile-x86_64 :: instrprof-value-prof-evict.test
  Profile-x86_64 :: instrprof-value-prof-reset.c
  Profile-x86_64 :: instrprof-value-prof.c
  Profile-x86_64 :: instrprof-value-prof.test
  Profile-x86_64 :: instrprof-version-mismatch.c
  Profile-x86_64 :: instrprof-write-file-atexit-explicitly.c
  Profile-x86_64 :: instrprof-write-file-only.c
  Profile-x86_64 :: instrprof-write-file.c
  Profile-x86_64 :: runtime_infinite.c


Testing Time: 5.41s

Total Discovered Tests: 405
  Unsupported      : 224 (55.31%)
  Passed           : 135 (33.33%)
  Expectedly Failed:   4 (0.99%)
  Failed           :  42 (10.37%)

@yxsamliu

yxsamliu commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

This broke our builds on Windows. I guess it relates to this:

The host-side hook __llvm_profile_hip_collect_device_data is already declared weak in InstrProfilingFile.c (PR #200101), so its absence is fine at link time.

because we get undefined symbol errors for __llvm_profile_hip_collect_device_data and looking at #200101 it does not declare that symbol weak on Windows.

Thanks. got a fix #200859

yxsamliu added a commit that referenced this pull request Jun 1, 2026
…acro (#200859)

PR #200111 stops compiling InstrProfilingPlatformROCm.cpp (which defines
the
HIP GPU helper __llvm_profile_hip_collect_device_data) in profile-only
builds.
But the compile define -DCOMPILER_RT_BUILD_PROFILE_ROCM=1 was still
added
whenever the COMPILER_RT_BUILD_PROFILE_ROCM option was on (the default),
so
InstrProfilingFile.c still referenced the helper from
__llvm_profile_write_file
even though it was never built.

On ELF the declaration is weak, so the undefined symbol folds to null
and the
address-guarded call is skipped. COFF/Windows has no such fallback:

  error LNK2019: unresolved external symbol
  __llvm_profile_hip_collect_device_data referenced in function
  __llvm_profile_write_file

Add the define only when PROFILE_HAS_HIP_INTERCEPTOR is true, i.e. the
same
condition that keeps InstrProfilingPlatformROCm.cpp in the archive, so
the
macro is defined iff the helper is actually compiled in.

Reported by zmodem:
#200111 (comment)
llvm-upstreamsync Bot pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jun 1, 2026
…terceptor macro (#200859)

PR #200111 stops compiling InstrProfilingPlatformROCm.cpp (which defines
the
HIP GPU helper __llvm_profile_hip_collect_device_data) in profile-only
builds.
But the compile define -DCOMPILER_RT_BUILD_PROFILE_ROCM=1 was still
added
whenever the COMPILER_RT_BUILD_PROFILE_ROCM option was on (the default),
so
InstrProfilingFile.c still referenced the helper from
__llvm_profile_write_file
even though it was never built.

On ELF the declaration is weak, so the undefined symbol folds to null
and the
address-guarded call is skipped. COFF/Windows has no such fallback:

  error LNK2019: unresolved external symbol
  __llvm_profile_hip_collect_device_data referenced in function
  __llvm_profile_write_file

Add the define only when PROFILE_HAS_HIP_INTERCEPTOR is true, i.e. the
same
condition that keeps InstrProfilingPlatformROCm.cpp in the archive, so
the
macro is defined iff the helper is actually compiled in.

Reported by zmodem:
llvm/llvm-project#200111 (comment)
llvm-sync Bot pushed a commit to arm/arm-toolchain that referenced this pull request Jun 1, 2026
…terceptor macro (#200859)

PR #200111 stops compiling InstrProfilingPlatformROCm.cpp (which defines
the
HIP GPU helper __llvm_profile_hip_collect_device_data) in profile-only
builds.
But the compile define -DCOMPILER_RT_BUILD_PROFILE_ROCM=1 was still
added
whenever the COMPILER_RT_BUILD_PROFILE_ROCM option was on (the default),
so
InstrProfilingFile.c still referenced the helper from
__llvm_profile_write_file
even though it was never built.

On ELF the declaration is weak, so the undefined symbol folds to null
and the
address-guarded call is skipped. COFF/Windows has no such fallback:

  error LNK2019: unresolved external symbol
  __llvm_profile_hip_collect_device_data referenced in function
  __llvm_profile_write_file

Add the define only when PROFILE_HAS_HIP_INTERCEPTOR is true, i.e. the
same
condition that keeps InstrProfilingPlatformROCm.cpp in the archive, so
the
macro is defined iff the helper is actually compiled in.

Reported by zmodem:
llvm/llvm-project#200111 (comment)
zmodem added a commit that referenced this pull request Jun 3, 2026
…201416)

This broke profiling builds on Windows by switching the profile library
to link against the dynamic CRT; see discussion on the PR.

There were already a number of issues reported and fixed after this PR.
Rather than piling on the fixes (and this one may need some work),
revert back to green for now to let the project recover.

This reverts commit 5db1364.

Additionally, this reverts the followup PRs in
635e120,
2766733,
4c33844, and
5eca8b6:

"[PGO][HIP] Stop pulling ROCm.o into every PGO host link (#200101)"
"[compiler-rt][profile] Add COMPILER_RT_BUILD_PROFILE_ROCM option
(#200127)"
"[PGO][HIP] Skip ROCm interceptor in profile-only compiler-rt builds
(#200111)"
"[PGO][HIP] Fix profile-only Windows link by gating ROCm interceptor
macro (#200859)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler-rt PGO Profile Guided Optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants