[PATCH] D158206: [Driver] Add PIE support on Solaris

Rainer Orth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 18 07:55:46 PDT 2023


ro marked 2 inline comments as done.
ro added a comment.

In D158206#4596471 <https://reviews.llvm.org/D158206#4596471>, @MaskRay wrote:

>> I'll submit a follow-up patch to make use of crtbeginS.o and crtendS.o shortly.
>
> I think this patch should make this change, so that the change is correct on itself.

Ok, done.  I'll update with the merge patch once another round of testing has finished.



================
Comment at: clang/lib/Driver/ToolChains/Solaris.cpp:55
                                    const char *LinkingOutput) const {
+  const bool IsPIE =
+      !Args.hasArg(options::OPT_shared) &&
----------------
MaskRay wrote:
> On Linux, `clang -r` `-static` also disable the linker option `-pie`.
> `-static-pie` is handled as a special case which also disables the regular `-pie` code path.
I've taken `Gnu.cpp` (`getPIE`), removing the `-static-pie` handling.

Solaris supports neither `-static` (no `libc.a` etc. since Solaris 10) nor `-static-pie`.  Given that `gcc` silently ignores that, I'm doing the same.


================
Comment at: clang/test/Driver/solaris-ld.c:110
+// Check the right ld flags are present with -pie.
+// RUN: %clang -### %s -pie 2>&1 \
+// RUN:     --target=sparc-sun-solaris2.11 \
----------------
MaskRay wrote:
> The convention is to put `2>&1` at the end of the command, aka before `|`
I've changed just the newly added tests.  There are a few others, but I've left the as is for now to avoid cluttering the patch with unrelated changes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158206/new/

https://reviews.llvm.org/D158206



More information about the cfe-commits mailing list