Now that we can build compiler-rt and libunwind with a stripped
llvm install, we can build things in a few smaller steps without
ending up with a larger docker image than before.
For x86 architectures, binutils objcopy and strip can be used as
such.
For armv7 and aarch64, binutils doesn't recognize the architectures
and refuse to touch the files. For most/everything that objcopy/strip
do, the actual architecture doesn't really matter though. Therefore,
provide a wrapper script and a minimal tool for editing PE executables,
that change the architecture from armv7 and aarch64 to i686 and x86_64
respectively before invoking binutils, and change it back afterwards.
In case the binutils tools are missing, just return a successful result
without doing anything for stripping operations (previously, we had the
<triplet>-strip tool symlinked to /bin/true, so this isn't any worse than
before) and fail for other objcopy operations.
gcc/libssp's configure script runs checks for flags that clang doesn't
implement. We actually just need to set a few HAVE defines and compile
the .c sources, so just check out this subdirectory using svn and build
it using a custom makefile.
This doesn't help reduce the docker image size since it's done
in a separate RUN step than the one that added the files. (compiler-rt
and libunwind currently fail to build after stripping the llvm
installation though.)
This makes the output architecture independent, allowing
the x86_64 GNU binutils binary to be used for other
architectures as well, including arm/arm64 which aren't supported
by binutils.
LLVM does have llvm-rc, which almost does what is needed.
Currently missing features:
- It doesn't run the C preprocessor (which can be wrapped with
a shellscript easily if necessary)
- It chokes on C structs/typedefs normally found in included
C headers
Provide wrappers named <triplet>-gcc and <triplet>-g++ as well,
to ease cross compilation with e.g. autotools, to allow just
specifying --host=<triplet>.
Provide wrappers for objdump and ld that provide specific output
that autotools look for.
Provide <triplet>-strip as a symlink to /bin/true, since there is
no strip tool available yet (and llvm-objcopy doesn't support
COFF yet).
This version of mingw-w64 provides a few more import libraries
for aarch64, and allows using a lot more uncommon stdio functions
with ucrtbase.
The new libcxx version allows forcing using win32 threads even
if pthread.h exists.
This includes support for a -fdwarf-exceptions flag in clang,
allowing to choose that exception handling model on architectures
where it isn't the default.
This avoids having to manually add -lpsapi when linking in libc++.a.
This requires using a new script to merge libraries using ar -M
with a small MRI script.
The script merge_archives.py in libcxx does the merge by manually
extracting all object files and creating a new archive out of them.
The import libraries created by LLVM have more than one object file
with the same file name (just like MSVC tools do), so extracting
them doesn't work as intended - but merging using a MRI script works.
This is the correct layering/ordering.
This requies setting forcing CXX_SUPPORTS_CXX11=TRUE in cmake,
since it tries linking to see whether the C++ environment works,
but we haven't built libcxx yet.
Manually add the libcxx include directory to the include path
(since libunwind does use some C++ headers but doesn't require
linking to C++ libraries).