Skip to content

Commit

Permalink
autoconf: unbreak --enable-lto, fix some language macros
Browse files Browse the repository at this point in the history
PA_ADD_LANGFLAGS() was broken, resulting in among other things
--enable-lto not working.

Make autogen.sh fail if aclocal return error.

Signed-off-by: H. Peter Anvin <[email protected]>
  • Loading branch information
H. Peter Anvin committed Apr 16, 2024
1 parent b11802c commit 2d2ae91
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
14 changes: 8 additions & 6 deletions autoconf/m4/pa_add_langflags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ m4_defun([_PA_LANGFLAG_VAR],
[m4_fatal([PA_ADD_LANGFLAGS: Unknown language: $1])])])

AC_DEFUN([PA_ADD_LANGFLAGS],
[m4_set_foreach(PA_LANG_SEEN_SET, [lang],
[_pa_flag_found=no
m4_foreach_w([flag], [$1],
[AS_IF([test $_pa_flag_found = no],
[PA_ADD_FLAGS(_PA_LANGFLAG_VAR(lang),flag,[],[_pa_flag_found=yes])])
])])])
[m4_pushdef([_pa_langflags],m4_dquote($1))dnl
m4_set_foreach(_PA_LANG_SEEN_SET,[_pa_lang],dnl
[_pa_flag_found=no
m4_foreach_w([_pa_flag], _pa_langflags,
[AS_IF([test $_pa_flag_found = no],
[PA_ADD_FLAGS(_PA_LANGFLAG_VAR(_pa_lang),_pa_flag,[],[_pa_flag_found=yes])])
])])
m4_popdef([_pa_langflags])])
3 changes: 2 additions & 1 deletion autoconf/m4/pa_option_lto.m4
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ AC_DEFUN([PA_OPTION_LTO],
[PA_ARG_BOOL([lto],
[Try to enable link-time optimization for this compiler],
[$1],
[PA_ADD_LANGFLAGS([-flto])
[PA_ADD_LANGFLAGS([-flto=auto -flto])
PA_ADD_LANGFLAGS([-ffat-lto-objects])
dnl Note: we use _PROG rather than _TOOL since we are prepending the full
dnl CC name which ought to already contain the host triplet if needed
ccbase=`echo "$CC" | awk '{ print $1; }'`
Expand Down
13 changes: 13 additions & 0 deletions autoconf/m4/pa_prog_cc.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dnl --------------------------------------------------------------------------
dnl PA_PROG_CC()
dnl
dnl Similar to AC_PROG_CC, but add a prototype for main() to
dnl AC_INCLUDES_DEFAULT to avoid -Werror from breaking compilation.
dnl --------------------------------------------------------------------------
AC_DEFUN([PA_PROG_CC],
[AC_PROG_CC
AS_IF([test x$ac_cv_prog != xno],
[ac_includes_default="$ac_includes_default
#ifndef __cplusplus
extern int main(void);
#endif"])])
1 change: 1 addition & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ if test ! -f autoconf/aclocal.m4; then
# aclocal failed, revert to previous files
mv -f autoconf/m4.old/*.m4 autoconf/m4/
mv -f autoconf/aclocal.m4.old autoconf/aclocal.m4
exit 1
fi
rm -rf autoconf/*m4.old
"$AUTOHEADER" -B autoconf
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dnl the best very slow and doesn't buy us a single thing at all.
PA_CROSS_COMPILE

dnl Enable any available C extensions
AC_PROG_CC
PA_PROG_CC
AC_USE_SYSTEM_EXTENSIONS
PA_ADD_CPPFLAGS([-std=c17], [], [],
[PA_ADD_CPPFLAGS([-std=c11], [], [],
Expand Down

0 comments on commit 2d2ae91

Please sign in to comment.