@@ -41,7 +41,27 @@
Use gcc's option -pipe to use pipes rather than temp files when building
the toolchain.
-config EXTRA_FLAGS_FOR_HOST
+config EXTRA_CFLAGS_FOR_BUILD
+ string
+ prompt "Extra build compiler flags"
+ default ""
+ help
+ Extra flags to pass to the build C and C++ compiler.
+
+ May be used to change the default features of the build
+ compiler such as turning off the stack protector or fortify.
+
+config EXTRA_LDFLAGS_FOR_BUILD
+ string
+ prompt "Extra build linker flags"
+ default ""
+ help
+ Extra flags to pass to the build linker.
+
+ May be used to change the default features of the build
+ linker.
+
+config EXTRA_CFLAGS_FOR_HOST
string
prompt "Extra host compiler flags"
default ""
@@ -50,6 +70,16 @@
May be used to change the default features of the host
compiler such as turning off the stack protector or fortify.
+
+config EXTRA_LDFLAGS_FOR_HOST
+ string
+ prompt "Extra host linker flags"
+ default ""
+ help
+ Extra flags to pass to the host linker.
+
+ May be used to change the default features of the host
+ linker.
choice
bool
@@ -39,6 +39,8 @@
binutils_opts+=( "host=${CT_BUILD}" )
binutils_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
+ binutils_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
+ binutils_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
do_binutils_backend "${binutils_opts[@]}"
@@ -58,6 +60,7 @@
binutils_opts+=( "prefix=${CT_PREFIX_DIR}" )
binutils_opts+=( "static_build=${CT_STATIC_TOOLCHAIN}" )
binutils_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ binutils_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
binutils_opts+=( "build_manuals=${CT_BUILD_MANUALS}" )
do_binutils_backend "${binutils_opts[@]}"
@@ -99,13 +102,15 @@
# host : machine to run on : tuple : (none)
# prefix : prefix to install into : dir : (none)
# static_build : build statcially : bool : no
-# cflags : host cflags to use : string : (empty)
+# cflags : cflags to use : string : (empty)
+# ldflags : ldflags to use : string : (empty)
# build_manuals : whether to build manuals : bool : no
do_binutils_backend() {
local host
local prefix
local static_build
local cflags
+ local ldflags
local build_manuals=no
local -a extra_config
local -a extra_make_flags
@@ -158,6 +163,7 @@
CT_DoExecLog CFG \
CFLAGS="${cflags}" \
CXXFLAGS="${cflags}" \
+ LDFLAGS="${ldflags}" \
"${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure" \
--build=${CT_BUILD} \
--host=${host} \
@@ -49,6 +49,8 @@
elf2flt_opts+=( "host=${CT_BUILD}" )
elf2flt_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
+ elf2flt_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
+ elf2flt_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
elf2flt_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-build-${CT_HOST}" )
do_elf2flt_backend "${elf2flt_opts[@]}"
@@ -68,6 +70,7 @@
elf2flt_opts+=( "prefix=${CT_PREFIX_DIR}" )
elf2flt_opts+=( "static_build=${CT_STATIC_TOOLCHAIN}" )
elf2flt_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ elf2flt_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
elf2flt_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-host-${CT_HOST}" )
do_elf2flt_backend "${elf2flt_opts[@]}"
@@ -102,12 +105,14 @@
# host : machine to run on : tuple : (none)
# prefix : prefix to install into : dir : (none)
# static_build : build statcially : bool : no
-# cflags : host cflags to use : string : (empty)
+# cflags : cflags to use : string : (empty)
+# ldflags : ldflags to use : string : (empty)
do_elf2flt_backend() {
local host
local prefix
local static_build
local cflags
+ local ldflags
local binutils_bld
local binutils_src
local arg
@@ -120,7 +125,8 @@
CT_DoLog EXTRA "Configuring elf2flt"
CT_DoExecLog CFG \
- CFLAGS="${host_cflags}" \
+ CFLAGS="${cflags}" \
+ LDFLAGS="${ldflags}" \
"${CT_SRC_DIR}/elf2flt-${CT_ELF2FLT_VERSION}/configure" \
--build=${CT_BUILD} \
--host=${host} \
@@ -88,6 +88,7 @@
core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" )
core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
core_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ core_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
core_opts+=( "lang_list=c" )
CT_DoStep INFO "Installing pass-1 core C compiler"
@@ -108,6 +109,7 @@
core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" )
core_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ core_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
core_opts+=( "lang_list=c" )
# Different conditions are at stake here:
@@ -155,7 +157,8 @@
# build_libstdcxx : build libstdc++ or not : bool : no
# build_staticlinked : build statically linked or not : bool : no
# build_manuals : whether to build manuals or not : bool : no
-# cflags : host CFLAGS to use : string : (empty)
+# cflags : cflags to use : string : (empty)
+# ldflags : ldflags to use : string : (empty)
# Usage: do_cc_core_backend mode=[static|shared|baremetal] build_libgcc=[yes|no] build_staticlinked=[yes|no]
do_cc_core_backend() {
local mode
@@ -168,6 +171,7 @@
local complibs
local lang_list
local cflags
+ local ldflags
local tmp
local -a host_libstdcxx_flags
local -a extra_config
@@ -226,6 +230,8 @@
else
extra_config+=("--disable-__cxa_atexit")
fi
+
+ core_LDFLAGS+=("${ldflags}")
# *** WARNING ! ***
# Keep this full if-else-if-elif-fi-fi block in sync
@@ -521,6 +527,7 @@
final_opts+=( "prefix=${CT_PREFIX_DIR}" )
final_opts+=( "complibs=${CT_HOST_COMPLIBS_DIR}" )
final_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ final_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
final_opts+=( "lang_list=$( cc_gcc_lang_list )" )
if [ "${CT_BUILD_MANUALS}" = "y" ]; then
final_opts+=( "build_manuals=yes" )
@@ -553,7 +560,8 @@
# host : the host we run onto : tuple : (none)
# prefix : the runtime prefix : dir : (none)
# complibs : the companion libraries prefix : dir : (none)
-# cflags : the host CFLAGS : string : (empty)
+# cflags : cflags to use : string : (empty)
+# ldflags : ldflags to use : string : (empty)
# lang_list : the list of languages to build : string : (empty)
# build_manuals : whether to build manuals or not : bool : no
do_cc_backend() {
@@ -561,6 +569,7 @@
local prefix
local complibs
local cflags
+ local ldflags
local lang_list
local build_manuals
local -a host_libstdcxx_flags
@@ -627,6 +636,8 @@
extra_config+=(--disable-libquadmath-support)
fi
fi
+
+ final_LDFLAGS+=("${ldflags}")
# *** WARNING ! ***
# Keep this full if-else-if-elif-fi-fi block in sync
@@ -37,6 +37,8 @@
gmp_opts+=( "host=${CT_BUILD}" )
gmp_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
+ gmp_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
+ gmp_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
do_gmp_backend "${gmp_opts[@]}"
CT_Popd
@@ -53,6 +55,7 @@
gmp_opts+=( "host=${CT_HOST}" )
gmp_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
gmp_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ gmp_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
do_gmp_backend "${gmp_opts[@]}"
CT_Popd
@@ -63,11 +66,13 @@
# Parameter : description : type : default
# host : machine to run on : tuple : (none)
# prefix : prefix to install into : dir : (none)
-# cflags : host cflags to use : string : (empty)
+# cflags : cflags to use : string : (empty)
+# ldflags : ldflags to use : string : (empty)
do_gmp_backend() {
local host
local prefix
local cflags
+ local ldflags
local arg
for arg in "$@"; do
@@ -78,6 +83,7 @@
CT_DoExecLog CFG \
CFLAGS="${cflags} -fexceptions" \
+ LDFLAGS="${ldflags}" \
"${CT_SRC_DIR}/gmp-${CT_GMP_VERSION}/configure" \
--build=${CT_BUILD} \
--host=${host} \
@@ -80,6 +80,8 @@
mpfr_opts+=( "host=${CT_BUILD}" )
mpfr_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
+ mpfr_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
+ mpfr_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
do_mpfr_backend "${mpfr_opts[@]}"
CT_Popd
@@ -96,6 +98,7 @@
mpfr_opts+=( "host=${CT_HOST}" )
mpfr_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
mpfr_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ mpfr_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
do_mpfr_backend "${mpfr_opts[@]}"
CT_Popd
@@ -106,11 +109,13 @@
# Parameter : description : type : default
# host : machine to run on : tuple : (none)
# prefix : prefix to install into : dir : (none)
-# cflags : host cflags to use : string : (empty)
+# cflags : cflags to use : string : (empty)
+# ldflags : ldflags to use : string : (empty)
do_mpfr_backend() {
local host
local prefix
local cflags
+ local ldflags
local arg
for arg in "$@"; do
@@ -128,7 +133,8 @@
CT_DoLog EXTRA "Configuring MPFR"
CT_DoExecLog CFG \
CC="${host}-gcc" \
- CFLAGS="${CT_CFLAGS_FOR_HOST}" \
+ CFLAGS="${cflags}" \
+ LDFLAGS="${ldflags}" \
"${CT_SRC_DIR}/mpfr-${CT_MPFR_VERSION}/configure" \
--build=${CT_BUILD} \
--host=${host} \
@@ -40,6 +40,8 @@
ppl_opts+=( "host=${CT_BUILD}" )
ppl_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
+ ppl_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
+ ppl_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
do_ppl_backend "${ppl_opts[@]}"
CT_Popd
@@ -56,6 +58,7 @@
ppl_opts+=( "host=${CT_HOST}" )
ppl_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
ppl_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ ppl_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
do_ppl_backend "${ppl_opts[@]}"
CT_Popd
@@ -66,11 +69,13 @@
# Parameter : description : type : default
# host : machine to run on : tuple : (none)
# prefix : prefix to install into : dir : (none)
-# cflags : host cflags to use : string : (empty)
+# cflags : cflags to use : string : (empty)
+# ldflags : ldflags to use : string : (empty)
do_ppl_backend() {
local host
local prefix
local cflags
+ local ldflags
local arg
for arg in "$@"; do
@@ -82,6 +87,7 @@
CT_DoExecLog CFG \
CFLAGS="${cflags}" \
CXXFLAGS="${cflags}" \
+ LDFLAGS="${ldflags}" \
"${CT_SRC_DIR}/ppl-${CT_PPL_VERSION}/configure" \
--build=${CT_BUILD} \
--host=${host} \
@@ -53,6 +53,8 @@
cloog_opts+=( "host=${CT_BUILD}" )
cloog_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
+ cloog_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
+ cloog_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
do_cloog_backend "${cloog_opts[@]}"
CT_Popd
@@ -69,6 +71,7 @@
cloog_opts+=( "host=${CT_HOST}" )
cloog_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
cloog_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ cloog_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
do_cloog_backend "${cloog_opts[@]}"
CT_Popd
@@ -79,11 +82,13 @@
# Parameter : description : type : default
# host : machine to run on : tuple : (none)
# prefix : prefix to install into : dir : (none)
-# cflags : host cflags to use : string : (empty)
+# cflags : cflags to use : string : (empty)
+# ldflags : ldflags to use : string : (empty)
do_cloog_backend() {
local host
local prefix
local cflags
+ local ldflags
local cloog_src_dir="${CT_SRC_DIR}/cloog-ppl-${CT_CLOOG_VERSION}"
local arg
@@ -95,6 +100,7 @@
CT_DoExecLog CFG \
CFLAGS="${cflags}" \
+ LDFLAGS="${ldflags}" \
LIBS="-lm" \
"${cloog_src_dir}/configure" \
--build=${CT_BUILD} \
@@ -38,6 +38,8 @@
mpc_opts+=( "host=${CT_BUILD}" )
mpc_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
+ mpc_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
+ mpc_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
do_mpc_backend "${mpc_opts[@]}"
CT_Popd
@@ -54,6 +56,7 @@
mpc_opts+=( "host=${CT_HOST}" )
mpc_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
mpc_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ mpc_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
do_mpc_backend "${mpc_opts[@]}"
CT_Popd
@@ -64,11 +67,13 @@
# Parameter : description : type : default
# host : machine to run on : tuple : (none)
# prefix : prefix to install into : dir : (none)
-# cflags : host cflags to use : string : (empty)
+# cflags : cflags to use : string : (empty)
+# ldflags : ldflags to use : string : (empty)
do_mpc_backend() {
local host
local prefix
local cflags
+ local ldflags
local arg
for arg in "$@"; do
@@ -79,6 +84,7 @@
CT_DoExecLog CFG \
CFLAGS="${cflags}" \
+ LDFLAGS="${ldflags}" \
"${CT_SRC_DIR}/mpc-${CT_MPC_VERSION}/configure" \
--build=${CT_BUILD} \
--host=${host} \
@@ -38,6 +38,8 @@
libelf_opts+=( "host=${CT_BUILD}" )
libelf_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
+ libelf_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
+ libelf_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
do_libelf_backend "${libelf_opts[@]}"
CT_Popd
@@ -54,6 +56,7 @@
libelf_opts+=( "host=${CT_HOST}" )
libelf_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
libelf_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ libelf_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
do_libelf_backend "${libelf_opts[@]}"
CT_Popd
@@ -87,13 +90,15 @@
# destdir : out-of-tree install dir : string : /
# host : machine to run on : tuple : (none)
# prefix : prefix to install into : dir : (none)
-# cflags : host cflags to use : string : (empty)
+# cflags : cflags to use : string : (empty)
+# ldflags : ldflags to use : string : (empty)
# shared : also buils shared lib : bool : n
do_libelf_backend() {
local destdir="/"
local host
local prefix
local cflags
+ local ldflags
local shared
local -a extra_config
local arg
@@ -114,6 +119,7 @@
CC="${host}-gcc" \
RANLIB="${host}-ranlib" \
CFLAGS="${cflags} -fPIC" \
+ LDFLAGS="${ldflags}" \
"${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure" \
--build=${CT_BUILD} \
--host=${host} \
@@ -488,12 +488,22 @@
rm -f "${tmp}"
fi
- # Help gcc
+ # Help build gcc
+ # Explicitly optimise, else the lines below will overide the
+ # package's default optimisation flags
+ CT_CFLAGS_FOR_BUILD="-O2 -g"
+ CT_CFLAGS_FOR_BUILD+=" ${CT_EXTRA_CFLAGS_FOR_BUILD}"
+ CT_LDFLAGS_FOR_BUILD=
+ CT_LDFLAGS_FOR_BUILD+=" ${CT_EXTRA_LDFLAGS_FOR_BUILD}"
+
+ # Help host gcc
# Explicitly optimise, else the lines below will overide the
# package's default optimisation flags
CT_CFLAGS_FOR_HOST="-O2 -g"
[ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST+=" -pipe"
- CT_CFLAGS_FOR_HOST+=" ${CT_EXTRA_FLAGS_FOR_HOST}"
+ CT_CFLAGS_FOR_HOST+=" ${CT_EXTRA_CFLAGS_FOR_HOST}"
+ CT_LDFLAGS_FOR_HOST=
+ CT_LDFLAGS_FOR_HOST+=" ${CT_EXTRA_LDFLAGS_FOR_HOST}"
# Set the shell to be used by ./configure scripts and by Makefiles (those
# that support it!).
# HG changeset patch # User Yann Diorcet (diorcet.yann@gmail.com) # Date 1353075957 -3600 # Node ID d24043276c9243a35421763b192f4cf59cea650b # Parent 515c5c4635d99ebe4877e1cbb52af227cfd75d5f Add BUILD/HOST extra cflags/ldflags config: Add entry for each flags scripts: Update scripts with new flags Signed-off-by: Yann Diorcet <diorcet.yann@gmail.com> -- For unsubscribe information see http://sourceware.org/lists.html#faq