Looks like something that should be in the bitcode, no? What happens if one compile unit has it and another one doesn't? On Aug 31, 2015 8:50 PM, "Akira Hatanaka via cfe-commits" < cfe-commits@lists.llvm.org> wrote:
> ahatanak created this revision. > ahatanak added reviewers: echristo, dexonsmith. > ahatanak added a subscriber: cfe-commits. > > 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. > > http://reviews.llvm.org/D12511 > > Files: > lib/Driver/Tools.cpp > test/Driver/no-zero-initialized-in-bss.c > > Index: test/Driver/no-zero-initialized-in-bss.c > =================================================================== > --- /dev/null > +++ test/Driver/no-zero-initialized-in-bss.c > @@ -0,0 +1,11 @@ > +// RUN: %clang -### -c -fno-zero-initialized-in-bss %s 2>&1 | FileCheck > -check-prefix CHECK-NO-ZERO %s > +// RUN: %clang -### -c -fzero-initialized-in-bss %s 2>&1 | FileCheck > -check-prefix CHECK-ZERO %s > +// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix CHECK-ZERO %s > +// RUN: %clang -### -flto -fzero-initialized-in-bss > -fno-zero-initialized-in-bss -target x86_64-apple-darwin %s 2>&1 | > FileCheck -check-prefix CHECK-NO-ZERO-LTO-DARWIN %s > +// RUN: %clang -### -flto -fno-zero-initialized-in-bss > -fzero-initialized-in-bss -target x86_64-apple-darwin %s 2>&1 | FileCheck > -check-prefix CHECK-ZERO-LTO-DARWIN %s > +// RUN: %clang -### -flto -target x86_64-apple-darwin %s 2>&1 | FileCheck > -check-prefix CHECK-ZERO-LTO-DARWIN %s > + > +// CHECK-NO-ZERO: -mno-zero-initialized-in-bss > +// CHECK-ZERO-NOT: -mno-zero-initialized-in-bss > +// CHECK-NO-ZERO-LTO-DARWIN: -mllvm -nozero-initialized-in-bss > +// CHECK-ZERO-LTO-DARWIN-NOT: -mllvm -nozero-initialized-in-bss > Index: lib/Driver/Tools.cpp > =================================================================== > --- lib/Driver/Tools.cpp > +++ lib/Driver/Tools.cpp > @@ -6579,6 +6579,11 @@ > Args.AddAllArgs(CmdArgs, options::OPT_dylinker__install__name); > Args.AddLastArg(CmdArgs, options::OPT_dylinker); > Args.AddLastArg(CmdArgs, options::OPT_Mach); > + > + if (D.IsUsingLTO(Args)) > + if (!Args.hasFlag(options::OPT_fzero_initialized_in_bss, > + options::OPT_fno_zero_initialized_in_bss)) > + CmdArgs.push_back("-mllvm -nozero-initialized-in-bss"); > } > > void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA, > > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits