Page MenuHomePhabricator

Add support in CMake to statically link the C++ standard library.

Authored by erichkeane on Aug 1 2019, 1:04 PM.



It is sometimes useful to have the C++ standard library linked into the
assembly when compiling clang, particularly when distributing a compiler
onto systems that don't have a copy of stdlibc++ or libc++ installed.

This functionality should work with either GCC or Clang as the host
compiler, though statically linking libc++ (as may be required for
licensing purposes) is only possible if the host compiler is Clang with
a copy of libc++ available.

Diff Detail


Event Timeline

erichkeane created this revision.Aug 1 2019, 1:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2019, 1:04 PM
Herald added a subscriber: mgorny. · View Herald Transcript

Unfortunately, this ends up adding a warning or two to the build if you enable this, since we have a couple of things built in "C" (flag not used...). In the 'clang' test I did, ./bin/count was the only one. Unfortunately, we don't have separate C vs C++ linking flags, so I think this is just something that someone using this flag needs to deal with.

Does anyone have issues with this? Can I commit it?

This revision was not accepted when it landed; it landed in state Needs Review.Aug 14 2019, 12:55 PM
This revision was automatically updated to reflect the committed changes.