With linker copy relocations, PIE can generate better code for external global variable accesses. This patch adds a new option to clang to specify this. Please see http://reviews.llvm.org/D24849 for the patch to LLVM to optimize global accesses when this is available.
Details
- Reviewers
davide rnk - Commits
- rG165a8845f8ae: New clang option -mpie-copy-relocations to use copy relocations for PIE builds.
rC284638: New clang option -mpie-copy-relocations to use copy relocations for PIE builds.
rL284638: New clang option -mpie-copy-relocations to use copy relocations for PIE builds.
Diff Detail
Event Timeline
Is there a gcc option or they just assume they are targeting the
linker that was around when gcc was built?
+ if (Args.hasFlag(options::OPT_mpiecopyrelocs, options::OPT_mno_piecopyrelocs,
+ false)) {
+ CmdArgs.push_back("-piecopyrelocs");
+ }
you don't need the {}
+def piecopyrelocs : Flag<["-"], "piecopyrelocs">,
+ HelpText<"Linker copy relocations support when linking as PIE">;
I think you are missing a verb: Linker copy relocations *are* supported.
But how about just "Position independent executables can have copy relocations"?
Cheers,
Rafael
- Option name changed to -mpie-copy-relocations
- Option sets MCPIECopyRelocations in MCOptions
IIRC there's no GCC option. They base their decision on the configure-time check like you suggested.
include/clang/Driver/Options.td | ||
---|---|---|
1549 | I agree with Rafael, this needs a verb, like "Use copy relocations in PIE builds" or something. | |
1551 | The "no" option variants don't need to be CC1 options. | |
1552 | I don't think we need help text for the "no" variant. I think we add help text to "no" flags when the flag is on by default, for example -fno-exceptions. |
- Changed help text to "Avail copy relocations support for PIE builds"
- Removed mno-pie... as a CC1 option
- Removed help text from mno-pie..
lgtm
include/clang/Driver/Options.td | ||
---|---|---|
1549 | I guess "avail" is a verb, but I've never seen anyone use it. I'd really rather use "use". :) |
lib/Frontend/CompilerInvocation.cpp | ||
---|---|---|
567 | mpie_copy_relocations is the only CC1 flag here and that is pushed into CC1 command after checking for the negative. |
I agree with Rafael, this needs a verb, like "Use copy relocations in PIE builds" or something.