summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephanos Ioannidis <root@stephanos.io>2019-11-29 16:42:18 (GMT)
committerStephanos Ioannidis <root@stephanos.io>2021-06-07 10:52:58 (GMT)
commit3c637c1eec9fe05c48bcd40186c7831933c2d6f2 (patch)
tree88782b2ee55ae918018d01e203789a4257c4ed50 /scripts
parent6dd60ca6947395b41e09fcf2488066651fb8119a (diff)
gcc: Assume '-O2' by default for building gcc target libraries
The gcc target libraries (e.g. libstdc++) are currently built without any optimisation flag when `CT_CC_GCC_ENABLE_TARGET_OPTSPACE` is not enabled and default to `-O0` unless user explicitly specifies an optimisation flag. This commit updates the gcc build script to assume `-O2` for building target libraries unless user provides a different optimisation flag. Note also that this is the default behaviour for gcc when C[XX]FLAGS_FOR_TARGET is not overridden. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build/cc/gcc.sh14
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh
index cccd654..39c70bb 100644
--- a/scripts/build/cc/gcc.sh
+++ b/scripts/build/cc/gcc.sh
@@ -608,6 +608,9 @@ do_gcc_core_backend() {
cflags_for_target="${cflags_for_target} -idirafter ${CT_HEADERS_DIR}"
fi
+ # Assume '-O2' by default for building target libraries.
+ cflags_for_target="-g -O2 ${cflags_for_target}"
+
# Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532).
# Pass only user-specified CFLAGS/LDFLAGS in CFLAGS_FOR_TARGET/LDFLAGS_FOR_TARGET: during
# the build of, for example, libatomic, GCC tried to compile multiple variants for runtime
@@ -936,6 +939,7 @@ do_gcc_backend() {
local lang_list
local cflags
local cflags_for_build
+ local cflags_for_target
local ldflags
local build_manuals
local exec_prefix
@@ -1200,8 +1204,9 @@ do_gcc_backend() {
CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
- # We may need to modify host/build CFLAGS separately below
+ # We may need to modify host/build/target CFLAGS separately below
cflags_for_build="${cflags}"
+ cflags_for_target="${CT_TARGET_CFLAGS}"
# Clang's default bracket-depth is 256, and building GCC
# requires somewhere between 257 and 512.
@@ -1217,6 +1222,9 @@ do_gcc_backend() {
fi
fi
+ # Assume '-O2' by default for building target libraries.
+ cflags_for_target="-g -O2 ${cflags_for_target}"
+
# NB: not using CT_ALL_TARGET_CFLAGS/CT_ALL_TARGET_LDFLAGS here!
# See do_gcc_core_backend for explanation.
CT_DoExecLog CFG \
@@ -1226,8 +1234,8 @@ do_gcc_backend() {
CXXFLAGS="${cflags}" \
CXXFLAGS_FOR_BUILD="${cflags_for_build}" \
LDFLAGS="${final_LDFLAGS[*]}" \
- CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
- CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
+ CFLAGS_FOR_TARGET="${cflags_for_target}" \
+ CXXFLAGS_FOR_TARGET="${cflags_for_target}" \
LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \
${CONFIG_SHELL} \
"${CT_SRC_DIR}/gcc/configure" \