Skip to content

Commit 2d2ae91

Browse files
author
H. Peter Anvin
committed
autoconf: unbreak --enable-lto, fix some language macros
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]>
1 parent b11802c commit 2d2ae91

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

autoconf/m4/pa_add_langflags.m4

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ m4_defun([_PA_LANGFLAG_VAR],
1717
[m4_fatal([PA_ADD_LANGFLAGS: Unknown language: $1])])])
1818

1919
AC_DEFUN([PA_ADD_LANGFLAGS],
20-
[m4_set_foreach(PA_LANG_SEEN_SET, [lang],
21-
[_pa_flag_found=no
22-
m4_foreach_w([flag], [$1],
23-
[AS_IF([test $_pa_flag_found = no],
24-
[PA_ADD_FLAGS(_PA_LANGFLAG_VAR(lang),flag,[],[_pa_flag_found=yes])])
25-
])])])
20+
[m4_pushdef([_pa_langflags],m4_dquote($1))dnl
21+
m4_set_foreach(_PA_LANG_SEEN_SET,[_pa_lang],dnl
22+
[_pa_flag_found=no
23+
m4_foreach_w([_pa_flag], _pa_langflags,
24+
[AS_IF([test $_pa_flag_found = no],
25+
[PA_ADD_FLAGS(_PA_LANGFLAG_VAR(_pa_lang),_pa_flag,[],[_pa_flag_found=yes])])
26+
])])
27+
m4_popdef([_pa_langflags])])

autoconf/m4/pa_option_lto.m4

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ AC_DEFUN([PA_OPTION_LTO],
1010
[PA_ARG_BOOL([lto],
1111
[Try to enable link-time optimization for this compiler],
1212
[$1],
13-
[PA_ADD_LANGFLAGS([-flto])
13+
[PA_ADD_LANGFLAGS([-flto=auto -flto])
14+
PA_ADD_LANGFLAGS([-ffat-lto-objects])
1415
dnl Note: we use _PROG rather than _TOOL since we are prepending the full
1516
dnl CC name which ought to already contain the host triplet if needed
1617
ccbase=`echo "$CC" | awk '{ print $1; }'`

autoconf/m4/pa_prog_cc.m4

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
dnl --------------------------------------------------------------------------
2+
dnl PA_PROG_CC()
3+
dnl
4+
dnl Similar to AC_PROG_CC, but add a prototype for main() to
5+
dnl AC_INCLUDES_DEFAULT to avoid -Werror from breaking compilation.
6+
dnl --------------------------------------------------------------------------
7+
AC_DEFUN([PA_PROG_CC],
8+
[AC_PROG_CC
9+
AS_IF([test x$ac_cv_prog != xno],
10+
[ac_includes_default="$ac_includes_default
11+
#ifndef __cplusplus
12+
extern int main(void);
13+
#endif"])])

autogen.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ if test ! -f autoconf/aclocal.m4; then
5353
# aclocal failed, revert to previous files
5454
mv -f autoconf/m4.old/*.m4 autoconf/m4/
5555
mv -f autoconf/aclocal.m4.old autoconf/aclocal.m4
56+
exit 1
5657
fi
5758
rm -rf autoconf/*m4.old
5859
"$AUTOHEADER" -B autoconf

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dnl the best very slow and doesn't buy us a single thing at all.
1818
PA_CROSS_COMPILE
1919

2020
dnl Enable any available C extensions
21-
AC_PROG_CC
21+
PA_PROG_CC
2222
AC_USE_SYSTEM_EXTENSIONS
2323
PA_ADD_CPPFLAGS([-std=c17], [], [],
2424
[PA_ADD_CPPFLAGS([-std=c11], [], [],

0 commit comments

Comments
 (0)