Clang driver option -fno-zero-initialized-in-bss is used to prevent global variables that are initialized to zero from being placed in the bss section, but is currently ignored when doing LTO. This patch fixes this bug by passing -no-zero-initialized-in-bss on ld64's command line using -mllvm. If we agree on the approach this patch takes, I plan to make similar changes for gold's plugin.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
Looks like something that should be in the bitcode, no? What happens if one
compile unit has it and another one doesn't?
Comment Actions
If it's important to be able to compile one file with -fno-zero-initialized-in-bss and another without the option, we could add a bit to GlobalVariable that indicates it shouldn't be go into the bss section. Is that what you are suggesting?
If we are going to take that approach, users will be passing -fno-zero-initialized-in-bss at compile time to set the bit for the GlobalVariables clang creates and pass the option again at link time (which will translate into -mllvm -nozero-initialized-in-bss) since some of the passes that are run at link time create GlobalVariables.