File tree Expand file tree Collapse file tree 3 files changed +37
-3
lines changed
Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -680,6 +680,27 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
680680] )
681681CFLAGS=$saved_CFLAGS
682682
683+ dnl Force compiler to use zero_call_used_regs("used") to check for the function attribute support.
684+ dnl Otherwise the compiler may falsely advertise it with __has_attribute operator, even though
685+ dnl it does not implement it on some archs.
686+ AC_MSG_CHECKING ( [ for zero_call_used_regs(user)] )
687+ saved_CFLAGS=$CFLAGS
688+ CFLAGS="-O0 -Werror"
689+ AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ [
690+ void _test_function(void);
691+ __attribute__((zero_call_used_regs("used"))) void _test_function(void) {
692+ volatile int *i; volatile int j = 0; if (j) *i = 0;
693+ }
694+ ] ] ,
695+ [ [ _test_function() ] ]
696+ ) ] ,[
697+ AC_DEFINE ( [ HAVE_ATTRIBUTE_ZEROCALLUSEDREGS] , 1 , [ Define to 1 to use __attribute__((zero_call_used_regs("used")))] )
698+ AC_MSG_RESULT ( [ yes] )
699+ ] , [
700+ AC_MSG_RESULT ( [ no] )
701+ ] )
702+ CFLAGS=$saved_CFLAGS
703+
683704AC_MSG_CHECKING ( [ for systemd tmpfiles config directory] )
684705if test "x$prefix" != "xNONE"; then
685706 saved_PKG_CONFIG=$PKG_CONFIG
Original file line number Diff line number Diff line change 99
1010#define ATTR_NOINLINE __attribute__ ((noinline))
1111#define ATTR_ZERO_REGS
12- #if defined __has_attribute
13- # if __has_attribute (zero_call_used_regs )
12+ #if HAVE_ATTRIBUTE_ZEROCALLUSEDREGS
1413# undef ATTR_ZERO_REGS
1514# define ATTR_ZERO_REGS __attribute__ ((zero_call_used_regs("used")))
16- # endif
1715#endif
1816
1917/* Workaround for https://github.com/google/sanitizers/issues/1507 */
Original file line number Diff line number Diff line change @@ -697,6 +697,21 @@ if cc.links(
697697 description : ' Define to 1 to use __attribute__((symver))' )
698698endif
699699
700+ # ==========================================================================
701+ # Check compiler support for zero_called_used_regs("used") function attribute
702+ if cc.links(
703+ ''' void _test_fn(void);
704+
705+ __attribute__((zero_call_used_regs("used"))) void _test_fn(void) {
706+ volatile int *i; volatile int j = 0; if (j) *i = 0;
707+ }
708+ int main(void) { _test_fn(); return 0; }''' ,
709+ args : [' -O0' , ' -Werror' ],
710+ name : ' for zero_call_used_regs("used") attribute support' )
711+ conf.set10(' HAVE_ATTRIBUTE_ZEROCALLUSEDREGS' , true ,
712+ description : ' Define to 1 to use __attribute__((zero_call_used_regs("used")))' )
713+ endif
714+
700715# ==========================================================================
701716
702717if get_option (' dev-random' )
You can’t perform that action at this time.
0 commit comments