From b3b6c570dac24d6bfd39c4c72e2d52ecf491fcf5 Mon Sep 17 00:00:00 2001 From: Evgeny Grin Date: Thu, 16 Dec 2021 16:01:38 +0300 Subject: Added local patches for autotools (mainly for libtool) Patches required mostly for MSys2 toolchains, especially for MSys2/Clang{64,32} toolchains. --- .../0003-Pass-various-flags-to-GCC.patch | 20 + ...us-runtime-library-flags-to-GCC.mingw-mod.patch | 30 ++ .../0006-Fix-strict-ansi-vs-posix-mod.patch | 22 + .../0009-libtool-2.4.2.418-msysize-mod.patch | 443 +++++++++++++++++++++ .../0010-libtool-2.4.2-include-process-h-mod.patch | 12 + ...ng_rt-static-archives-compiler-internal-l.patch | 33 ++ ...e-files-over-linker-scripts-for-mingw-mod.patch | 83 ++++ ...ly-linking-compiler-support-libraries-mod.patch | 38 ++ .../0014-Support-llvm-objdump-f-output-mod.patch | 39 ++ contrib/autotools-patches/apply-all.sh | 33 ++ 10 files changed, 753 insertions(+) create mode 100644 contrib/autotools-patches/0003-Pass-various-flags-to-GCC.patch create mode 100644 contrib/autotools-patches/0003-Pass-various-runtime-library-flags-to-GCC.mingw-mod.patch create mode 100644 contrib/autotools-patches/0006-Fix-strict-ansi-vs-posix-mod.patch create mode 100644 contrib/autotools-patches/0009-libtool-2.4.2.418-msysize-mod.patch create mode 100644 contrib/autotools-patches/0010-libtool-2.4.2-include-process-h-mod.patch create mode 100644 contrib/autotools-patches/0011-Pick-up-clang_rt-static-archives-compiler-internal-l.patch create mode 100644 contrib/autotools-patches/0012-Prefer-response-files-over-linker-scripts-for-mingw-mod.patch create mode 100644 contrib/autotools-patches/0013-Allow-statically-linking-compiler-support-libraries-mod.patch create mode 100644 contrib/autotools-patches/0014-Support-llvm-objdump-f-output-mod.patch create mode 100755 contrib/autotools-patches/apply-all.sh (limited to 'contrib') diff --git a/contrib/autotools-patches/0003-Pass-various-flags-to-GCC.patch b/contrib/autotools-patches/0003-Pass-various-flags-to-GCC.patch new file mode 100644 index 00000000..6833f297 --- /dev/null +++ b/contrib/autotools-patches/0003-Pass-various-flags-to-GCC.patch @@ -0,0 +1,20 @@ +diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh +index 21e5e078..ddd6e36f 100755 +--- a/build-aux/ltmain.sh ++++ b/build-aux/ltmain.sh +@@ -7369,11 +7369,14 @@ func_mode_link () + # -fsanitize=* Clang/GCC memory and address sanitizer + # -fuse-ld=* Linker select flags for GCC + # -static-* direct GCC to link specific libraries statically ++ # -shared-* direct GCC to link shared version of specific libraries + # -fcilkplus Cilk Plus language extension features for C/C++ + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ + -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ +- -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus) ++ -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-shared-*|-fcilkplus| \ ++ -ftree-parallelize-loops=*|-fgnu-tm|-ffast-math| \ ++ -funsafe-math-optimizations|-fvtable-verify*) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + func_append compile_command " $arg" diff --git a/contrib/autotools-patches/0003-Pass-various-runtime-library-flags-to-GCC.mingw-mod.patch b/contrib/autotools-patches/0003-Pass-various-runtime-library-flags-to-GCC.mingw-mod.patch new file mode 100644 index 00000000..f4815d78 --- /dev/null +++ b/contrib/autotools-patches/0003-Pass-various-runtime-library-flags-to-GCC.mingw-mod.patch @@ -0,0 +1,30 @@ +[PATCH 3/6] Pass various runtime library flags to GCC. +* build-aux/ltmain.in (func_mode_link): Pass the +-shared-libgcc and -static-lib* flags along to GCC. +--- + build-aux/ltmain.sh | 5 ++++- + 1 files changed, 4 insertions(+), 1 deletions(-) + +diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh +index 1821779..eda7790 100644 +--- a/build-aux/ltmain.sh ++++ b/build-aux/ltmain.sh +@@ -5084,9 +5084,14 @@ func_mode_link () + # --sysroot=* for sysroot support + # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization + # -stdlib=* select c++ std lib with clang ++ # -{shared,static}-libgcc, -static-{libgfortran|libstdc++} ++ # link against specified runtime library + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ +- -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) ++ -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ ++ -ftree-parallelize-loops=*|-fcilkplus|-fgnu-tm|-ffast-math| \ ++ -funsafe-math-optimizations|-fvtable-verify*| \ ++ -shared-libgcc|-static-libgcc|-static-libgfortran|-static-libstdc++) + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + func_append compile_command " $arg" +-- +1.7.1 + diff --git a/contrib/autotools-patches/0006-Fix-strict-ansi-vs-posix-mod.patch b/contrib/autotools-patches/0006-Fix-strict-ansi-vs-posix-mod.patch new file mode 100644 index 00000000..61a1cc56 --- /dev/null +++ b/contrib/autotools-patches/0006-Fix-strict-ansi-vs-posix-mod.patch @@ -0,0 +1,22 @@ +[PATCH 6/6] Fix STRICT_ANSI vs POSIX +* build-aux/ltmain.in (func_mode_link): Also check for _POSIX +as well as __STRICT_ANSI__ to avoid re-definitions. +--- + build-aux/ltmain.sh | 4 +++- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh +index af46cb8..244bb5b 100644 +--- a/build-aux/ltmain.sh ++++ b/build-aux/ltmain.sh +@@ -3382,7 +3382,7 @@ + + /* declarations of non-ANSI functions */ + #if defined __MINGW32__ +-# ifdef __STRICT_ANSI__ ++# if defined(__STRICT_ANSI__) && !defined(__MINGW64_VERSION_MAJOR) || defined(_POSIX_) + int _putenv (const char *); + # endif + #elif defined __CYGWIN__ +-- +1.7.0.2.msysgit.0 diff --git a/contrib/autotools-patches/0009-libtool-2.4.2.418-msysize-mod.patch b/contrib/autotools-patches/0009-libtool-2.4.2.418-msysize-mod.patch new file mode 100644 index 00000000..4d44cf63 --- /dev/null +++ b/contrib/autotools-patches/0009-libtool-2.4.2.418-msysize-mod.patch @@ -0,0 +1,443 @@ +diff --git a/build-aux/config.guess b/build-aux/config.guess +index f50dcdb6..cd89e459 100755 +--- a/build-aux/config.guess ++++ b/build-aux/config.guess +@@ -883,6 +883,9 @@ EOF + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; ++ amd64:MSYS*:*:* | x86_64:MSYS*:*:*) ++ echo x86_64-unknown-msys ++ exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; +diff -Naur libtool-2.4.2.418-orig/build-aux/ltmain.sh libtool-2.4.2.418/build-aux/ltmain.sh +--- libtool-2.4.2.418-orig/build-aux/ltmain.sh 2013-10-27 02:53:58.000000000 +0400 ++++ libtool-2.4.2.418/build-aux/ltmain.sh 2014-09-02 10:29:08.840800000 +0400 +@@ -2315,7 +2315,7 @@ + case $host in + # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 + # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 +- *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) ++ *cygwin* | *msys* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) + # don't eliminate duplications in $postdeps and $predeps + opt_duplicate_compiler_generated_deps=: + ;; +@@ -3328,7 +3328,7 @@ + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in +- cygwin* | mingw* | pw32* | os2* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | os2* | cegcc*) + pic_mode=default + ;; + esac +@@ -4201,7 +4201,7 @@ + 'exit $?' + tstripme=$stripme + case $host_os in +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + case $realname in + *.dll.a) + tstripme= +@@ -4307,7 +4307,7 @@ + + # Do a test to see if this is really a libtool program. + case $host in +- *cygwin* | *mingw*) ++ *cygwin* | *msys* | *mingw*) + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + wrapper=$func_ltwrapper_scriptname_result +@@ -4382,7 +4382,7 @@ + # remove .exe since cygwin /usr/bin/install will append another + # one anyway + case $install_prog,$host in +- */usr/bin/install*,*cygwin*) ++ */usr/bin/install*,*cygwin* | */usr/bin/install*,*msys*) + case $file:$destfile in + *.exe:*.exe) + # this is ok +@@ -4535,7 +4535,7 @@ + $RM $export_symbols + eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in +- *cygwin* | *mingw* | *cegcc* ) ++ *cygwin* | *msys* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' + ;; +@@ -4547,7 +4547,7 @@ + eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + case $host in +- *cygwin* | *mingw* | *cegcc* ) ++ *cygwin* | *msys* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' + ;; +@@ -4561,7 +4561,7 @@ + func_basename "$dlprefile" + name=$func_basename_result + case $host in +- *cygwin* | *mingw* | *cegcc* ) ++ *cygwin* | *msys* | *mingw* | *cegcc* ) + # if an import library, we need to obtain dlname + if func_win32_import_lib_p "$dlprefile"; then + func_tr_sh "$dlprefile" +@@ -4736,7 +4736,7 @@ + # Transform the symbol file into the correct name. + symfileobj=$output_objdir/${my_outputname}S.$objext + case $host in +- *cygwin* | *mingw* | *cegcc* ) ++ *cygwin* | *msys* | *mingw* | *cegcc* ) + if test -f "$output_objdir/$my_outputname.def"; then + compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` +@@ -5629,7 +5629,7 @@ + { + EOF + case $host in +- *mingw* | *cygwin* ) ++ *mingw* | *cygwin* | *msys* ) + # make stdout use "unix" line endings + echo " setmode(1,_O_BINARY);" + ;; +@@ -6350,7 +6350,7 @@ + $debug_cmd + + case $host in +- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) ++ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # what system we are compiling for in order to pass an extra +@@ -6843,7 +6843,7 @@ + ;; + esac + case $host in +- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) ++ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$dir:"*) ;; +@@ -6863,7 +6863,7 @@ + -l*) + if test X-lc = "X$arg" || test X-lm = "X$arg"; then + case $host in +- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) ++ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) + # These systems don't actually have a C or math library (as such) + continue + ;; +@@ -6946,7 +6946,7 @@ + + -no-install) + case $host in +- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) ++ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) + # The PATH hackery in wrapper scripts is required on Windows + # and Darwin in order for the loader to find any dlls it needs. + func_warning "'-no-install' is ignored for $host" +@@ -7812,7 +7812,7 @@ + fi + case $host in + # special handling for platforms with PE-DLLs. +- *cygwin* | *mingw* | *cegcc* ) ++ *cygwin* | *msys* | *mingw* | *cegcc* ) + # Linker will automatically link against shared library if both + # static and shared are present. Therefore, ensure we extract + # symbols from the import library if a shared library is present +@@ -7956,7 +7956,7 @@ + if test -n "$library_names" && + { test no = "$use_static_libs" || test -z "$old_library"; }; then + case $host in +- *cygwin* | *mingw* | *cegcc* | *os2*) ++ *cygwin* | *msys* | *mingw* | *cegcc* | *os2*) + # No point in relinking DLLs because paths are not encoded + func_append notinst_deplibs " $lib" + need_relink=no +@@ -8026,7 +8026,7 @@ + elif test -n "$soname_spec"; then + # bleh windows + case $host in +- *cygwin* | mingw* | *cegcc* | *os2*) ++ *cygwin* | *msys* | mingw* | *cegcc* | *os2*) + func_arith $current - $age + major=$func_arith_result + versuffix=-$major +@@ -8899,7 +8899,7 @@ + if test yes = "$build_libtool_libs"; then + if test -n "$rpath"; then + case $host in +- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) ++ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) +@@ -9413,7 +9413,7 @@ + + orig_export_symbols= + case $host_os in +- cygwin* | mingw* | cegcc*) ++ cygwin* | *msys* | mingw* | cegcc*) + if test -n "$export_symbols" && test -z "$export_symbols_regex"; then + # exporting using user supplied symfile + func_dll_def_p "$export_symbols" || { +@@ -9970,7 +9970,7 @@ + + prog) + case $host in +- *cygwin*) func_stripname '' '.exe' "$output" ++ *cygwin* | *msys*) func_stripname '' '.exe' "$output" + output=$func_stripname_result.exe;; + esac + test -n "$vinfo" && \ +@@ -10081,7 +10081,7 @@ + esac + fi + case $host in +- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) ++ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$libdir:"*) ;; +@@ -10159,7 +10159,7 @@ + # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. + wrappers_required=false + ;; +- *cygwin* | *mingw* ) ++ *cygwin* | *msys* | *mingw* ) + test yes = "$build_libtool_libs" || wrappers_required=false + ;; + *) +@@ -10305,14 +10305,14 @@ + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in +- *cygwin*) ++ *cygwin* | *msys*) + exeext=.exe + func_stripname '' '.exe' "$outputname" + outputname=$func_stripname_result ;; + *) exeext= ;; + esac + case $host in +- *cygwin* | *mingw* ) ++ *cygwin* | *msys* | *mingw* ) + func_dirname_and_basename "$output" "" "." + output_name=$func_basename_result + output_path=$func_dirname_result +@@ -10644,7 +10644,7 @@ + # tests/bindir.at for full details. + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in +- *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) ++ *cygwin*,*lai,yes,no,*.dll | *msys*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) + # If a -bindir argument was supplied, place the dll there. + if test -n "$bindir"; then + func_relative_path "$install_libdir" "$bindir" +diff -Naur libtool-2.4.2.418-orig/m4/libtool.m4 libtool-2.4.2.418/m4/libtool.m4 +--- libtool-2.4.2.418-orig/m4/libtool.m4 2013-10-26 03:37:46.000000000 +0400 ++++ libtool-2.4.2.418/m4/libtool.m4 2014-09-02 10:19:40.084800000 +0400 +@@ -1665,7 +1665,7 @@ + lt_cv_sys_max_cmd_len=-1; + ;; + +- cygwin* | mingw* | cegcc*) ++ cygwin* | msys* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, +@@ -1913,7 +1913,7 @@ + lt_cv_dlopen_libs= + ;; + +- cygwin*) ++ cygwin* | msys*) + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + ;; +@@ -2399,7 +2399,7 @@ + # libtool to hard-code these into programs + ;; + +-cygwin* | mingw* | pw32* | cegcc*) ++cygwin* | msys* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=.dll + need_version=no +@@ -2431,6 +2431,12 @@ + m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) + ;; ++ msys*) ++ # MSYS DLLs use 'msys-' prefix rather than 'lib' ++ soname_spec='`echo $libname | sed -e 's/^lib/msys-/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ++m4_if([$1], [],[ ++ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ++ ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' +@@ -2465,7 +2471,7 @@ + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` + ;; +- cygwin*) ++ cygwin* | msys*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... +@@ -3203,7 +3209,7 @@ + esac + reload_cmds='$LD$reload_flag -o $output$reload_objs' + case $host_os in +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + if test yes != "$GCC"; then + reload_cmds=false + fi +@@ -3259,7 +3265,7 @@ + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +-cygwin*) ++cygwin* | msys*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' +@@ -3564,7 +3570,7 @@ + [lt_cv_sharedlib_from_linklib_cmd='unknown' + + case $host_os in +-cygwin* | mingw* | pw32* | cegcc*) ++cygwin* | msys* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in +@@ -3634,7 +3640,7 @@ + [AC_REQUIRE([AC_CANONICAL_HOST])dnl + LIBM= + case $host in +-*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) ++*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-msys* | *-*-haiku* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; + *-ncr-sysv4.3*) +@@ -3709,7 +3715,7 @@ + aix*) + symcode='[[BCDT]]' + ;; +-cygwin* | mingw* | pw32* | cegcc*) ++cygwin* | msys* | mingw* | pw32* | cegcc*) + symcode='[[ABCDGISTW]]' + ;; + hpux*) +@@ -4015,7 +4021,7 @@ + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; +- mingw* | cygwin* | os2* | pw32* | cegcc*) ++ mingw* | cygwin* | msys* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style +@@ -4086,7 +4092,7 @@ + ;; + esac + ;; +- mingw* | cygwin* | os2* | pw32* | cegcc*) ++ mingw* | cygwin* | msys* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], +@@ -4334,7 +4340,7 @@ + # PIC is the default for these OSes. + ;; + +- mingw* | cygwin* | pw32* | os2* | cegcc*) ++ mingw* | cygwin* | msys* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style +@@ -4433,7 +4439,7 @@ + esac + ;; + +- mingw* | cygwin* | pw32* | os2* | cegcc*) ++ mingw* | cygwin* | msys* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], +@@ -4699,7 +4705,7 @@ + pw32*) + _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds + ;; +- cygwin* | mingw* | cegcc*) ++ cygwin* | msys* | mingw* | cegcc*) + case $cc_basename in + cl*) + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' +@@ -4757,7 +4763,7 @@ + extract_expsyms_cmds= + + case $host_os in +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. +@@ -4872,7 +4878,7 @@ + fi + ;; + +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' +@@ -5247,7 +5253,7 @@ + _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is +@@ -6241,7 +6247,7 @@ + esac + ;; + +- cygwin* | mingw* | pw32* | cegcc*) ++ cygwin* | msys* | mingw* | pw32* | cegcc*) + case $GXX,$cc_basename in + ,cl* | no,cl*) + # Native MSVC +@@ -7937,7 +7943,7 @@ + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; +- *-*-cygwin* ) ++ *-*-cygwin* | *-*-msys* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix +@@ -7945,12 +7951,12 @@ + ;; + esac + ;; +- *-*-cygwin* ) ++ *-*-cygwin* | *-*-msys* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; +- *-*-cygwin* ) ++ *-*-cygwin* | *-*-msys* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix diff --git a/contrib/autotools-patches/0010-libtool-2.4.2-include-process-h-mod.patch b/contrib/autotools-patches/0010-libtool-2.4.2-include-process-h-mod.patch new file mode 100644 index 00000000..c1301a1a --- /dev/null +++ b/contrib/autotools-patches/0010-libtool-2.4.2-include-process-h-mod.patch @@ -0,0 +1,12 @@ +diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh +index 0418007..91276c2 100644 +--- a/build-aux/ltmain.sh ++++ b/build-aux/ltmain.sh +@@ -4163,6 +4163,7 @@ + # include + # include + # ifdef __CYGWIN__ ++# include + # include + # endif + #endif diff --git a/contrib/autotools-patches/0011-Pick-up-clang_rt-static-archives-compiler-internal-l.patch b/contrib/autotools-patches/0011-Pick-up-clang_rt-static-archives-compiler-internal-l.patch new file mode 100644 index 00000000..49cc0706 --- /dev/null +++ b/contrib/autotools-patches/0011-Pick-up-clang_rt-static-archives-compiler-internal-l.patch @@ -0,0 +1,33 @@ +From a18473ed4e5574dab899db640b8efeff78939b54 Mon Sep 17 00:00:00 2001 +From: Manoj Gupta +Date: Wed, 10 Oct 2018 10:50:23 +0300 +Subject: [PATCH 1/2] Pick up clang_rt static archives compiler internal + libraries + +Libtool checks only for libraries linked as -l* when trying to +find internal compiler libraries. Clang, however uses the absolute +path to link its internal libraries e.g. compiler_rt. This patch +handles clang's statically linked libraries when finding internal +compiler libraries. +https://crbug.com/749263 +https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27866 +--- + m4/libtool.m4 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/m4/libtool.m4 b/m4/libtool.m4 +index b55a6e5..d9322d0 100644 +--- a/m4/libtool.m4 ++++ b/m4/libtool.m4 +@@ -7556,7 +7556,7 @@ if AC_TRY_EVAL(ac_compile); then + for p in `eval "$output_verbose_link_cmd"`; do + case $prev$p in + +- -L* | -R* | -l*) ++ -L* | -R* | -l* | */libclang_rt.*.a) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test x-L = "$p" || +-- +2.7.4 + diff --git a/contrib/autotools-patches/0012-Prefer-response-files-over-linker-scripts-for-mingw-mod.patch b/contrib/autotools-patches/0012-Prefer-response-files-over-linker-scripts-for-mingw-mod.patch new file mode 100644 index 00000000..e0222b59 --- /dev/null +++ b/contrib/autotools-patches/0012-Prefer-response-files-over-linker-scripts-for-mingw-mod.patch @@ -0,0 +1,83 @@ +From ec15841963ca3aab3bc88fb0932c014337284bfc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Martin=20Storsj=C3=B6?= +Date: Wed, 10 Oct 2018 10:47:21 +0300 +Subject: [PATCH 2/2] Prefer response files over linker scripts for mingw tools + +The GCC/binutils tools support response files just fine, while +lld (impersonating GNU ld) only supports response files, not +linker scripts. Using a linker script as input just to pass a +list of files is overkill for cases when a response file is enough. +--- + build-aux/ltmain.in | 28 ++++++++++++++-------------- + m4/libtool.m4 | 2 ++ + 2 files changed, 16 insertions(+), 14 deletions(-) + +diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh +index e2fb263..db5d590 100644 +--- a/build-aux/ltmain.sh ++++ b/build-aux/ltmain.sh +@@ -7932,20 +7932,7 @@ EOF + last_robj= + k=1 + +- if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then +- output=$output_objdir/$output_la.lnkscript +- func_verbose "creating GNU ld script: $output" +- echo 'INPUT (' > $output +- for obj in $save_libobjs +- do +- func_to_tool_file "$obj" +- $ECHO "$func_to_tool_file_result" >> $output +- done +- echo ')' >> $output +- func_append delfiles " $output" +- func_to_tool_file "$output" +- output=$func_to_tool_file_result +- elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then ++ if test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then + output=$output_objdir/$output_la.lnk + func_verbose "creating linker input file list: $output" + : > $output +@@ -7964,6 +7951,19 @@ EOF + func_append delfiles " $output" + func_to_tool_file "$output" + output=$firstobj\"$file_list_spec$func_to_tool_file_result\" ++ elif test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then ++ output=$output_objdir/$output_la.lnkscript ++ func_verbose "creating GNU ld script: $output" ++ echo 'INPUT (' > $output ++ for obj in $save_libobjs ++ do ++ func_to_tool_file "$obj" ++ $ECHO "$func_to_tool_file_result" >> $output ++ done ++ echo ')' >> $output ++ func_append delfiles " $output" ++ func_to_tool_file "$output" ++ output=$func_to_tool_file_result + else + if test -n "$save_libobjs"; then + func_verbose "creating reloadable object files..." +diff --git a/m4/libtool.m4 b/m4/libtool.m4 +index d9322d0..9046a84 100644 +--- a/m4/libtool.m4 ++++ b/m4/libtool.m4 +@@ -5130,6 +5130,7 @@ _LT_EOF + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ++ _LT_TAGVAR(file_list_spec, $1)='@' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' +@@ -6706,6 +6707,7 @@ if test yes != "$_lt_caught_CXX_error"; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ++ _LT_TAGVAR(file_list_spec, $1)='@' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' +-- +2.7.4 + diff --git a/contrib/autotools-patches/0013-Allow-statically-linking-compiler-support-libraries-mod.patch b/contrib/autotools-patches/0013-Allow-statically-linking-compiler-support-libraries-mod.patch new file mode 100644 index 00000000..0ae0415f --- /dev/null +++ b/contrib/autotools-patches/0013-Allow-statically-linking-compiler-support-libraries-mod.patch @@ -0,0 +1,38 @@ +From b9f77cae8cfbe850e58cac686fcb4d246b5bfc51 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Martin=20Storsj=C3=B6?= +Date: Mon, 19 Aug 2019 13:34:51 +0300 +Subject: [PATCH] Allow statically linking compiler support libraries when + linking a library + +For cases with deplibs_check_method="file_magic ..." (as it is for mingw), +there were previously no way that a static library could be accepted +here. +--- + build-aux/ltmain.in | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh +index e2fb2633..db4d775c 100644 +--- a/build-aux/ltmain.sh ++++ b/build-aux/ltmain.sh +@@ -5870,8 +5870,15 @@ func_mode_link () + fi + case $linkmode in + lib) +- # Linking convenience modules into shared libraries is allowed, +- # but linking other static libraries is non-portable. ++ # Linking convenience modules and compiler provided static libraries ++ # into shared libraries is allowed, but linking other static ++ # libraries is non-portable. ++ case $deplib in ++ */libgcc*.$libext | */libclang_rt*.$libext) ++ deplibs="$deplib $deplibs" ++ continue ++ ;; ++ esac + case " $dlpreconveniencelibs " in + *" $deplib "*) ;; + *) +-- +2.17.1 + diff --git a/contrib/autotools-patches/0014-Support-llvm-objdump-f-output-mod.patch b/contrib/autotools-patches/0014-Support-llvm-objdump-f-output-mod.patch new file mode 100644 index 00000000..0a1be0ec --- /dev/null +++ b/contrib/autotools-patches/0014-Support-llvm-objdump-f-output-mod.patch @@ -0,0 +1,39 @@ +From 03dabb6a70847761e65572a2a7b770a3b1b9f123 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= +Date: Mon, 12 Apr 2021 23:44:10 +0200 +Subject: [PATCH] Support llvm-objdump -f output + +--- + build-aux/ltmain.in | 2 +- + m4/libtool.m4 | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh +index a9f070a..4a434cc 100644 +--- a/build-aux/ltmain.sh ++++ b/build-aux/ltmain.sh +@@ -3019,7 +3019,7 @@ func_win32_libid () + *ar\ archive*) # could be an import, or static + # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | +- $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then ++ $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|coff-arm|coff-arm64|coff-i386|coff-x86-64)' >/dev/null; then + case $nm_interface in + "MS dumpbin") + if func_cygming_ms_implib_p "$1" || +diff --git a/m4/libtool.m4 b/m4/libtool.m4 +index 21a7d60..594be9c 100644 +--- a/m4/libtool.m4 ++++ b/m4/libtool.m4 +@@ -3473,7 +3473,7 @@ mingw* | pw32*) + lt_cv_file_magic_cmd='func_win32_libid' + else + # Keep this pattern in sync with the one in func_win32_libid. +- lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' ++ lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|coff-arm|coff-arm64|coff-i386|coff-x86-64)' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; +-- +2.31.1 + diff --git a/contrib/autotools-patches/apply-all.sh b/contrib/autotools-patches/apply-all.sh new file mode 100755 index 00000000..0febcd2d --- /dev/null +++ b/contrib/autotools-patches/apply-all.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# +# This file applies optional libtool patches mainly for better MSys2 compatibility, +# especially for MSys2/Clang{64,32} toolchains. +# It's a pity that these patches haven't been sent upstream. +# +# Based on Debian SID baseline files as of December 2021. +# + +patchesdir="$(pwd)" + +patches=( + 0003-Pass-various-flags-to-GCC.patch + 0006-Fix-strict-ansi-vs-posix-mod.patch + 0009-libtool-2.4.2.418-msysize-mod.patch + 0010-libtool-2.4.2-include-process-h-mod.patch + 0011-Pick-up-clang_rt-static-archives-compiler-internal-l.patch + 0012-Prefer-response-files-over-linker-scripts-for-mingw-mod.patch + 0013-Allow-statically-linking-compiler-support-libraries-mod.patch + 0014-Support-llvm-objdump-f-output-mod.patch +) + +failed=( ) + +cd ../.. || exit 1 + +for patch in ${patches[@]}; do + patch -N -p1 --no-backup-if-mismatch -r - -i "${patchesdir}/${patch}" || failed+=("$patch") +done + +[[ -n "${failed[@]}" ]] && printf 'Failed patch: %s\n' "${failed[@]}" >&2 + -- cgit v1.2.3