Repository navigation
add ability to pass force-undefined-symbols to the linker - #12631
Conversation
This commit enables `-u <symbol>` for ELF and `-include:<symbol>` for COFF linkers for use internally. This means we do not expose these flags to the users just yet, however, we make use of them internally whenever required. One such use case is forcing inclusion of `_tls_index` when linking for Windows with mingw and LTO and dead code stripping enabled. This ensures we add `_tls_index` to the symbol resolver as an undefined symbol and force the linker to include an atom that provides it marking it a dead-code-stripping root - meaning it will not be garbage collected by the linker no matter what.
|
I feel bad about posting on this since I'm using Zig as a cross-compiler for Rust, but this seems to be causing my builds to fail with One of the old zig versions I was using did compile & link my projects fine so this pr seems to be where the Also an example project of this where I'm using cargo-zigbuild which acts as a wrapper for cross-compiling along with the Just wondering if I should post this elsewhere for help. |
|
Thanks for bringing this to my attention @rtldg! I'll be happy to investigate what is happening and hopefully provide a fix :-) |
This commit enables
-u <symbol>for ELF and-include:<symbol>for COFF linkers for use internally. This means we do not expose these flags to the users just yet, however, we make use of them internally whenever required. One such use case is forcing inclusion of_tls_indexwhen linking for Windows with mingw and LTO and dead code stripping enabled. This ensures we add_tls_indexto the symbol resolver as an undefined symbol and force the linker to include an atom that provides it marking it a dead-code-stripping root - meaning it will not be garbage collected by the linker no matter what.This is my proposed alternative to #8674 which doesn't rely on scanning input source files by name when compiling mingw and putting in the cache. Instead, we tell the linker to force-include
_tls_indexwhenever we link against mingw libc.Closes #8531
@andrewrk I've also had a look at your reported C++ problems in presence of LTO but I couldn't repro it locally so unless we get a report that it's still the case, I have now enabled LTO by default on Windows for Release builds, and I am marking #8531 for closing.
cc @xxxbxxx