Merge libpsapi.a into libunwind.a

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 commit is contained in:
Martin Storsjö committed 2017-11-28 22:56:42 +02:00
1 parent c06aca2432
commit 26bba774fe
2 files changed
+36 -5

No files matched your search

+7 -5
View File
@@ -157,6 +157,7 @@ RUN git clone -b master https://github.com/llvm-mirror/libcxx.git && \
cd ../libunwind && \ cd ../libunwind && \
git checkout 2ddcf2461daa5d61c543474aed06b12a8b9ad816 git checkout 2ddcf2461daa5d61c543474aed06b12a8b9ad816
COPY merge_archives.sh /build
RUN cd libunwind && \ RUN cd libunwind && \
for arch in $TOOLCHAIN_ARCHS; do \ for arch in $TOOLCHAIN_ARCHS; do \
mkdir build-$arch && cd build-$arch && cmake \ mkdir build-$arch && cd build-$arch && cmake \
@@ -179,6 +180,9 @@ RUN cd libunwind && \
-DCMAKE_CXX_FLAGS="-I/build/libcxx/include" \ -DCMAKE_CXX_FLAGS="-I/build/libcxx/include" \
.. && \ .. && \
make -j4 && make install && \ make -j4 && make install && \
/build/merge_archives.sh \
$TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libunwind.a \
$TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libpsapi.a && \
cd .. || exit 1; \ cd .. || exit 1; \
done done
@@ -239,9 +243,7 @@ RUN cd libcxx && \
-DCMAKE_CXX_FLAGS="-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS" \ -DCMAKE_CXX_FLAGS="-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS" \
.. && \ .. && \
make -j4 && make install && \ make -j4 && make install && \
../utils/merge_archives.py \ /build/merge_archives.sh \
--ar llvm-ar \
-o $TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libc++.a \
$TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libc++.a \ $TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libc++.a \
$TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libunwind.a && \ $TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libunwind.a && \
cd .. || exit 1; \ cd .. || exit 1; \
@@ -258,12 +260,12 @@ RUN cd hello && \
RUN cd hello && \ RUN cd hello && \
for arch in $TOOLCHAIN_ARCHS; do \ for arch in $TOOLCHAIN_ARCHS; do \
$arch-w64-mingw32-clang++ hello.cpp -o hello-cpp-$arch.exe -fno-exceptions -lpsapi || exit 1; \ $arch-w64-mingw32-clang++ hello.cpp -o hello-cpp-$arch.exe -fno-exceptions || exit 1; \
done done
RUN cd hello && \ RUN cd hello && \
for arch in $TOOLCHAIN_ARCHS; do \ for arch in $TOOLCHAIN_ARCHS; do \
$arch-w64-mingw32-clang++ hello-exception.cpp -o hello-exception-$arch.exe -lpsapi || exit 1; \ $arch-w64-mingw32-clang++ hello-exception.cpp -o hello-exception-$arch.exe || exit 1; \
done done
ENV AR=llvm-ar ENV AR=llvm-ar
+29
View File
@@ -0,0 +1,29 @@
#!/bin/sh
set -e
if [ $# -lt 2 ]; then
echo $0 lib add1 [add2...]
exit 1
fi
: ${AR:=llvm-ar}
: ${RANLIB:=llvm-ranlib}
SCRIPT=merge.mri
OUT=tmp.a
TARGET=$1
rm -f $SCRIPT
echo "CREATE $OUT" >> $SCRIPT
while [ $# -gt 0 ]; do
echo "ADDLIB $1" >> $SCRIPT
shift
done
echo "SAVE" >> $SCRIPT
echo "END" >> $SCRIPT
$AR -M < $SCRIPT
rm -f $SCRIPT
$RANLIB $OUT
mv $OUT $TARGET