This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Add -static= to unify -static-{libgcc,libstdc++}
Needs ReviewPublic

Authored by MaskRay on Oct 12 2018, 7:15 PM.

Details

Summary

We have lots of -static-* options now. Add -static= (OPT_static_EQ) so
that people can specify -static=foo,bar instead of -static-foo and
-static-bar. This saves us a bunch of OPT_static_foo, OPT_static_bar,
etc, which may be added in the future.

Diff Detail

Event Timeline

MaskRay created this revision.Oct 12 2018, 7:15 PM
MaskRay updated this revision to Diff 169538.Oct 12 2018, 7:48 PM

Rename local variables

Greeting from a dev meeting attendee :)

Seems like a better solution than what I had in D37726.
I'm not sully sure on the naming so I think someone else should also sign off on this.

Also, Sorry for the long time to reply, I don't LLVM often enough :)

Seems like a better solution than what I had in D37726.
I'm not sully sure on the naming so I think someone else should also sign off on this.

This is still not good enough. --static=rtlib,stdlib may be better. I'll also find some time to improve this one :)

tomgrc added a subscriber: tomgrc.Aug 20 2019, 12:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 20 2019, 12:09 PM
hhb added a subscriber: hhb.Aug 23 2019, 11:31 AM
MaskRay updated this revision to Diff 219025.Sep 5 2019, 8:50 PM
MaskRay retitled this revision from [Driver] Add -static-{rtlib,stdlib} and make -static-{libgcc,libstdc++} their aliases to [Driver] Add -static= to unify -static-{libgcc,libstdc++}.
MaskRay edited the summary of this revision. (Show Details)
MaskRay added reviewers: phosek, pirama, rnk, srhines.
MaskRay removed a subscriber: rnk.

Repurpose the patch. Add -static= instead

pirama added a comment.EditedSep 5 2019, 9:49 PM

Does this regress from existing behavior for unused argument warnings? Currently, -static-libstdc++ -nostdlib issues an unused argument warning for -static-libstdc++, while AFAICT -static=c++stdlib -nostdlib doesn't.

I'm not exactly sure how/where to issue this warning, though.

Does this regress from existing behavior for unused argument warnings? Currently, -static-libstdc++ -nostdlib issues an unused argument warning for -static-libstdc++, while AFAICT -static=c++stdlib -nostdlib doesn't.

I'm not exactly sure how/where to issue this warning, though.

This change will suppress some unused argument warnings but I'll not call that "regression":)

Various toolchains already do things like:

Args.ClaimAllArgs(options::OPT_g_Group);
Args.ClaimAllArgs(options::OPT_emit_llvm);
Args.ClaimAllArgs(options::OPT_w);

Hexagon and Myriad even do Args.ClaimAllArgs(options::OPT_static_libgcc); This diagnostic IMO has very low value.

Yu added a subscriber: Yu.Oct 21 2020, 1:44 PM

I accidentally come into this thread when searching for how to statically link to libc++/libc++abi. I'm really curious if this patch will or will not get merged. I'm really painful on using c++17 on ancient environment which does not have libc++/libc++ abi dynamic library. We have to remove -stdlib=libc++ and manually add libc++.a/libc++abi.a to the object lists. That's pretty hacky for cmake users. It'll be really awesome if we can have this patch merged. Thanks guys!

In D53238#2345618, @Yu wrote:

I accidentally come into this thread when searching for how to statically link to libc++/libc++abi. I'm really curious if this patch will or will not get merged. I'm really painful on using c++17 on ancient environment which does not have libc++/libc++ abi dynamic library. We have to remove -stdlib=libc++ and manually add libc++.a/libc++abi.a to the object lists. That's pretty hacky for cmake users. It'll be really awesome if we can have this patch merged. Thanks guys!

Though non-obvious, -static-libstdc++ actually works for -stdlib=libc++...