Page MenuHomePhabricator

[cmake] Don't pass -z discard-unused to Illumos ld

Authored by ro on Wed, Jun 10, 2:42 AM.



I'm currently working to port libc++ to Solaris. There exists a slightly bitrotten port
already, which was done on Illumos, an OpenSolaris derivative. In order not to break that
port with my work, I need to test the result on both Solaris and Illumos. While doing so,
it turned out that Illumos ld doesn't support the -z discard-sections=unused option
currently used on SunOS unconditionally.

While there exists a patch
for LLVM 9.0 in the OpenIndiana repository, it apparently hasn't been submitted
upstream and is completely wrong: it replaces -z discard-sections=unused with
-z ignore. In terms of the equivalent gld options, this means replacing --gc-sections
with --as-needed.

This patch instead tests if the linker actually supports the option before using it.

Tested on amd64-pc-solaris2.11 (all of Solaris 11.4, 11.3 and OpenIndiana 2020.04).

Ok for master?

Diff Detail

Event Timeline

ro created this revision.Wed, Jun 10, 2:42 AM

Seems reasonable to me.

This revision is now accepted and ready to land.Thu, Jun 11, 10:01 AM
This revision was automatically updated to reflect the committed changes.