This is an archive of the discontinued LLVM Phabricator instance.

[LTO] Pass -no-zero-initialized-in-bss on linker command line
Needs ReviewPublic

Authored by ahatanak on Aug 31 2015, 5:50 PM.

Details

Summary

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.

Diff Detail

Event Timeline

ahatanak updated this revision to Diff 33648.Aug 31 2015, 5:50 PM
ahatanak retitled this revision from to [LTO] Pass -no-zero-initialized-in-bss on linker command line.
ahatanak updated this object.
ahatanak added reviewers: echristo, dexonsmith.
ahatanak added a subscriber: cfe-commits.

Looks like something that should be in the bitcode, no? What happens if one
compile unit has it and another one doesn't?

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.

dexonsmith resigned from this revision.Oct 6 2020, 3:41 PM