aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorEvgeny Grin <k2k@narod.ru>2021-12-16 16:01:38 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-12-16 16:04:48 +0300
commitb3b6c570dac24d6bfd39c4c72e2d52ecf491fcf5 (patch)
tree6f98fa21e9a025237120bb322d52db0ab3a0405c /contrib
parentfeb04e725cc6a87f0beb3abebb44789830a86a6b (diff)
downloadlibmicrohttpd-b3b6c570dac24d6bfd39c4c72e2d52ecf491fcf5.tar.gz
libmicrohttpd-b3b6c570dac24d6bfd39c4c72e2d52ecf491fcf5.zip
Added local patches for autotools (mainly for libtool)
Patches required mostly for MSys2 toolchains, especially for MSys2/Clang{64,32} toolchains.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/autotools-patches/0003-Pass-various-flags-to-GCC.patch20
-rw-r--r--contrib/autotools-patches/0003-Pass-various-runtime-library-flags-to-GCC.mingw-mod.patch30
-rw-r--r--contrib/autotools-patches/0006-Fix-strict-ansi-vs-posix-mod.patch22
-rw-r--r--contrib/autotools-patches/0009-libtool-2.4.2.418-msysize-mod.patch443
-rw-r--r--contrib/autotools-patches/0010-libtool-2.4.2-include-process-h-mod.patch12
-rw-r--r--contrib/autotools-patches/0011-Pick-up-clang_rt-static-archives-compiler-internal-l.patch33
-rw-r--r--contrib/autotools-patches/0012-Prefer-response-files-over-linker-scripts-for-mingw-mod.patch83
-rw-r--r--contrib/autotools-patches/0013-Allow-statically-linking-compiler-support-libraries-mod.patch38
-rw-r--r--contrib/autotools-patches/0014-Support-llvm-objdump-f-output-mod.patch39
-rwxr-xr-xcontrib/autotools-patches/apply-all.sh33
10 files changed, 753 insertions, 0 deletions
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 @@
1diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh
2index 21e5e078..ddd6e36f 100755
3--- a/build-aux/ltmain.sh
4+++ b/build-aux/ltmain.sh
5@@ -7369,11 +7369,14 @@ func_mode_link ()
6 # -fsanitize=* Clang/GCC memory and address sanitizer
7 # -fuse-ld=* Linker select flags for GCC
8 # -static-* direct GCC to link specific libraries statically
9+ # -shared-* direct GCC to link shared version of specific libraries
10 # -fcilkplus Cilk Plus language extension features for C/C++
11 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
12 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
13 -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
14- -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus)
15+ -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-shared-*|-fcilkplus| \
16+ -ftree-parallelize-loops=*|-fgnu-tm|-ffast-math| \
17+ -funsafe-math-optimizations|-fvtable-verify*)
18 func_quote_for_eval "$arg"
19 arg=$func_quote_for_eval_result
20 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 @@
1[PATCH 3/6] Pass various runtime library flags to GCC.
2* build-aux/ltmain.in (func_mode_link): Pass the
3-shared-libgcc and -static-lib* flags along to GCC.
4---
5 build-aux/ltmain.sh | 5 ++++-
6 1 files changed, 4 insertions(+), 1 deletions(-)
7
8diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh
9index 1821779..eda7790 100644
10--- a/build-aux/ltmain.sh
11+++ b/build-aux/ltmain.sh
12@@ -5084,9 +5084,14 @@ func_mode_link ()
13 # --sysroot=* for sysroot support
14 # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
15 # -stdlib=* select c++ std lib with clang
16+ # -{shared,static}-libgcc, -static-{libgfortran|libstdc++}
17+ # link against specified runtime library
18 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
19 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
20- -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
21+ -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
22+ -ftree-parallelize-loops=*|-fcilkplus|-fgnu-tm|-ffast-math| \
23+ -funsafe-math-optimizations|-fvtable-verify*| \
24+ -shared-libgcc|-static-libgcc|-static-libgfortran|-static-libstdc++)
25 func_quote_for_eval "$arg"
26 arg=$func_quote_for_eval_result
27 func_append compile_command " $arg"
28--
291.7.1
30
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 @@
1[PATCH 6/6] Fix STRICT_ANSI vs POSIX
2* build-aux/ltmain.in (func_mode_link): Also check for _POSIX
3as well as __STRICT_ANSI__ to avoid re-definitions.
4---
5 build-aux/ltmain.sh | 4 +++-
6 1 files changed, 1 insertions(+), 1 deletions(-)
7
8diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh
9index af46cb8..244bb5b 100644
10--- a/build-aux/ltmain.sh
11+++ b/build-aux/ltmain.sh
12@@ -3382,7 +3382,7 @@
13
14 /* declarations of non-ANSI functions */
15 #if defined __MINGW32__
16-# ifdef __STRICT_ANSI__
17+# if defined(__STRICT_ANSI__) && !defined(__MINGW64_VERSION_MAJOR) || defined(_POSIX_)
18 int _putenv (const char *);
19 # endif
20 #elif defined __CYGWIN__
21--
221.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 @@
1diff --git a/build-aux/config.guess b/build-aux/config.guess
2index f50dcdb6..cd89e459 100755
3--- a/build-aux/config.guess
4+++ b/build-aux/config.guess
5@@ -883,6 +883,9 @@ EOF
6 amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
7 echo x86_64-unknown-cygwin
8 exit ;;
9+ amd64:MSYS*:*:* | x86_64:MSYS*:*:*)
10+ echo x86_64-unknown-msys
11+ exit ;;
12 prep*:SunOS:5.*:*)
13 echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
14 exit ;;
15diff -Naur libtool-2.4.2.418-orig/build-aux/ltmain.sh libtool-2.4.2.418/build-aux/ltmain.sh
16--- libtool-2.4.2.418-orig/build-aux/ltmain.sh 2013-10-27 02:53:58.000000000 +0400
17+++ libtool-2.4.2.418/build-aux/ltmain.sh 2014-09-02 10:29:08.840800000 +0400
18@@ -2315,7 +2315,7 @@
19 case $host in
20 # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
21 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
22- *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
23+ *cygwin* | *msys* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
24 # don't eliminate duplications in $postdeps and $predeps
25 opt_duplicate_compiler_generated_deps=:
26 ;;
27@@ -3328,7 +3328,7 @@
28
29 # On Cygwin there's no "real" PIC flag so we must build both object types
30 case $host_os in
31- cygwin* | mingw* | pw32* | os2* | cegcc*)
32+ cygwin* | msys* | mingw* | pw32* | os2* | cegcc*)
33 pic_mode=default
34 ;;
35 esac
36@@ -4201,7 +4201,7 @@
37 'exit $?'
38 tstripme=$stripme
39 case $host_os in
40- cygwin* | mingw* | pw32* | cegcc*)
41+ cygwin* | msys* | mingw* | pw32* | cegcc*)
42 case $realname in
43 *.dll.a)
44 tstripme=
45@@ -4307,7 +4307,7 @@
46
47 # Do a test to see if this is really a libtool program.
48 case $host in
49- *cygwin* | *mingw*)
50+ *cygwin* | *msys* | *mingw*)
51 if func_ltwrapper_executable_p "$file"; then
52 func_ltwrapper_scriptname "$file"
53 wrapper=$func_ltwrapper_scriptname_result
54@@ -4382,7 +4382,7 @@
55 # remove .exe since cygwin /usr/bin/install will append another
56 # one anyway
57 case $install_prog,$host in
58- */usr/bin/install*,*cygwin*)
59+ */usr/bin/install*,*cygwin* | */usr/bin/install*,*msys*)
60 case $file:$destfile in
61 *.exe:*.exe)
62 # this is ok
63@@ -4535,7 +4535,7 @@
64 $RM $export_symbols
65 eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
66 case $host in
67- *cygwin* | *mingw* | *cegcc* )
68+ *cygwin* | *msys* | *mingw* | *cegcc* )
69 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
70 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
71 ;;
72@@ -4547,7 +4547,7 @@
73 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
74 eval '$MV "$nlist"T "$nlist"'
75 case $host in
76- *cygwin* | *mingw* | *cegcc* )
77+ *cygwin* | *msys* | *mingw* | *cegcc* )
78 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
79 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
80 ;;
81@@ -4561,7 +4561,7 @@
82 func_basename "$dlprefile"
83 name=$func_basename_result
84 case $host in
85- *cygwin* | *mingw* | *cegcc* )
86+ *cygwin* | *msys* | *mingw* | *cegcc* )
87 # if an import library, we need to obtain dlname
88 if func_win32_import_lib_p "$dlprefile"; then
89 func_tr_sh "$dlprefile"
90@@ -4736,7 +4736,7 @@
91 # Transform the symbol file into the correct name.
92 symfileobj=$output_objdir/${my_outputname}S.$objext
93 case $host in
94- *cygwin* | *mingw* | *cegcc* )
95+ *cygwin* | *msys* | *mingw* | *cegcc* )
96 if test -f "$output_objdir/$my_outputname.def"; then
97 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
98 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
99@@ -5629,7 +5629,7 @@
100 {
101 EOF
102 case $host in
103- *mingw* | *cygwin* )
104+ *mingw* | *cygwin* | *msys* )
105 # make stdout use "unix" line endings
106 echo " setmode(1,_O_BINARY);"
107 ;;
108@@ -6350,7 +6350,7 @@
109 $debug_cmd
110
111 case $host in
112- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
113+ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
114 # It is impossible to link a dll without this setting, and
115 # we shouldn't force the makefile maintainer to figure out
116 # what system we are compiling for in order to pass an extra
117@@ -6843,7 +6843,7 @@
118 ;;
119 esac
120 case $host in
121- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
122+ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
123 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
124 case :$dllsearchpath: in
125 *":$dir:"*) ;;
126@@ -6863,7 +6863,7 @@
127 -l*)
128 if test X-lc = "X$arg" || test X-lm = "X$arg"; then
129 case $host in
130- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
131+ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
132 # These systems don't actually have a C or math library (as such)
133 continue
134 ;;
135@@ -6946,7 +6946,7 @@
136
137 -no-install)
138 case $host in
139- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
140+ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
141 # The PATH hackery in wrapper scripts is required on Windows
142 # and Darwin in order for the loader to find any dlls it needs.
143 func_warning "'-no-install' is ignored for $host"
144@@ -7812,7 +7812,7 @@
145 fi
146 case $host in
147 # special handling for platforms with PE-DLLs.
148- *cygwin* | *mingw* | *cegcc* )
149+ *cygwin* | *msys* | *mingw* | *cegcc* )
150 # Linker will automatically link against shared library if both
151 # static and shared are present. Therefore, ensure we extract
152 # symbols from the import library if a shared library is present
153@@ -7956,7 +7956,7 @@
154 if test -n "$library_names" &&
155 { test no = "$use_static_libs" || test -z "$old_library"; }; then
156 case $host in
157- *cygwin* | *mingw* | *cegcc* | *os2*)
158+ *cygwin* | *msys* | *mingw* | *cegcc* | *os2*)
159 # No point in relinking DLLs because paths are not encoded
160 func_append notinst_deplibs " $lib"
161 need_relink=no
162@@ -8026,7 +8026,7 @@
163 elif test -n "$soname_spec"; then
164 # bleh windows
165 case $host in
166- *cygwin* | mingw* | *cegcc* | *os2*)
167+ *cygwin* | *msys* | mingw* | *cegcc* | *os2*)
168 func_arith $current - $age
169 major=$func_arith_result
170 versuffix=-$major
171@@ -8899,7 +8899,7 @@
172 if test yes = "$build_libtool_libs"; then
173 if test -n "$rpath"; then
174 case $host in
175- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
176+ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
177 # these systems don't actually have a c library (as such)!
178 ;;
179 *-*-rhapsody* | *-*-darwin1.[012])
180@@ -9413,7 +9413,7 @@
181
182 orig_export_symbols=
183 case $host_os in
184- cygwin* | mingw* | cegcc*)
185+ cygwin* | *msys* | mingw* | cegcc*)
186 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
187 # exporting using user supplied symfile
188 func_dll_def_p "$export_symbols" || {
189@@ -9970,7 +9970,7 @@
190
191 prog)
192 case $host in
193- *cygwin*) func_stripname '' '.exe' "$output"
194+ *cygwin* | *msys*) func_stripname '' '.exe' "$output"
195 output=$func_stripname_result.exe;;
196 esac
197 test -n "$vinfo" && \
198@@ -10081,7 +10081,7 @@
199 esac
200 fi
201 case $host in
202- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
203+ *-*-cygwin* | *-*-msys* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
204 testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
205 case :$dllsearchpath: in
206 *":$libdir:"*) ;;
207@@ -10159,7 +10159,7 @@
208 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
209 wrappers_required=false
210 ;;
211- *cygwin* | *mingw* )
212+ *cygwin* | *msys* | *mingw* )
213 test yes = "$build_libtool_libs" || wrappers_required=false
214 ;;
215 *)
216@@ -10305,14 +10305,14 @@
217 esac
218 # test for cygwin because mv fails w/o .exe extensions
219 case $host in
220- *cygwin*)
221+ *cygwin* | *msys*)
222 exeext=.exe
223 func_stripname '' '.exe' "$outputname"
224 outputname=$func_stripname_result ;;
225 *) exeext= ;;
226 esac
227 case $host in
228- *cygwin* | *mingw* )
229+ *cygwin* | *msys* | *mingw* )
230 func_dirname_and_basename "$output" "" "."
231 output_name=$func_basename_result
232 output_path=$func_dirname_result
233@@ -10644,7 +10644,7 @@
234 # tests/bindir.at for full details.
235 tdlname=$dlname
236 case $host,$output,$installed,$module,$dlname in
237- *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
238+ *cygwin*,*lai,yes,no,*.dll | *msys*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
239 # If a -bindir argument was supplied, place the dll there.
240 if test -n "$bindir"; then
241 func_relative_path "$install_libdir" "$bindir"
242diff -Naur libtool-2.4.2.418-orig/m4/libtool.m4 libtool-2.4.2.418/m4/libtool.m4
243--- libtool-2.4.2.418-orig/m4/libtool.m4 2013-10-26 03:37:46.000000000 +0400
244+++ libtool-2.4.2.418/m4/libtool.m4 2014-09-02 10:19:40.084800000 +0400
245@@ -1665,7 +1665,7 @@
246 lt_cv_sys_max_cmd_len=-1;
247 ;;
248
249- cygwin* | mingw* | cegcc*)
250+ cygwin* | msys* | mingw* | cegcc*)
251 # On Win9x/ME, this test blows up -- it succeeds, but takes
252 # about 5 minutes as the teststring grows exponentially.
253 # Worse, since 9x/ME are not pre-emptively multitasking,
254@@ -1913,7 +1913,7 @@
255 lt_cv_dlopen_libs=
256 ;;
257
258- cygwin*)
259+ cygwin* | msys*)
260 lt_cv_dlopen=dlopen
261 lt_cv_dlopen_libs=
262 ;;
263@@ -2399,7 +2399,7 @@
264 # libtool to hard-code these into programs
265 ;;
266
267-cygwin* | mingw* | pw32* | cegcc*)
268+cygwin* | msys* | mingw* | pw32* | cegcc*)
269 version_type=windows
270 shrext_cmds=.dll
271 need_version=no
272@@ -2431,6 +2431,12 @@
273 m4_if([$1], [],[
274 sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
275 ;;
276+ msys*)
277+ # MSYS DLLs use 'msys-' prefix rather than 'lib'
278+ soname_spec='`echo $libname | sed -e 's/^lib/msys-/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
279+m4_if([$1], [],[
280+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
281+ ;;
282 mingw* | cegcc*)
283 # MinGW DLLs use traditional 'lib' prefix
284 soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
285@@ -2465,7 +2471,7 @@
286 # Convert to MSYS style.
287 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
288 ;;
289- cygwin*)
290+ cygwin* | msys*)
291 # Convert to unix form, then to dos form, then back to unix form
292 # but this time dos style (no spaces!) so that the unix form looks
293 # like /cygdrive/c/PROGRA~1:/cygdr...
294@@ -3203,7 +3209,7 @@
295 esac
296 reload_cmds='$LD$reload_flag -o $output$reload_objs'
297 case $host_os in
298- cygwin* | mingw* | pw32* | cegcc*)
299+ cygwin* | msys* | mingw* | pw32* | cegcc*)
300 if test yes != "$GCC"; then
301 reload_cmds=false
302 fi
303@@ -3259,7 +3265,7 @@
304 lt_cv_file_magic_test_file=/shlib/libc.so
305 ;;
306
307-cygwin*)
308+cygwin* | msys*)
309 # func_win32_libid is a shell function defined in ltmain.sh
310 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
311 lt_cv_file_magic_cmd='func_win32_libid'
312@@ -3564,7 +3570,7 @@
313 [lt_cv_sharedlib_from_linklib_cmd='unknown'
314
315 case $host_os in
316-cygwin* | mingw* | pw32* | cegcc*)
317+cygwin* | msys* | mingw* | pw32* | cegcc*)
318 # two different shell functions defined in ltmain.sh;
319 # decide which one to use based on capabilities of $DLLTOOL
320 case `$DLLTOOL --help 2>&1` in
321@@ -3634,7 +3640,7 @@
322 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
323 LIBM=
324 case $host in
325-*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
326+*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-msys* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
327 # These system don't have libm, or don't need it
328 ;;
329 *-ncr-sysv4.3*)
330@@ -3709,7 +3715,7 @@
331 aix*)
332 symcode='[[BCDT]]'
333 ;;
334-cygwin* | mingw* | pw32* | cegcc*)
335+cygwin* | msys* | mingw* | pw32* | cegcc*)
336 symcode='[[ABCDGISTW]]'
337 ;;
338 hpux*)
339@@ -4015,7 +4021,7 @@
340 beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
341 # PIC is the default for these OSes.
342 ;;
343- mingw* | cygwin* | os2* | pw32* | cegcc*)
344+ mingw* | cygwin* | msys* | os2* | pw32* | cegcc*)
345 # This hack is so that the source file can tell whether it is being
346 # built for inclusion in a dll (and should export symbols for example).
347 # Although the cygwin gcc ignores -fPIC, still need this for old-style
348@@ -4086,7 +4092,7 @@
349 ;;
350 esac
351 ;;
352- mingw* | cygwin* | os2* | pw32* | cegcc*)
353+ mingw* | cygwin* | msys* | os2* | pw32* | cegcc*)
354 # This hack is so that the source file can tell whether it is being
355 # built for inclusion in a dll (and should export symbols for example).
356 m4_if([$1], [GCJ], [],
357@@ -4334,7 +4340,7 @@
358 # PIC is the default for these OSes.
359 ;;
360
361- mingw* | cygwin* | pw32* | os2* | cegcc*)
362+ mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
363 # This hack is so that the source file can tell whether it is being
364 # built for inclusion in a dll (and should export symbols for example).
365 # Although the cygwin gcc ignores -fPIC, still need this for old-style
366@@ -4433,7 +4439,7 @@
367 esac
368 ;;
369
370- mingw* | cygwin* | pw32* | os2* | cegcc*)
371+ mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
372 # This hack is so that the source file can tell whether it is being
373 # built for inclusion in a dll (and should export symbols for example).
374 m4_if([$1], [GCJ], [],
375@@ -4699,7 +4705,7 @@
376 pw32*)
377 _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds
378 ;;
379- cygwin* | mingw* | cegcc*)
380+ cygwin* | msys* | mingw* | cegcc*)
381 case $cc_basename in
382 cl*)
383 _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
384@@ -4757,7 +4763,7 @@
385 extract_expsyms_cmds=
386
387 case $host_os in
388- cygwin* | mingw* | pw32* | cegcc*)
389+ cygwin* | msys* | mingw* | pw32* | cegcc*)
390 # FIXME: the MSVC++ port hasn't been tested in a loooong time
391 # When not using gcc, we currently assume that we are using
392 # Microsoft Visual C++.
393@@ -4872,7 +4878,7 @@
394 fi
395 ;;
396
397- cygwin* | mingw* | pw32* | cegcc*)
398+ cygwin* | msys* | mingw* | pw32* | cegcc*)
399 # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
400 # as there is no search path for DLLs.
401 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
402@@ -5247,7 +5253,7 @@
403 _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
404 ;;
405
406- cygwin* | mingw* | pw32* | cegcc*)
407+ cygwin* | msys* | mingw* | pw32* | cegcc*)
408 # When not using gcc, we currently assume that we are using
409 # Microsoft Visual C++.
410 # hardcode_libdir_flag_spec is actually meaningless, as there is
411@@ -6241,7 +6247,7 @@
412 esac
413 ;;
414
415- cygwin* | mingw* | pw32* | cegcc*)
416+ cygwin* | msys* | mingw* | pw32* | cegcc*)
417 case $GXX,$cc_basename in
418 ,cl* | no,cl*)
419 # Native MSVC
420@@ -7937,7 +7943,7 @@
421 *-*-mingw* ) # actually msys
422 lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
423 ;;
424- *-*-cygwin* )
425+ *-*-cygwin* | *-*-msys* )
426 lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
427 ;;
428 * ) # otherwise, assume *nix
429@@ -7945,12 +7951,12 @@
430 ;;
431 esac
432 ;;
433- *-*-cygwin* )
434+ *-*-cygwin* | *-*-msys* )
435 case $build in
436 *-*-mingw* ) # actually msys
437 lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
438 ;;
439- *-*-cygwin* )
440+ *-*-cygwin* | *-*-msys* )
441 lt_cv_to_host_file_cmd=func_convert_file_noop
442 ;;
443 * ) # 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 @@
1diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh
2index 0418007..91276c2 100644
3--- a/build-aux/ltmain.sh
4+++ b/build-aux/ltmain.sh
5@@ -4163,6 +4163,7 @@
6 # include <unistd.h>
7 # include <stdint.h>
8 # ifdef __CYGWIN__
9+# include <process.h>
10 # include <io.h>
11 # endif
12 #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 @@
1From a18473ed4e5574dab899db640b8efeff78939b54 Mon Sep 17 00:00:00 2001
2From: Manoj Gupta <manojgupta@chromium.org>
3Date: Wed, 10 Oct 2018 10:50:23 +0300
4Subject: [PATCH 1/2] Pick up clang_rt static archives compiler internal
5 libraries
6
7Libtool checks only for libraries linked as -l* when trying to
8find internal compiler libraries. Clang, however uses the absolute
9path to link its internal libraries e.g. compiler_rt. This patch
10handles clang's statically linked libraries when finding internal
11compiler libraries.
12https://crbug.com/749263
13https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27866
14---
15 m4/libtool.m4 | 2 +-
16 1 file changed, 1 insertion(+), 1 deletion(-)
17
18diff --git a/m4/libtool.m4 b/m4/libtool.m4
19index b55a6e5..d9322d0 100644
20--- a/m4/libtool.m4
21+++ b/m4/libtool.m4
22@@ -7556,7 +7556,7 @@ if AC_TRY_EVAL(ac_compile); then
23 for p in `eval "$output_verbose_link_cmd"`; do
24 case $prev$p in
25
26- -L* | -R* | -l*)
27+ -L* | -R* | -l* | */libclang_rt.*.a)
28 # Some compilers place space between "-{L,R}" and the path.
29 # Remove the space.
30 if test x-L = "$p" ||
31--
322.7.4
33
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 @@
1From ec15841963ca3aab3bc88fb0932c014337284bfc Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
3Date: Wed, 10 Oct 2018 10:47:21 +0300
4Subject: [PATCH 2/2] Prefer response files over linker scripts for mingw tools
5
6The GCC/binutils tools support response files just fine, while
7lld (impersonating GNU ld) only supports response files, not
8linker scripts. Using a linker script as input just to pass a
9list of files is overkill for cases when a response file is enough.
10---
11 build-aux/ltmain.in | 28 ++++++++++++++--------------
12 m4/libtool.m4 | 2 ++
13 2 files changed, 16 insertions(+), 14 deletions(-)
14
15diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh
16index e2fb263..db5d590 100644
17--- a/build-aux/ltmain.sh
18+++ b/build-aux/ltmain.sh
19@@ -7932,20 +7932,7 @@ EOF
20 last_robj=
21 k=1
22
23- if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
24- output=$output_objdir/$output_la.lnkscript
25- func_verbose "creating GNU ld script: $output"
26- echo 'INPUT (' > $output
27- for obj in $save_libobjs
28- do
29- func_to_tool_file "$obj"
30- $ECHO "$func_to_tool_file_result" >> $output
31- done
32- echo ')' >> $output
33- func_append delfiles " $output"
34- func_to_tool_file "$output"
35- output=$func_to_tool_file_result
36- elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
37+ if test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
38 output=$output_objdir/$output_la.lnk
39 func_verbose "creating linker input file list: $output"
40 : > $output
41@@ -7964,6 +7951,19 @@ EOF
42 func_append delfiles " $output"
43 func_to_tool_file "$output"
44 output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
45+ elif test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
46+ output=$output_objdir/$output_la.lnkscript
47+ func_verbose "creating GNU ld script: $output"
48+ echo 'INPUT (' > $output
49+ for obj in $save_libobjs
50+ do
51+ func_to_tool_file "$obj"
52+ $ECHO "$func_to_tool_file_result" >> $output
53+ done
54+ echo ')' >> $output
55+ func_append delfiles " $output"
56+ func_to_tool_file "$output"
57+ output=$func_to_tool_file_result
58 else
59 if test -n "$save_libobjs"; then
60 func_verbose "creating reloadable object files..."
61diff --git a/m4/libtool.m4 b/m4/libtool.m4
62index d9322d0..9046a84 100644
63--- a/m4/libtool.m4
64+++ b/m4/libtool.m4
65@@ -5130,6 +5130,7 @@ _LT_EOF
66 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
67 _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'
68 _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
69+ _LT_TAGVAR(file_list_spec, $1)='@'
70
71 if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
72 _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'
73@@ -6706,6 +6707,7 @@ if test yes != "$_lt_caught_CXX_error"; then
74 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
75 _LT_TAGVAR(always_export_symbols, $1)=no
76 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
77+ _LT_TAGVAR(file_list_spec, $1)='@'
78
79 if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
80 _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'
81--
822.7.4
83
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 @@
1From b9f77cae8cfbe850e58cac686fcb4d246b5bfc51 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
3Date: Mon, 19 Aug 2019 13:34:51 +0300
4Subject: [PATCH] Allow statically linking compiler support libraries when
5 linking a library
6
7For cases with deplibs_check_method="file_magic ..." (as it is for mingw),
8there were previously no way that a static library could be accepted
9here.
10---
11 build-aux/ltmain.in | 11 +++++++++--
12 1 file changed, 9 insertions(+), 2 deletions(-)
13
14diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh
15index e2fb2633..db4d775c 100644
16--- a/build-aux/ltmain.sh
17+++ b/build-aux/ltmain.sh
18@@ -5870,8 +5870,15 @@ func_mode_link ()
19 fi
20 case $linkmode in
21 lib)
22- # Linking convenience modules into shared libraries is allowed,
23- # but linking other static libraries is non-portable.
24+ # Linking convenience modules and compiler provided static libraries
25+ # into shared libraries is allowed, but linking other static
26+ # libraries is non-portable.
27+ case $deplib in
28+ */libgcc*.$libext | */libclang_rt*.$libext)
29+ deplibs="$deplib $deplibs"
30+ continue
31+ ;;
32+ esac
33 case " $dlpreconveniencelibs " in
34 *" $deplib "*) ;;
35 *)
36--
372.17.1
38
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 @@
1From 03dabb6a70847761e65572a2a7b770a3b1b9f123 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= <mati865@gmail.com>
3Date: Mon, 12 Apr 2021 23:44:10 +0200
4Subject: [PATCH] Support llvm-objdump -f output
5
6---
7 build-aux/ltmain.in | 2 +-
8 m4/libtool.m4 | 2 +-
9 2 files changed, 2 insertions(+), 2 deletions(-)
10
11diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh
12index a9f070a..4a434cc 100644
13--- a/build-aux/ltmain.sh
14+++ b/build-aux/ltmain.sh
15@@ -3019,7 +3019,7 @@ func_win32_libid ()
16 *ar\ archive*) # could be an import, or static
17 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
18 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
19- $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
20+ $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
21 case $nm_interface in
22 "MS dumpbin")
23 if func_cygming_ms_implib_p "$1" ||
24diff --git a/m4/libtool.m4 b/m4/libtool.m4
25index 21a7d60..594be9c 100644
26--- a/m4/libtool.m4
27+++ b/m4/libtool.m4
28@@ -3473,7 +3473,7 @@ mingw* | pw32*)
29 lt_cv_file_magic_cmd='func_win32_libid'
30 else
31 # Keep this pattern in sync with the one in func_win32_libid.
32- lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
33+ 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)'
34 lt_cv_file_magic_cmd='$OBJDUMP -f'
35 fi
36 ;;
37--
382.31.1
39
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 @@
1#!/bin/bash
2
3#
4# This file applies optional libtool patches mainly for better MSys2 compatibility,
5# especially for MSys2/Clang{64,32} toolchains.
6# It's a pity that these patches haven't been sent upstream.
7#
8# Based on Debian SID baseline files as of December 2021.
9#
10
11patchesdir="$(pwd)"
12
13patches=(
14 0003-Pass-various-flags-to-GCC.patch
15 0006-Fix-strict-ansi-vs-posix-mod.patch
16 0009-libtool-2.4.2.418-msysize-mod.patch
17 0010-libtool-2.4.2-include-process-h-mod.patch
18 0011-Pick-up-clang_rt-static-archives-compiler-internal-l.patch
19 0012-Prefer-response-files-over-linker-scripts-for-mingw-mod.patch
20 0013-Allow-statically-linking-compiler-support-libraries-mod.patch
21 0014-Support-llvm-objdump-f-output-mod.patch
22)
23
24failed=( )
25
26cd ../.. || exit 1
27
28for patch in ${patches[@]}; do
29 patch -N -p1 --no-backup-if-mismatch -r - -i "${patchesdir}/${patch}" || failed+=("$patch")
30done
31
32[[ -n "${failed[@]}" ]] && printf 'Failed patch: %s\n' "${failed[@]}" >&2
33