]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
Build: Fix __attribute__((ifunc(...))) detection with clang -Wall.
authorLasse Collin <lasse.collin@tukaani.org>
Tue, 26 Sep 2023 12:00:43 +0000 (15:00 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Tue, 26 Sep 2023 12:00:43 +0000 (15:00 +0300)
Now if user-supplied CFLAGS contains -Wall -Wextra -Wpedantic
the two checks that need -Werror will still work.

At CMake side there is add_compile_options(-Wall -Wextra)
but it didn't affect the -Werror tests. So with both Autotools
and CMake only user-supplied CFLAGS could make the checks fail
when they shouldn't.

This is not a full fix as things like -Wunused-macros in
user-supplied CFLAGS will still cause problems with both
GCC and Clang.

CMakeLists.txt
configure.ac

index 9baa314e3392feb3282e85cb05f8aa7231b4457d..c8d52f2db4d8be20ab37e2fdff2cad999aa83c7a 100644 (file)
@@ -790,6 +790,14 @@ if(ALLOW_ATTR_IFUNC)
             void func_ifunc(void)
                     __attribute__((__ifunc__(\"resolve_func\")));
             int main(void) { return 0; }
+            /*
+             * 'clang -Wall' incorrectly warns that resolve_func is
+             * unused (-Wunused-function). Correct assembly output is
+             * still produced. This problem exists at least in Clang
+             * versions 4 to 17. The following silences the bogus warning:
+             */
+            void make_clang_quiet(void);
+            void make_clang_quiet(void) { resolve_func()(); }
         "
         HAVE_FUNC_ATTRIBUTE_IFUNC)
     cmake_pop_check_state()
index d83b148a44f32bac3c6d2bd988389e2ef83a0287..cf34c739b73f789c7c66b22c4f030c9c7791ad97 100644 (file)
@@ -882,6 +882,14 @@ if test "x$enable_ifunc" = xyes ; then
                static void (*resolve_func (void)) (void) { return func; }
                void func_ifunc (void)
                                __attribute__((__ifunc__("resolve_func")));
+               /*
+                * 'clang -Wall' incorrectly warns that resolve_func is
+                * unused (-Wunused-function). Correct assembly output is
+                * still produced. This problem exists at least in Clang
+                * versions 4 to 17. The following silences the bogus warning:
+                */
+               void make_clang_quiet(void);
+               void make_clang_quiet(void) { resolve_func()(); }
        ]])], [
                AC_DEFINE([HAVE_FUNC_ATTRIBUTE_IFUNC], [1],
                        [Define to 1 if __attribute__((__ifunc__()))