generated from gnu-ci-templates/ci-check
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3cc00ec
commit 7f37076
Showing
3 changed files
with
153 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
152 changes: 152 additions & 0 deletions
152
patches/0001-libtool-Fix-mishandling-compiler-flags-with-MSVC-too.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
From 583bc7bb5077646fe795bb66a2b339ddb21e0c40 Mon Sep 17 00:00:00 2001 | ||
From: Ileana Dumitrescu <ileanadumitrescu95@gmail.com> | ||
Date: Tue, 7 Jan 2025 19:34:11 +0200 | ||
Subject: [PATCH] libtool: Fix mishandling compiler flags with MSVC tools | ||
|
||
With MSVC, linker flags were not properly being linked in during a | ||
compile command. A check has been added to verify if there are linker | ||
flags set and then use a different command when linking. | ||
|
||
Fixes applied for bug#74175. | ||
|
||
* build-aux/ltmain.in: Fix command parser for '-Wl' option for MSVC. | ||
* m4/libtool.m4: Fix MSVC compile commands. | ||
* tests/flags.at: Use '$GREP --' instead of '$FGREP' when comparing with | ||
stdout. | ||
--- | ||
build-aux/ltmain.in | 18 ++++++++++++++---- | ||
m4/libtool.m4 | 20 ++++++++++++++++---- | ||
tests/flags.at | 8 ++++---- | ||
3 files changed, 34 insertions(+), 12 deletions(-) | ||
|
||
diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in | ||
index 8c48f14b..fc31facc 100644 | ||
--- a/build-aux/ltmain.in | ||
+++ b/build-aux/ltmain.in | ||
@@ -5130,8 +5130,13 @@ func_mode_link () | ||
continue | ||
;; | ||
xlinker) | ||
- func_append linker_flags " $qarg" | ||
- func_append compiler_flags " $wl$qarg" | ||
+ func_append linker_flags "$qarg," | ||
+ # Args in the var 'compiler_flags' causes warnings in MSVC | ||
+ func_cc_basename "$CC" | ||
+ case $func_cc_basename_result in | ||
+ cl*) ;; | ||
+ *) func_append compiler_flags " $wl$qarg" ;; | ||
+ esac | ||
prev= | ||
func_append compile_command " $wl$qarg" | ||
func_append finalize_command " $wl$qarg" | ||
@@ -5505,8 +5510,13 @@ func_mode_link () | ||
IFS=$save_ifs | ||
func_quote_arg pretty "$flag" | ||
func_append arg " $wl$func_quote_arg_result" | ||
- func_append compiler_flags " $wl$func_quote_arg_result" | ||
- func_append linker_flags " $func_quote_arg_result" | ||
+ # Args in the var 'compiler_flags' causes warnings in MSVC | ||
+ func_cc_basename "$CC" | ||
+ case $func_cc_basename_result in | ||
+ cl*) ;; | ||
+ *) func_append compiler_flags " $wl$func_quote_arg_result" ;; | ||
+ esac | ||
+ func_append linker_flags "$func_quote_arg_result," | ||
done | ||
IFS=$save_ifs | ||
func_stripname ' ' '' "$arg" | ||
diff --git a/m4/libtool.m4 b/m4/libtool.m4 | ||
index b77eaedb..1e5f16f1 100644 | ||
--- a/m4/libtool.m4 | ||
+++ b/m4/libtool.m4 | ||
@@ -5732,6 +5732,8 @@ _LT_EOF | ||
# Tell ltmain to make .dll files, not .so files. | ||
shrext_cmds=.dll | ||
# FIXME: Setting linknames here is a bad hack. | ||
+ # A check exists to verify if there are linker flags, which will use | ||
+ # different commands when linking. | ||
_LT_TAGVAR(archive_cmds, $1)='$CC -Fe$output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' | ||
_LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then | ||
cp "$export_symbols" "$output_objdir/$soname.def"; | ||
@@ -5739,7 +5741,11 @@ _LT_EOF | ||
else | ||
$SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; | ||
fi~ | ||
- $CC -Fe$tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ | ||
+ if test -z "$linker_flags"; then | ||
+ $CC -Fe$tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"; | ||
+ else | ||
+ $CC -Fe$tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,$linker_flags-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"; | ||
+ fi~ | ||
linknames=' | ||
# The linker will not automatically build a static lib if we build a DLL. | ||
# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' | ||
@@ -5771,7 +5777,7 @@ _LT_EOF | ||
# Tell ltmain to make .dll files, not .so files. | ||
shrext_cmds=.dll | ||
# FIXME: Setting linknames here is a bad hack. | ||
- _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' | ||
+ _LT_TAGVAR(archive_cmds, $1)='$CC -Fe$lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' | ||
# The linker will automatically build a .lib file if we build a DLL. | ||
_LT_TAGVAR(old_archive_from_new_cmds, $1)='true' | ||
# FIXME: Should let the user specify the lib program. | ||
@@ -6812,14 +6818,20 @@ if test yes != "$_lt_caught_CXX_error"; then | ||
# Tell ltmain to make .dll files, not .so files. | ||
shrext_cmds=.dll | ||
# FIXME: Setting linknames here is a bad hack. | ||
- _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' | ||
+ # A check exists to verify if there are linker flags, which will use | ||
+ # different commands when linking. | ||
+ _LT_TAGVAR(archive_cmds, $1)='$CC -Fe$output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' | ||
_LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then | ||
cp "$export_symbols" "$output_objdir/$soname.def"; | ||
echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; | ||
else | ||
$SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; | ||
fi~ | ||
- $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ | ||
+ if test -z "$linker_flags"; then | ||
+ $CC -Fe$tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"; | ||
+ else | ||
+ $CC -Fe$tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,$linker_flags-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"; | ||
+ fi~ | ||
linknames=' | ||
# The linker will not automatically build a static lib if we build a DLL. | ||
# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' | ||
diff --git a/tests/flags.at b/tests/flags.at | ||
index 8c40a7af..e59667ea 100644 | ||
--- a/tests/flags.at | ||
+++ b/tests/flags.at | ||
@@ -89,7 +89,7 @@ for flag in -Wc, -Wl, '-Xcompiler ' '-Xlinker '; do | ||
-Wc, | -Xcompiler\ ) | ||
AT_CHECK([$LIBTOOL -n --tag=lt_tag --mode=compile $compile ]dnl | ||
[$flag-foo -c $source], [], [stdout], [ignore]) | ||
- AT_CHECK([$FGREP " -foo" stdout], [], [ignore]) | ||
+ AT_CHECK([$GREP -- " -foo" stdout], [], [ignore]) | ||
flag_prefix_prog= | ||
flag_prefix_lib= | ||
flags_in_liblink=$compiler_flags_in_liblink | ||
@@ -103,7 +103,7 @@ for flag in -Wc, -Wl, '-Xcompiler ' '-Xlinker '; do | ||
|
||
AT_CHECK([$LIBTOOL -n --tag=lt_tag --mode=link $link ]dnl | ||
[-o program$EXEEXT a.lo $flag-foo], [], [stdout], [ignore]) | ||
- AT_CHECK([$FGREP " $flag_prefix_prog-foo" stdout], [], [ignore]) | ||
+ AT_CHECK([$GREP -- "$flag_prefix_prog-foo" stdout], [], [ignore]) | ||
|
||
eval set x "$library_and_module" | ||
for output | ||
@@ -112,9 +112,9 @@ for flag in -Wc, -Wl, '-Xcompiler ' '-Xlinker '; do | ||
AT_CHECK([$LIBTOOL -n --tag=lt_tag --mode=link $link ]dnl | ||
[-o $output a.lo -rpath /nowhere $flag-foo], [], [stdout], [ignore]) | ||
if $flags_in_liblink; then | ||
- AT_CHECK([$FGREP " $flag_prefix_lib-foo" stdout], [], [ignore]) | ||
+ AT_CHECK([$GREP -- "$flag_prefix_lib-foo" stdout], [], [ignore]) | ||
else | ||
- AT_CHECK([$FGREP " $flag_prefix_lib-foo" stdout], [1]) | ||
+ AT_CHECK([$GREP -- " $flag_prefix_lib-foo" stdout], [1]) | ||
fi | ||
done | ||
done | ||
-- | ||
2.45.2 | ||
|