Enable function sections with windows-gnu#75604
Enable function sections with windows-gnu#75604mati865 wants to merge 2 commits intorust-lang:masterfrom
Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
With MinGW and specific flags symbol may end up in multiple sections in some cases like: 0000000000000000 p .pdata$_ZN20stable_symbol_names113mono_function17hd4880e88dec8766dE 0000000000000000 t .text$_ZN20stable_symbol_names113mono_function17hd4880e88dec8766dE 0000000000000000 r .xdata$_ZN20stable_symbol_names113mono_function17hd4880e88dec8766dE 0000000000000000 T _ZN20stable_symbol_names113mono_function17hd4880e88dec8766dE This will cause an error when comparing that output directly with other library that only imports the symbol since it will appear only once. To avoid the issue pass "-g" to nm so only the global symbol (the one with "T" letter) will be listed.
14ee44a to
b655027
Compare
|
IIRC the reason it was disabled until now was because on Windows there's an egregiously small limit on sections in object files, which then leads to compilation failures. Is |
|
Apparently it was disabled because of the LLVM assertions: #13846 I have tried enabling it some time ago but got ui tests crashes. |
FWIW, the limit on sections in an object file is higher if compiling in "big object" mode. IIRC GCC and/or MSVC require you to pass specific flags for enabling this, while LLVM enables this format automatically as needed. |
|
r? @nagisa |
|
@bors r+ |
|
📌 Commit b655027 has been approved by |
|
⌛ Testing commit b655027 with merge 18dd0795f6aecafa408c6b35e9b28d2798a6ea8a... |
|
💔 Test failed - checks-actions |
|
Appears to be bug fixed in binutils 2.32 I'll look for a workaround. |
|
I can reproduce it locally with the same Binutils version as on CI, Binutils 2.34 are not affected. @mstorsjo do you remember if this is easily workaroundable in LLVM? |
What issue in particular are you referring to here? |
|
@mstorsjo I apologize I thought I had included the link. Here is ld.bfd bug report: https://sourceware.org/bugzilla/show_bug.cgi?id=23872 |
Ah, that one. I have one potential fix in mind - appending a final object file that contains .rdata contents that is aligned to 4 bytes, included as the last object file in the link command. The object file can be assembled from e.g. this: That should take care to make sure the end of the .rdata section is aligned to 4 bytes, avoiding that particular ld bug. |
|
Unfortunately that didn't work. I'll just close it for now. |
The comment here was a bit misleading, #13846 was about an LLVM assertion that failed when `-Zfunction-sections` was enabled. However, that bug has been fixed for a long time and the actual issue was that older `ld` versions would not correctly link binaries (see #75604 for the prior attempt at this change). This bug was fixed in version 2.32 of binutils and Rust now ships binutils 2.42 as of #119229 so we can remove this workaround!
Passed tests locally on x86_64 with LLVM assertions enabled.