diff options
author | Stephanos Ioannidis <root@stephanos.io> | 2021-06-07 14:42:06 +0900 |
---|---|---|
committer | Stephanos Ioannidis <root@stephanos.io> | 2021-06-07 19:53:28 +0900 |
commit | fffa4c5aa5b5995ce88680170fb2288b10b05fbe (patch) | |
tree | 1f879b68ee8ece92e5720cf319c4228983975947 /scripts | |
parent | 3c637c1eec9fe05c48bcd40186c7831933c2d6f2 (diff) | |
download | crosstool-ng-fffa4c5aa5b5995ce88680170fb2288b10b05fbe.tar.gz crosstool-ng-fffa4c5aa5b5995ce88680170fb2288b10b05fbe.tar.bz2 crosstool-ng-fffa4c5aa5b5995ce88680170fb2288b10b05fbe.zip |
gcc: Allow setting custom target CXXFLAGS
This commit adds two additional arguments (`cxxflags_for_target` and
`extra_cxxflags_for_target`) for the gcc backend build function that
can be used to specify custom target CXXFLAGS.
By default, the target CXXFLAGS is set to the target CFLAGS. When
`cxxflags_for_target` is specified however, it overrides that behaviour
and allows setting different target CXXFLAGS from the target CFLAGS.
The `extra_cxxflags_for_target` argument can be used to specify the
extra target CXXFLAGS to be appended to the target CXXFLAGS. This is
useful when it is necessary to append CXX-specific flags to the
existing CFLAGS to be used as the target CXXFLAGS.
A useful application of this is building full and nano versions of
libstdc++ with different target CXXFLAGS as necessitated by
`nano.specs`.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/build/cc/gcc.sh | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh index 39c70bb6..dc391e47 100644 --- a/scripts/build/cc/gcc.sh +++ b/scripts/build/cc/gcc.sh @@ -295,7 +295,8 @@ do_gcc_core_backend() { local enable_optspace local complibs local lang_list - local cflags cflags_for_build cflags_for_target + local cflags cflags_for_build cflags_for_target cxxflags_for_target + local extra_cxxflags_for_target local ldflags local build_step local log_txt @@ -611,6 +612,16 @@ do_gcc_core_backend() { # Assume '-O2' by default for building target libraries. cflags_for_target="-g -O2 ${cflags_for_target}" + # Set target CXXFLAGS to CFLAGS if none is provided. + if [ -z "${cxxflags_for_target}" ]; then + cxxflags_for_target="${cflags_for_target}" + fi + + # Append extra CXXFLAGS if provided. + if [ -n "${extra_cxxflags_for_target}" ]; then + cxxflags_for_target="${cxxflags_for_target} ${extra_cxxflags_for_target}" + fi + # 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 @@ -624,7 +635,7 @@ do_gcc_core_backend() { CXXFLAGS_FOR_BUILD="${cflags_for_build}" \ LDFLAGS="${core_LDFLAGS[*]}" \ CFLAGS_FOR_TARGET="${cflags_for_target}" \ - CXXFLAGS_FOR_TARGET="${cflags_for_target}" \ + CXXFLAGS_FOR_TARGET="${cxxflags_for_target}" \ LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \ ${CONFIG_SHELL} \ "${CT_SRC_DIR}/gcc/configure" \ @@ -940,6 +951,8 @@ do_gcc_backend() { local cflags local cflags_for_build local cflags_for_target + local cxxflags_for_target + local extra_cxxflags_for_target local ldflags local build_manuals local exec_prefix @@ -1225,6 +1238,16 @@ do_gcc_backend() { # Assume '-O2' by default for building target libraries. cflags_for_target="-g -O2 ${cflags_for_target}" + # Set target CXXFLAGS to CFLAGS if none is provided. + if [ -z "${cxxflags_for_target}" ]; then + cxxflags_for_target="${cflags_for_target}" + fi + + # Append extra CXXFLAGS if provided. + if [ -n "${extra_cxxflags_for_target}" ]; then + cxxflags_for_target="${cxxflags_for_target} ${extra_cxxflags_for_target}" + fi + # NB: not using CT_ALL_TARGET_CFLAGS/CT_ALL_TARGET_LDFLAGS here! # See do_gcc_core_backend for explanation. CT_DoExecLog CFG \ @@ -1235,7 +1258,7 @@ do_gcc_backend() { CXXFLAGS_FOR_BUILD="${cflags_for_build}" \ LDFLAGS="${final_LDFLAGS[*]}" \ CFLAGS_FOR_TARGET="${cflags_for_target}" \ - CXXFLAGS_FOR_TARGET="${cflags_for_target}" \ + CXXFLAGS_FOR_TARGET="${cxxflags_for_target}" \ LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \ ${CONFIG_SHELL} \ "${CT_SRC_DIR}/gcc/configure" \ |