From fcfcef0592afb7f8267571ed46e082d347541635 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Thu, 11 Jul 2019 19:12:04 +0100 Subject: [PATCH] Updated Mingw build scripts to workaround libtool/slibtool issues. Currently we need both libtool and slibtool: - libtool fails to link self-contained DLL (it ignores '-static-libstdc++ -static-libgcc'), but manages to link EXEs with static library - slibtool manages to link self-contained DLL, but then fails to link the final EXEs with it (it passes '-lre2c' before some other predefined object file that contains definitions from libgcc) --- __alltest.sh | 4 +++- __build_mingw.sh | 7 +++++-- __build_mingw_slibtool.sh | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100755 __build_mingw_slibtool.sh diff --git a/__alltest.sh b/__alltest.sh index 931c097c..a451a6be 100755 --- a/__alltest.sh +++ b/__alltest.sh @@ -1,7 +1,8 @@ #!/bin/sh # normal tests -for d in __build{,_asan,_ubsan,_lsan,_clang,_clang_msan,_m32,_glibcxx_debug} ; do +# - exclude _clang_msan as it requires libc++ built with MSan +for d in __build{,_asan,_ubsan,_lsan,_clang,_m32,_glibcxx_debug} ; do ./${d}.sh \ && cd ${d} \ && make check VERBOSE=1 \ @@ -17,6 +18,7 @@ done || { cd .. ; echo "*** skeleton failed ***"; exit 1; } # mingw +# - exclude _mingw_slibtool, as it fails to link EXEs due to symbol collisions ./__build_mingw.sh \ && cd __build_mingw \ && make wtests \ diff --git a/__build_mingw.sh b/__build_mingw.sh index 51daba5c..1ce12e25 100755 --- a/__build_mingw.sh +++ b/__build_mingw.sh @@ -5,9 +5,12 @@ rm -rf $builddir mkdir $builddir cd $builddir -../configure LDFLAGS="-static-libstdc++ -static-libgcc" \ +# '-static' tells libtool not to build shared libraries (DLLs) +# (they would be of no use anyway because libtool ignores '-static-libstdc++ +# -static-libgcc' options and produces non-portable DLLs) +../configure LDFLAGS="-static -static-libstdc++ -static-libgcc" \ --enable-debug \ --enable-libs \ --host i686-w64-mingw32 \ - && make -j$(nproc) LIBTOOL="dlibtool" + && make -j$(nproc) cd .. diff --git a/__build_mingw_slibtool.sh b/__build_mingw_slibtool.sh new file mode 100755 index 00000000..acef2233 --- /dev/null +++ b/__build_mingw_slibtool.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +builddir=__build_mingw_slibtool +rm -rf $builddir +mkdir $builddir + +cd $builddir +# slibtool fails to build final EXEs because of symbol collisions: +# libre2c is statically linked with libgcc, and slibtool passes -lre2c +# before some object file that also contains definitions from libgcc +# +# however, slibtool manages to correctly build self-contained libre2c.dll +# (unlike libtool, which ignores '-static-libstdc++ -static-libgcc' and +# produces non-portable DLL) +../configure LDFLAGS="-static-libstdc++ -static-libgcc" \ + --enable-debug \ + --enable-libs \ + --host i686-w64-mingw32 \ + && make -j$(nproc) LIBTOOL="slibtool" +cd .. -- 2.40.0