]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
libtool: Check if -no-canonical-prefixes supported
authorIleana Dumitrescu <ileanadumitrescu95@gmail.com>
Fri, 7 Jun 2024 17:02:55 +0000 (20:02 +0300)
committerIleana Dumitrescu <ileanadumitrescu95@gmail.com>
Sat, 8 Jun 2024 08:16:10 +0000 (11:16 +0300)
The compiler fails with the -no-canonical-prefixes flag in certain
environments. Check if the flag is supported in the current environment
and skip the test if it is not supported.

* tests/bug_62343.at: Skip test if -no-canonical-prefixes is unsupported
  in the current environment.

tests/bug_62343.at

index 05839dc4fb9bc2bce32b3d586678618e7056040b..f6053dc6bfce7bf1f2f0c4b76816727449dc3f40 100644 (file)
@@ -29,13 +29,32 @@ AT_CHECK([$LIBTOOL --config | $EGREP '^build_libtool_libs=no' && (exit 77)], 1)
 
 AT_DATA([x.cpp],
 [[
-void f(int *p) { *p = 21; }
+#include <iostream>
+
+int main() {
+    std::cout << "Hello, World!" << std::endl;
+    return 0;
+}
 ]])
 
+# The -no-canonical-prefixes flag sometimes fails at the compiler level
+# depending on how the environment is set up, or which other flags have to be passed.
+# So first try to compile without libtool first to test if the current environment
+# supports the -no-canonical-prefixes flag. If it doesn't, skip the test.
+
+g++ -no-canonical-prefixes -c x.cpp
+
+result=$?
 
-AT_CHECK([$LIBTOOL --mode=compile --tag=CXX g++ -c x.cpp], [0], [stdout], [stderr])
+if test 0 -ne "$result"; then
+    AT_SKIP_IF([:])
+fi
+
+AT_CHECK([$LIBTOOL --mode=compile --tag=CXX g++ -no-canonical-prefixes -c x.cpp], [0], [stdout], [stderr])
+
+AT_CHECK([$GREP -- '-no-canonical-prefixes' stdout], [0], [ignore])
 
-AT_CHECK([$LIBTOOL --mode=link --tag=CXX g++ -o libx.la -no-canonical-prefixes -rpath /usr/lib64/ x.lo], [0], [stdout], [stderr])
+AT_CHECK([$LIBTOOL --mode=link --tag=CXX g++ -no-undefined -no-canonical-prefixes -o libx.la -rpath /usr/lib64/ x.lo], [0], [stdout], [stderr])
 
 AT_CHECK([$GREP -- '-no-canonical-prefixes' stdout], [0], [ignore])