mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-09 10:52:24 +00:00
Add option for link-time optimization/link-time code generation
The option is disabled by default.
configure.ac:
Add --enable-lto option to the configure script to enable LTO/LTCG.
scripts/mgnuc.in:
scripts/ml.in:
Pass LTO options to the C compiler/linker.
compiler/compile_target_code.m:
compiler/options.m:
scripts/Mercury.config.in:
Add internal options to specify C compiler and linker LTO/LTCG flags.
This commit is contained in:
committed by
Julien Fischer
parent
9a042f4fb1
commit
416fbe954a
@@ -72,6 +72,7 @@ DEFAULT_MCFLAGS=\
|
||||
--cflags-for-regs "@CFLAGS_FOR_REGS@" \
|
||||
--cflags-for-gotos "@CFLAGS_FOR_GOTOS@" \
|
||||
--cflags-for-pic "@CFLAGS_FOR_PIC@" \
|
||||
--cflags-for-lto "@CFLAGS_FOR_LTO@" \
|
||||
--c-flag-to-name-object-file "@OBJFILE_OPT@" \
|
||||
--java-flags "@JAVAC_FLAGS_FOR_HEAP_SIZE_CONFIG@" \
|
||||
--object-file-extension ".@OBJ_SUFFIX@" \
|
||||
@@ -98,6 +99,7 @@ DEFAULT_MCFLAGS=\
|
||||
--readline-libs "@READLINE_LIBRARIES@" \
|
||||
--linker-opt-separator "@LINK_OPT_SEP@" \
|
||||
--linker-thread-flags "@LDFLAGS_FOR_THREADS@" \
|
||||
--linker-lto-flags "@LDFLAGS_FOR_LTO@" \
|
||||
--shlib-linker-thread-flags "@LD_LIBFLAGS_FOR_THREADS@" \
|
||||
--linker-trace-flags "@LDFLAGS_FOR_TRACE@" \
|
||||
--shlib-linker-trace-flags "@LD_LIBFLAGS_FOR_TRACE@" \
|
||||
|
||||
7
scripts/mgnuc.in
Normal file → Executable file
7
scripts/mgnuc.in
Normal file → Executable file
@@ -25,6 +25,7 @@ C_COMPILER_TYPE=${MERCURY_C_COMPILER_TYPE="@C_COMPILER_TYPE@"}
|
||||
CFLAGS_FOR_REGS="@CFLAGS_FOR_REGS@"
|
||||
CFLAGS_FOR_GOTOS="@CFLAGS_FOR_GOTOS@"
|
||||
CFLAGS_FOR_THREADS="@CFLAGS_FOR_THREADS@"
|
||||
CFLAGS_FOR_LTO="@CFLAGS_FOR_LTO@"
|
||||
CFLAGS_FOR_NO_STRICT_ALIASING="@CFLAGS_FOR_NO_STRICT_ALIASING@"
|
||||
CFLAGS_FOR_ANSI="@CFLAGS_FOR_ANSI@"
|
||||
CFLAGS_FOR_SANITIZERS="@CFLAGS_FOR_SANITIZERS@"
|
||||
@@ -86,7 +87,7 @@ case "$C_COMPILER_TYPE" in
|
||||
msvc*)
|
||||
ANSI_OPTS=""
|
||||
CHECK_OPTS="-nologo" # Suppress the MSVC banner message.
|
||||
OPT_OPTS=""
|
||||
OPT_OPTS="-O1"
|
||||
# See README.MS-VisualC for why we don't enable C level debugging.
|
||||
#DEBUG_OPTS="-Zi"
|
||||
DEBUG_OPTS=""
|
||||
@@ -514,6 +515,9 @@ esac
|
||||
# if sanitizers were enabled at configure time, add CFLAGS_FOR_SANITIZERS
|
||||
SANITIZER_OPTS="$CFLAGS_FOR_SANITIZERS"
|
||||
|
||||
# Use any applicable LTO options
|
||||
LTO_OPTS="$CFLAGS_FOR_LTO"
|
||||
|
||||
#
|
||||
# Special case hacks for particular architectures
|
||||
# Any code here needs to be duplicated in ../configure.in.
|
||||
@@ -645,6 +649,7 @@ ALL_CC_OPTS="$MERC_ALL_C_INCL_DIRS\
|
||||
$ANSI_OPTS\
|
||||
$CHECK_OPTS\
|
||||
$OPT_OPTS\
|
||||
$LTO_OPTS\
|
||||
$HLC_OPTS\
|
||||
$HLD_OPTS\
|
||||
$GCC_OPTS\
|
||||
|
||||
@@ -49,6 +49,7 @@ LD_STATIC_FLAGS="@LD_STATIC_FLAGS@"
|
||||
LDFLAGS_FOR_THREADS="@LDFLAGS_FOR_THREADS@"
|
||||
LDFLAGS_FOR_TRACE="@LDFLAGS_FOR_TRACE@"
|
||||
LD_LIBFLAGS_FOR_THREADS="@LD_LIBFLAGS_FOR_THREADS@"
|
||||
LDFLAGS_FOR_LTO="@LDFLAGS_FOR_LTO@"
|
||||
THREAD_LIBS="@THREAD_LIBS@"
|
||||
HWLOC_LIBS="@HWLOC_LIBS@"
|
||||
HWLOC_STATIC_LIBS="@HWLOC_STATIC_LIBS@"
|
||||
@@ -408,6 +409,9 @@ else
|
||||
NODEFAULTLIB_FLAG=""
|
||||
fi
|
||||
|
||||
# Use any applicable LTO options
|
||||
LTO_OPTS="$LDFLAGS_FOR_LTO"
|
||||
|
||||
case $make_shared_lib in
|
||||
true)
|
||||
LINKER="$LINK_SHARED_OBJ"
|
||||
@@ -559,7 +563,7 @@ else
|
||||
NOLOGO_OPTS=""
|
||||
fi
|
||||
|
||||
LINKER_PRE_FLAGS="$NOLOGO_OPTS $MSVCRT_OPTS $PRINT_MAP_OPT $UNDEF_OPT $STRIP_OPTS $MAYBE_STATIC_OPT $ARCH_OPTS $SANITIZER_OPTS"
|
||||
LINKER_PRE_FLAGS="$NOLOGO_OPTS $MSVCRT_OPTS $PRINT_MAP_OPT $UNDEF_OPT $STRIP_OPTS $LTO_OPTS $MAYBE_STATIC_OPT $ARCH_OPTS $SANITIZER_OPTS"
|
||||
LINKER_POST_FLAGS="@LINK_OPT_SEP@ $NODEFAULTLIB_FLAG $DEBUG_FLAG $LIBDIR_OPTS $RPATH_OPT_LIST $LIBS"
|
||||
|
||||
case $verbose in
|
||||
|
||||
Reference in New Issue
Block a user