[llvm-dev] unusual use of getenv

Michael Kruse via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 9 17:29:27 PST 2020


Am Mo., 2. Nov. 2020 um 14:01 Uhr schrieb David Blaikie <dblaikie at gmail.com>:
> Hmm, not sure why the whole file was added only when MSVC support was added - if it is a "static library object file selection" issue. Wouldn't that have turned up on other platforms before that moment?

It did turn up on non-Windows platforms in
https://reviews.llvm.org/D61446. The name of the file where this trick
is used "LinkAllPasses.h" should give a hint what it is used for.
Looking into the entire history of the file, I have no idea how one
would have concluded this whas a Windows thing. It first occurred in
1c5b428ff8234cef705bf57bc1418deb4db25c83 (SVN r23921) when Windows
support was not yet a thing.

LLVM tools themselves, like opt, call some function for each LLVM
component directly (such as initializeCore()) to achieve the same
thing. Howwer clang does include LinkAllPasses.h (in cc1_main.cpp).
All that matters is that there is a strong reference to at least one
symbol to each object file, otherwise the linker will not include it
when.

Michael


More information about the llvm-dev mailing list