[clang] [compiler-rt] [llvm] [PGO][AMDGPU] Add basic HIP offload PGO support (PR #177665)
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 3 07:34:33 PDT 2026
zmodem wrote:
As the comment in compiler-rt/lib/profile/CMakeLists.txt points out, "profile historically used the static CRT (/MT)". This PR changed it to the dynamic CRT (/MD). That's a pretty major change. Was it discussed somewhere?
This broke all builds that were using the profiling library with the static CRT.
Given the number of issues that have come up after this landed, perhaps it's time to back it out so the project can recover?
---
Here's a reproducer for the breakage:
```
cmake -Bbuild.foo -GNinja -DCMAKE_BUILD_TYPE=Release -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 clang runtimes
type a.c
int main() { return 0; }
build.foo\bin\clang-cl a.c -fprofile-generate
LINK : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4217: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj)' in function 'lprofCreateBufferIOInternal'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj)'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingValue.c.obj)'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingPlatformROCm.cpp.obj)'
LINK : warning LNK4217: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj)' in function 'lprofCreateBufferIOInternal'
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingValue.c.obj)'
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingPlatformROCm.cpp.obj)'
LINK : warning LNK4217: symbol 'malloc' defined in 'libucrt.lib(malloc.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj)' in function '__llvm_profile_get_path_prefix'
LINK : warning LNK4286: symbol 'malloc' defined in 'libucrt.lib(malloc.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj)'
LINK : warning LNK4286: symbol 'malloc' defined in 'libucrt.lib(malloc.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingPlatformROCm.cpp.obj)'
LINK : warning LNK4286: symbol '__acrt_iob_func' defined in 'libucrt.lib(_file.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingPlatformROCm.cpp.obj)'
LINK : warning LNK4217: symbol '__acrt_iob_func' defined in 'libucrt.lib(_file.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj)' in function '__llvm_profile_get_path_prefix'
LINK : warning LNK4286: symbol '__acrt_iob_func' defined in 'libucrt.lib(_file.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj)'
LINK : warning LNK4286: symbol '__acrt_iob_func' defined in 'libucrt.lib(_file.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingMerge.c.obj)'
LINK : warning LNK4286: symbol '__acrt_iob_func' defined in 'libucrt.lib(_file.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingValue.c.obj)'
LINK : warning LNK4286: symbol '__stdio_common_vfprintf' defined in 'libucrt.lib(output.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingPlatformROCm.cpp.obj)'
LINK : warning LNK4217: symbol '__stdio_common_vfprintf' defined in 'libucrt.lib(output.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj)' in function 'fprintf'
LINK : warning LNK4286: symbol '__stdio_common_vfprintf' defined in 'libucrt.lib(output.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj)'
LINK : warning LNK4286: symbol '__stdio_common_vfprintf' defined in 'libucrt.lib(output.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingMerge.c.obj)'
LINK : warning LNK4286: symbol '__stdio_common_vfprintf' defined in 'libucrt.lib(output.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingValue.c.obj)'
LINK : warning LNK4217: symbol '_errno' defined in 'libucrt.lib(errno.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj)' in function '__llvm_profile_write_file'
LINK : warning LNK4286: symbol '_errno' defined in 'libucrt.lib(errno.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj)'
LINK : warning LNK4217: symbol '_fileno' defined in 'libucrt.lib(fileno.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj)' in function 'writeFile'
LINK : warning LNK4286: symbol '_fileno' defined in 'libucrt.lib(fileno.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj)'
LINK : warning LNK4286: symbol '_fileno' defined in 'libucrt.lib(fileno.obj)' is imported by 'oldnames.lib(fileno.obi)'
LINK : warning LNK4217: symbol 'atoi' defined in 'libucrt.lib(atox.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj)' in function 'writeFile'
LINK : warning LNK4286: symbol 'atoi' defined in 'libucrt.lib(atox.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj)'
LINK : warning LNK4286: symbol 'atoi' defined in 'libucrt.lib(atox.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingValue.c.obj)'
LINK : warning LNK4217: symbol 'fclose' defined in 'libucrt.lib(fclose.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj)' in function 'writeFile'
LINK : warning LNK4217: symbol 'fflush' defined in 'libucrt.lib(fflush.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj)' in function 'writeFile'
LINK : warning LNK4217: symbol '__stdio_common_vsprintf' defined in 'libucrt.lib(output.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj)' in function 'snprintf'
LINK : warning LNK4286: symbol '__stdio_common_vsprintf' defined in 'libucrt.lib(output.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingPlatformROCm.cpp.obj)'
LINK : warning LNK4217: symbol '_open_osfhandle' defined in 'libucrt.lib(osfinfo.obj)' is imported by 'clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj)' in function 'lprofOpenFileEx'
LINK : warning LNK4217: symbol '_get_osfhandle' defined in 'libucrt.lib(osfinfo.obj)' is imported by 'clang_rt.profile-x86_64.lib(WindowsMMap.c.obj)' in function '__llvm_profile_mmap'
clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj) : error LNK2019: unresolved external symbol __imp_getpid referenced in function getCurFilename
oldnames.lib(getpid.obi) : error LNK2001: unresolved external symbol __imp_getpid
clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj) : error LNK2019: unresolved external symbol __imp_getenv referenced in function __llvm_profile_initialize_file
clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj) : error LNK2001: unresolved external symbol __imp_getenv
clang_rt.profile-x86_64.lib(InstrProfilingValue.c.obj) : error LNK2001: unresolved external symbol __imp_getenv
clang_rt.profile-x86_64.lib(InstrProfilingPlatformROCm.cpp.obj) : error LNK2001: unresolved external symbol __imp_getenv
clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj) : error LNK2019: unresolved external symbol __imp_strdup referenced in function parseAndSetFilename
oldnames.lib(strdup.obi) : error LNK2001: unresolved external symbol __imp_strdup
clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj) : error LNK2019: unresolved external symbol __imp_strerror referenced in function __llvm_profile_write_file
clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj) : error LNK2001: unresolved external symbol __imp_strerror
clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj) : error LNK2019: unresolved external symbol __imp_fopen referenced in function writeFile
clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj) : error LNK2019: unresolved external symbol __imp__chsize referenced in function writeFile
clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj) : error LNK2019: unresolved external symbol __imp_fseek referenced in function writeFile
clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj) : error LNK2019: unresolved external symbol __imp_fileno referenced in function __llvm_profile_set_file_object
clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj) : error LNK2001: unresolved external symbol __imp_fileno
oldnames.lib(fileno.obi) : error LNK2001: unresolved external symbol __imp_fileno
clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj) : error LNK2019: unresolved external symbol __imp_ftell referenced in function getProfileFileSizeForMerging
clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj) : error LNK2001: unresolved external symbol __imp_ftell
clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj) : error LNK2019: unresolved external symbol __imp_fwrite referenced in function fileWriter
clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj) : error LNK2019: unresolved external symbol __imp__putenv referenced in function truncateCurrentFile
clang_rt.profile-x86_64.lib(InstrProfilingFile.c.obj) : error LNK2019: unresolved external symbol __imp_strncpy referenced in function createProfileDir
clang_rt.profile-x86_64.lib(InstrProfilingPlatformROCm.cpp.obj) : error LNK2001: unresolved external symbol __imp_strncpy
clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj) : error LNK2019: unresolved external symbol __imp__mkdir referenced in function __llvm_profile_recursive_mkdir
clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj) : error LNK2019: unresolved external symbol __imp__fdopen referenced in function lprofOpenFileEx
clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj) : error LNK2019: unresolved external symbol __imp_fread referenced in function lprofGetFileContentBuffer
clang_rt.profile-x86_64.lib(InstrProfilingUtil.c.obj) : error LNK2019: unresolved external symbol __imp_feof referenced in function lprofGetFileContentBuffer
clang_rt.profile-x86_64.lib(InstrProfilingPlatformROCm.cpp.obj) : error LNK2019: unresolved external symbol __imp_realloc referenced in function __llvm_profile_offload_register_dynamic_module
clang_rt.profile-x86_64.lib(interception_win.cpp.obj) : error LNK2019: unresolved external symbol __imp__stricmp referenced in function "bool __cdecl __interception::OverrideImportedFunction(char const *,char const *,char const *,unsigned __int64,unsigned __int64 *)" (?OverrideImportedFunction at __interception@@YA_NPEBD00_KPEA_K at Z)
oldnames.lib(getpid.obi) : error LNK2001: unresolved external symbol __imp__getpid
oldnames.lib(strdup.obi) : error LNK2001: unresolved external symbol __imp__strdup
a.exe : fatal error LNK1120: 20 unresolved externals
clang-cl: error: linker command failed with exit code 1120 (use -v to see invocation)
```
https://github.com/llvm/llvm-project/pull/177665
More information about the cfe-commits
mailing list