[llvm-dev] Linking libc++(abi) (ideally statically) on non-llvm OS
Carsten Mattner via llvm-dev
llvm-dev at lists.llvm.org
Mon Feb 26 14:59:44 PST 2018
I've been unsuccessfully trying tell g++ or clang++ to use libc++(abi)
when building a C++ source file (single file for test purposes) when
the host cc and c++ are all configured to use glibc and libstdc++.
My goal is to statically links musl libc and libc++(abi) and create
binaries for Linux that just work anywhere. Naturally, I'm not
building a .so or depending on dynamic libs.
My last attempt was something along the lines of:
-nodefaultlibs -lc++ -lc++abi -lc -lgcc_s -lgcc
where, obviously, I hadn't tried to put musl libc into the equation
yet. First, I wanted to make sure I can use libc++(abi) dynamically.
Then, if there's no vestige of libstdc++ (right now there is), try
to link libc++.a and libc++abi.a. If that all works, go to step two,
which is getting rid of gcc's runtime support libs and the glibc
dependencies.
The test file was a dumb hello-world:
#include <iostream>
int main(int, char**) {
std::cout << "Hello, LLVM!" << std::endl;
return 0;
}
The questions I have are:
1. how do I use libc++(abi) exclusively on a Linux distro where
llvm's toolchain isn't the default host toolchain? In FreeBSD
it is the default, if you're wondering what I mean here.
2. how do I link libc++(abi).a when using clang++ and avoid any
C++ stdlib runtime dependency.
More information about the llvm-dev
mailing list