Build: Fix silently-ignored attribute problem on CompCert 3.12.
Tested on godbolt.org only.
This commit is contained in:
parent
68c4cfc40c
commit
34a48239ed
|
@ -759,6 +759,13 @@ set(CMAKE_REQUIRED_FLAGS "-Werror")
|
||||||
check_c_source_compiles("
|
check_c_source_compiles("
|
||||||
__attribute__((__constructor__))
|
__attribute__((__constructor__))
|
||||||
static void my_constructor_func(void) { return; }
|
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; }
|
int main(void) { return 0; }
|
||||||
"
|
"
|
||||||
HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR)
|
HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR)
|
||||||
|
@ -791,15 +798,22 @@ if(ALLOW_ATTR_IFUNC)
|
||||||
static void (*resolve_func(void)) (void) { return func; }
|
static void (*resolve_func(void)) (void) { return func; }
|
||||||
void func_ifunc(void)
|
void func_ifunc(void)
|
||||||
__attribute__((__ifunc__(\"resolve_func\")));
|
__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
|
* 'clang -Wall' incorrectly warns that resolve_func is
|
||||||
* unused (-Wunused-function). Correct assembly output is
|
* unused (-Wunused-function). Correct assembly output is
|
||||||
* still produced. This problem exists at least in Clang
|
* 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 call_funcs(void);
|
||||||
void make_clang_quiet(void) { resolve_func()(); }
|
void call_funcs(void) { resolve_func()(); func_ifunc(); }
|
||||||
|
int main(void) { return 0; }
|
||||||
"
|
"
|
||||||
HAVE_FUNC_ATTRIBUTE_IFUNC)
|
HAVE_FUNC_ATTRIBUTE_IFUNC)
|
||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
|
|
20
configure.ac
20
configure.ac
|
@ -866,6 +866,13 @@ CFLAGS="$CFLAGS -Werror"
|
||||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||||
__attribute__((__constructor__))
|
__attribute__((__constructor__))
|
||||||
static void my_constructor_func(void) { return; }
|
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],
|
AC_DEFINE([HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR], [1],
|
||||||
[Define to 1 if __attribute__((__constructor__))
|
[Define to 1 if __attribute__((__constructor__))
|
||||||
|
@ -908,13 +915,20 @@ if test "x$enable_ifunc" = xyes ; then
|
||||||
void func_ifunc (void)
|
void func_ifunc (void)
|
||||||
__attribute__((__ifunc__("resolve_func")));
|
__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
|
* 'clang -Wall' incorrectly warns that resolve_func is
|
||||||
* unused (-Wunused-function). Correct assembly output is
|
* unused (-Wunused-function). Correct assembly output is
|
||||||
* still produced. This problem exists at least in Clang
|
* 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 call_funcs(void);
|
||||||
void make_clang_quiet(void) { resolve_func()(); }
|
void call_funcs(void) { resolve_func()(); func_ifunc(); }
|
||||||
]])], [
|
]])], [
|
||||||
AC_DEFINE([HAVE_FUNC_ATTRIBUTE_IFUNC], [1],
|
AC_DEFINE([HAVE_FUNC_ATTRIBUTE_IFUNC], [1],
|
||||||
[Define to 1 if __attribute__((__ifunc__()))
|
[Define to 1 if __attribute__((__ifunc__()))
|
||||||
|
|
Loading…
Reference in New Issue