mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-01-18 16:25:05 +08:00
Makefile: make it possible to compile with gcc link-time optimization
Put in the necessary machinery to compile with gcc link-time optimization. This means compiling and linking with -flto, as well as using gcc-ar and gcc-ranlib instead of the normal tools. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
parent
2d6a3101f9
commit
5fe847e590
21
aclocal.m4
vendored
21
aclocal.m4
vendored
@ -14,6 +14,27 @@ AC_DEFUN(PA_ADD_CFLAGS,
|
||||
AC_MSG_RESULT([no])
|
||||
CFLAGS="$pa_add_cflags__old_cflags")])
|
||||
|
||||
dnl --------------------------------------------------------------------------
|
||||
dnl PA_ADD_CLDFLAGS()
|
||||
dnl
|
||||
dnl Attempt to add the given option to CFLAGS and LDFLAGS,
|
||||
dnl if it doesn't break compilation
|
||||
dnl --------------------------------------------------------------------------
|
||||
AC_DEFUN(PA_ADD_CLDFLAGS,
|
||||
[AC_MSG_CHECKING([if $CC accepts $1])
|
||||
pa_add_cldflags__old_cflags="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $1"
|
||||
pa_add_cldflags__old_ldflags="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $1"
|
||||
AC_TRY_LINK([#include <stdio.h>],
|
||||
[printf("Hello, World!\n");],
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS="$pa_add_cldflags__old_cflags ifelse([$2],[],[$1],[$2])"
|
||||
LDFLAGS="$pa_add_cldflags__old_ldflags ifelse([$2],[],[$1],[$2])",
|
||||
AC_MSG_RESULT([no])
|
||||
CFLAGS="$pa_add_cldflags__old_cflags"
|
||||
LDFLAGS="$pa_add_cldflags__old_ldflags")])
|
||||
|
||||
dnl --------------------------------------------------------------------------
|
||||
dnl PA_HAVE_FUNC
|
||||
dnl
|
||||
|
19
configure.ac
19
configure.ac
@ -148,13 +148,28 @@ PA_FUNC_ATTRIBUTE(pure)
|
||||
PA_FUNC_ATTRIBUTE_ERROR
|
||||
|
||||
dnl
|
||||
dnl support cchace
|
||||
dnl support ccache
|
||||
dnl
|
||||
AC_ARG_ENABLE([ccache],
|
||||
[AC_HELP_STRING([--with-ccache], [compile with ccache])],
|
||||
[AC_HELP_STRING([--enable-ccache], [compile with ccache])],
|
||||
[CC="ccache $CC"],
|
||||
[])
|
||||
|
||||
dnl
|
||||
dnl support LTO
|
||||
dnl
|
||||
AC_ARG_ENABLE([lto],
|
||||
[AC_HELP_STRING([--enable-lto], [compile with gcc link time optimization])],
|
||||
[PA_ADD_CLDFLAGS([-flto])
|
||||
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; }'`
|
||||
AC_CHECK_PROG(CC_AR, [${ccbase}-ar], [${ccbase}-ar], [$ac_cv_prog_AR])
|
||||
AR="$CC_AR"
|
||||
AC_CHECK_PROG(CC_RANLIB, [${ccbase}-ranlib], [${ccbase}-ranlib], [$ac_cv_prog_RANLIB])
|
||||
RANLIB="$CC_RANLIB"
|
||||
], [])
|
||||
|
||||
dnl If we have gcc, add appropriate code cleanliness options
|
||||
PA_ADD_CFLAGS([-W])
|
||||
PA_ADD_CFLAGS([-Wall])
|
||||
|
Loading…
Reference in New Issue
Block a user