[compiler-rt] [Profile] Dump binary id to raw profiles on Windows. (PR #75618)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 5 12:40:35 PST 2024


mstorsjo wrote:

> It looks like this breaks the build when using mingw:
> 
> > C:/a/rust/rust/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\a\rust\rust\build\x86_64-pc-windows-gnu\stage2\lib\rustlib\x86_64-pc-windows-gnu\lib\libprofiler_builtins-06ad067b40ce3a0d.rlib(InstrProfilingPlatformWindows.o):InstrProfilingPlatformWindows.c:(.rdata$.refptr.__buildid[.refptr.__buildid]+0x0): undefined reference to `__buildid'
> 
> I don't really get how this code is supposed to work, I don't think extern selectany supports symbols that are not defined?

I think the idea was that it previously was a weak undefined symbol - if linking with LLD 18, the linker does define it and we can pick up the build ID from there. But while GNU binutils and GCC did come up with the way of emulating ELF weak symbols on top of COFF, they do have a couple of bugs around it, which I presume is what you're running into here.

I guess that with the fix from https://github.com/llvm/llvm-project/pull/80700, it changes the symbol from a weak undefined into a weak defined. If linking with LLD as opposed to GNU ld, this should hopefully be handled correctly, and it should prefer the `__buildid` that is provided by the linker (as a non-weak symbol) rather than the default dummy uninitialized/zero-initialized `__buildid` here.

https://github.com/llvm/llvm-project/pull/75618


More information about the llvm-commits mailing list