]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
libtool: Fix --no-warnings flag
authorIleana Dumitrescu <ileanadumitrescu95@gmail.com>
Mon, 18 Nov 2024 18:19:57 +0000 (20:19 +0200)
committerIleana Dumitrescu <ileanadumitrescu95@gmail.com>
Wed, 20 Nov 2024 15:36:29 +0000 (17:36 +0200)
Passing --no-warnings to libtool would not suppress warning messages.

* build-aux/ltmain.in: Add 'opt_warning' check before printing out
  warning messages.
* tests/libtool.at: Add simple test for '--no-warnings'.
* NEWS: Update.

NEWS
build-aux/ltmain.in
tests/libtool.at

diff --git a/NEWS b/NEWS
index b61b40247c54c1e4582deb7fe49c2af966420261..355a5ad030c3a78be0c8eb89caa4d86e1c1d593d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,8 @@ NEWS - list of user-visible changes between releases of GNU Libtool
 
   - Fix '-Fe' usage with linking in MSVC.
 
+  - Fix '--no-warnings' flag.
+
 ** Changes in supported systems or compilers:
 
   - Support additional flang-based compilers, 'f18' and 'f95'.
index 4d7fc293d3fba04c0d4f8d0e0ad8771bfcdf713e..8cef9e8dfbe05cc9fefa84462b8d224d417454f3 100644 (file)
@@ -111,18 +111,6 @@ func_echo ()
 }
 
 
-# func_warning ARG...
-# -------------------
-# Libtool warnings are not categorized, so override funclib.sh
-# func_warning with this simpler definition.
-func_warning ()
-{
-    $debug_cmd
-
-    $warning_func ${1+"$@"}
-}
-
-
 ## ---------------- ##
 ## Options parsing. ##
 ## ---------------- ##
@@ -383,6 +371,7 @@ libtool_options_prep ()
     opt_preserve_dup_deps=false
     opt_quiet=false
     opt_finishing=true
+    opt_warning=
 
     nonopt=
     preserve_args=
@@ -553,6 +542,18 @@ libtool_parse_options ()
 func_add_hook func_parse_options libtool_parse_options
 
 
+# func_warning ARG...
+# -------------------
+# Libtool warnings are not categorized, so override funclib.sh
+# func_warning with this simpler definition.
+func_warning ()
+{
+    if $opt_warning; then
+        $debug_cmd
+        $warning_func ${1+"$@"}
+    fi
+}
+
 
 # libtool_validate_options [ARG]...
 # ---------------------------------
index b41c3cdef93f4940d16d800240a28851788ac0bc..7143a5082f83b13c257a4927e290b9afd0de0780 100755 (executable)
@@ -239,3 +239,22 @@ AT_CHECK([$LIBTOOL -n --mode=link --tag=UnKnOwN compiler -o liba.la foo.lo],
 AT_CHECK([$GREP 'ignoring unknown tag' stderr], [0], [ignore])
 
 AT_CLEANUP
+
+## -------------------- ##
+## Silence LT warnings. ##
+## -------------------- ##
+
+AT_SETUP([test silencing warnings])
+
+AT_DATA([x.cpp],
+[[
+void f(int *p) { *p = 21; }
+]])
+
+AT_CHECK([$LIBTOOL --mode=compile --tag=CXX g++ -c x.cpp], [0], [stdout], [stderr])
+
+AT_CHECK([$LIBTOOL --no-warnings --mode=link --tag=CXX g++ -o libx.la -no-canonical-prefixes -R /usr/lib64/ -version-info x.lo], [0], [stdout], [stderr])
+
+AT_CHECK([$GREP -- 'warning' stderr], [1], [ignore])
+
+AT_CLEANUP