Compare commits
4 Commits
master
...
build_werr
Author | SHA1 | Date |
---|---|---|
Lasse Collin | a338f62471 | |
Lasse Collin | 34a48239ed | |
Lasse Collin | 68c4cfc40c | |
Lasse Collin | 2fcb4085fd |
|
@ -759,6 +759,13 @@ set(CMAKE_REQUIRED_FLAGS "-Werror")
|
|||
check_c_source_compiles("
|
||||
__attribute__((__constructor__))
|
||||
static void my_constructor_func(void) { return; }
|
||||
/*
|
||||
* CompCert 3.12 silently ignores unsupported attributes
|
||||
* if the function appears to be unused. It doesn't consider
|
||||
* that the unknown attribute might make the function used.
|
||||
*/
|
||||
void call_func(void);
|
||||
void call_func(void) { my_constructor_func(); }
|
||||
int main(void) { return 0; }
|
||||
"
|
||||
HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR)
|
||||
|
@ -791,15 +798,22 @@ if(ALLOW_ATTR_IFUNC)
|
|||
static void (*resolve_func(void)) (void) { return func; }
|
||||
void func_ifunc(void)
|
||||
__attribute__((__ifunc__(\"resolve_func\")));
|
||||
int main(void) { return 0; }
|
||||
/*
|
||||
* CompCert 3.12 silently ignores unsupported attributes
|
||||
* if the function appears to be unused. It doesn't consider
|
||||
* that the unknown attribute might make the function used.
|
||||
*
|
||||
* '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:
|
||||
* versions 4 to 17.
|
||||
*
|
||||
* The following make CompCert diagnose the unsupported
|
||||
* attribute and silences the bogus Clang warning:
|
||||
*/
|
||||
void make_clang_quiet(void);
|
||||
void make_clang_quiet(void) { resolve_func()(); }
|
||||
void call_funcs(void);
|
||||
void call_funcs(void) { resolve_func()(); func_ifunc(); }
|
||||
int main(void) { return 0; }
|
||||
"
|
||||
HAVE_FUNC_ATTRIBUTE_IFUNC)
|
||||
cmake_pop_check_state()
|
||||
|
@ -848,10 +862,30 @@ if(HAVE_IMMINTRIN_H)
|
|||
tuklib_add_definition_if(liblzma HAVE_USABLE_CLMUL)
|
||||
endif()
|
||||
|
||||
# Support -fvisiblity=hidden when building shared liblzma.
|
||||
# These lines do nothing on Windows (even under Cygwin).
|
||||
# HAVE_VISIBILITY should always be defined to 0 or 1.
|
||||
if(BUILD_SHARED_LIBS)
|
||||
# Symbol visibility support:
|
||||
#
|
||||
# The C_VISIBILITY_PRESET property takes care of adding the compiler
|
||||
# option -fvisibility=hidden (or equivalent) if and only if it is supported.
|
||||
#
|
||||
# HAVE_VISIBILITY indicates if __attribute__((__visibility__("default")))
|
||||
# is supported. HAVE_VISIBILITY is ignored on Windows and Cygwin in
|
||||
# the C code so we don't need to handle that here. HAVE_VISIBILITY
|
||||
# should always be defined to 0 or 1.
|
||||
#
|
||||
# CMake's GenerateExportHeader module is too fancy since liblzma already
|
||||
# has the necessary macros. Instead, check CMake's internal variable
|
||||
# CMAKE_C_COMPILE_OPTIONS_VISIBILITY (it's the C-specific variant of
|
||||
# CMAKE_<LANG>_COMPILE_OPTIONS_VISIBILITY) which contains the string or
|
||||
# substring "-fvisibility=" when that compiler option is supported (due to
|
||||
# the possibility of substring, we use MATCHES instead of STREQUAL). It's
|
||||
# empty or unset when visibility isn't supported.
|
||||
#
|
||||
# NOTE: CMake 3.27 doesn't support other visibility mechanisms. For example,
|
||||
# SolarisStudio ("SunPro") has the option -xldscope=hidden and uses __global
|
||||
# instead of GNU C's __attribute__ to mark exported symbols. Autotools-based
|
||||
# build doesn't support -xldscope=hidden either.
|
||||
if(BUILD_SHARED_LIBS
|
||||
AND CMAKE_C_COMPILE_OPTIONS_VISIBILITY MATCHES "-fvisibility=")
|
||||
set_target_properties(liblzma PROPERTIES C_VISIBILITY_PRESET hidden)
|
||||
target_compile_definitions(liblzma PRIVATE HAVE_VISIBILITY=1)
|
||||
else()
|
||||
|
|
53
configure.ac
53
configure.ac
|
@ -606,6 +606,32 @@ AM_PROG_CC_C_O
|
|||
AM_PROG_AS
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
|
||||
# If using GCC or compatible compiler, verify that CFLAGS doesn't contain
|
||||
# something that makes -Werror unhappy. It's important to check this after
|
||||
# the above check for system extensions. It adds macros that can trigger,
|
||||
# for example, -Wunused-macros.
|
||||
if test "$GCC" = yes && test "x$SKIP_WERROR_CHECK" != xyes ; then
|
||||
AC_MSG_CHECKING([if the -Werror option is usable])
|
||||
OLD_CFLAGS=$CFLAGS
|
||||
CFLAGS="$CFLAGS -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[extern int foo; int foo;]])], [
|
||||
AC_MSG_RESULT([yes])
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([
|
||||
CFLAGS contains something that makes -Werror complain (see config.log).
|
||||
This would break certain checks in 'configure'. It is strongly
|
||||
recommended to modify CFLAGS to fix this. If you want to use noisy
|
||||
warning options, for example, -Weverything, it is still possible to
|
||||
add them later when running 'make': make CFLAGS+=-Weverything
|
||||
|
||||
In case you really want to continue with the current CFLAGS, pass
|
||||
'SKIP_WERROR_CHECK=yes' as an argument to 'configure'.
|
||||
])
|
||||
])
|
||||
CFLAGS=$OLD_CFLAGS
|
||||
fi
|
||||
|
||||
AS_CASE([$enable_threads],
|
||||
[posix], [
|
||||
echo
|
||||
|
@ -833,13 +859,6 @@ AC_C_BIGENDIAN
|
|||
# __attribute__((__constructor__)) can be used for one-time initializations.
|
||||
# Use -Werror because some compilers accept unknown attributes and just
|
||||
# give a warning.
|
||||
#
|
||||
# FIXME? Unfortunately -Werror can cause trouble if CFLAGS contains options
|
||||
# that produce warnings for unrelated reasons. For example, GCC and Clang
|
||||
# support -Wunused-macros which will warn about "#define _GNU_SOURCE 1"
|
||||
# which will be among the #defines that Autoconf inserts to the beginning of
|
||||
# the test program. There seems to be no nice way to prevent Autoconf from
|
||||
# inserting the any defines to the test program.
|
||||
AC_MSG_CHECKING([if __attribute__((__constructor__)) can be used])
|
||||
have_func_attribute_constructor=no
|
||||
OLD_CFLAGS="$CFLAGS"
|
||||
|
@ -847,6 +866,13 @@ CFLAGS="$CFLAGS -Werror"
|
|||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||
__attribute__((__constructor__))
|
||||
static void my_constructor_func(void) { return; }
|
||||
/*
|
||||
* CompCert 3.12 silently ignores unsupported attributes
|
||||
* if the function appears to be unused. It doesn't consider
|
||||
* that the unknown attribute might make the function used.
|
||||
*/
|
||||
void call_func(void);
|
||||
void call_func(void) { my_constructor_func(); }
|
||||
]])], [
|
||||
AC_DEFINE([HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR], [1],
|
||||
[Define to 1 if __attribute__((__constructor__))
|
||||
|
@ -889,13 +915,20 @@ if test "x$enable_ifunc" = xyes ; then
|
|||
void func_ifunc (void)
|
||||
__attribute__((__ifunc__("resolve_func")));
|
||||
/*
|
||||
* CompCert 3.12 silently ignores unsupported attributes
|
||||
* if the function appears to be unused. It doesn't consider
|
||||
* that the unknown attribute might make the function used.
|
||||
*
|
||||
* '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:
|
||||
* versions 4 to 17.
|
||||
*
|
||||
* The following make CompCert diagnose the unsupported
|
||||
* attribute and silences the bogus Clang warning:
|
||||
*/
|
||||
void make_clang_quiet(void);
|
||||
void make_clang_quiet(void) { resolve_func()(); }
|
||||
void call_funcs(void);
|
||||
void call_funcs(void) { resolve_func()(); func_ifunc(); }
|
||||
]])], [
|
||||
AC_DEFINE([HAVE_FUNC_ATTRIBUTE_IFUNC], [1],
|
||||
[Define to 1 if __attribute__((__ifunc__()))
|
||||
|
|
Loading…
Reference in New Issue