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:
1 parent
c06aca2432
commit
26bba774fe
2 files changed
+36
-5
No files matched your search
+7
-5
@@ -157,6 +157,7 @@ RUN git clone -b master https://github.com/llvm-mirror/libcxx.git && \
|
||||
cd ../libunwind && \
|
||||
git checkout 2ddcf2461daa5d61c543474aed06b12a8b9ad816
|
||||
|
||||
COPY merge_archives.sh /build
|
||||
RUN cd libunwind && \
|
||||
for arch in $TOOLCHAIN_ARCHS; do \
|
||||
mkdir build-$arch && cd build-$arch && cmake \
|
||||
@@ -179,6 +180,9 @@ RUN cd libunwind && \
|
||||
-DCMAKE_CXX_FLAGS="-I/build/libcxx/include" \
|
||||
.. && \
|
||||
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; \
|
||||
done
|
||||
|
||||
@@ -239,9 +243,7 @@ RUN cd libcxx && \
|
||||
-DCMAKE_CXX_FLAGS="-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS" \
|
||||
.. && \
|
||||
make -j4 && make install && \
|
||||
../utils/merge_archives.py \
|
||||
--ar llvm-ar \
|
||||
-o $TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libc++.a \
|
||||
/build/merge_archives.sh \
|
||||
$TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libc++.a \
|
||||
$TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libunwind.a && \
|
||||
cd .. || exit 1; \
|
||||
@@ -258,12 +260,12 @@ RUN cd hello && \
|
||||
|
||||
RUN cd hello && \
|
||||
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
|
||||
|
||||
RUN cd hello && \
|
||||
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
|
||||
|
||||
ENV AR=llvm-ar
|
||||
|
||||
Executable
+29
@@ -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
|
||||
Reference in new issue
Block a user