Skip to content

Commit 4f55f70

Browse files
committed
gcc: Support --enable-multilib-space with CT_MULTILIB_SPACE
When CT_MULTILIB_SPACE is selected, build gcc with the --enable-multilib-space flag. Signed-off-by: Keith Packard <keithp@keithp.com>
1 parent 53da362 commit 4f55f70

File tree

6 files changed

+36
-7
lines changed

6 files changed

+36
-7
lines changed

config/target.in

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,24 @@ config MULTILIB
6262
NOTE: The multilib feature in crosstool-NG is not well-tested.
6363
Use at your own risk, and report success and/or failure.
6464

65+
config MULTILIB_SPACE
66+
bool
67+
prompt "Build both speed and space optimized multilibs"
68+
help
69+
If you say 'y' here, then the toolchain will contain two versions
70+
of every multilib, one optimized for speed (the default) and another
71+
optimized for space. When building with the toolchain, linking with
72+
-Os or -Oz will automatically select the space optimized variant.
73+
74+
# either MULTILIB or MULTILIB_SPACE is set
75+
config MULTILIB_ANY
76+
bool
77+
default y if MULTILIB || MULTILIB_SPACE
78+
6579
config DEMULTILIB
6680
bool "Attempt to combine libraries into a single directory"
67-
default y if !MULTILIB
68-
depends on !MULTILIB || EXPERIMENTAL
81+
default y if !MULTILIB_ANY
82+
depends on !MULTILIB_ANY || EXPERIMENTAL
6983
help
7084
Normally, Crosstool-NG installs the libraries into the directories
7185
as the configure for these libraries determines appropriate. For

scripts/build/binutils/binutils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ do_binutils_for_target() {
346346

347347
[ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
348348
[ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
349-
if [ "${CT_MULTILIB}" = "y" ]; then
349+
if [ "${CT_MULTILIB_ANY}" = "y" ]; then
350350
extra_config+=("--enable-multilib")
351351
else
352352
extra_config+=("--disable-multilib")

scripts/build/cc/gcc.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,9 @@ do_gcc_core_backend() {
584584
extra_config+=("--with-multilib-generator=${CT_CC_GCC_MULTILIB_GENERATOR}")
585585
fi
586586
fi
587+
if [ "${CT_MULTILIB_SPACE}" = "y" ]; then
588+
extra_config+=("--enable-multilib-space")
589+
fi
587590

588591
CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
589592

scripts/build/companion_libs/340-picolibc.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ do_picolibc_common_install() {
2020
CT_DoLog EXTRA "Configuring C library"
2121

2222
# Multilib is the default, so if it is not enabled, disable it.
23-
if [ "${CT_MULTILIB}" != "y" ]; then
23+
if [ "${CT_MULTILIB_ANY}" != "y" ]; then
2424
picolibc_opts+=("-Dmultilib=false")
2525
fi
2626

@@ -66,6 +66,17 @@ NANO_MALLOC:newlib-nano-malloc
6666
[ "${CT_LIBC_PICOLIBC_LTO}" = "y" ] && \
6767
CT_LIBC_PICOLIBC_TARGET_CFLAGS="${CT_LIBC_PICOLIBC_TARGET_CFLAGS} -flto"
6868

69+
# Build picolibc in release mode when doing multilib-space mode as
70+
# we want the default to be release, not minsize; you'll still get
71+
# the -Os version if you link with -Os on the command line due to
72+
# multilib
73+
74+
if [ "${CT_LIBC_PICOLIBC_ENABLE_TARGET_OPTSPACE}" = "y" -a "${CT_MULTILIB_SPACE}" != "y" ]; then
75+
buildtype="minsize"
76+
else
77+
buildtype="release"
78+
fi
79+
6980
cflags_for_target="${CT_ALL_TARGET_CFLAGS} ${CT_LIBC_PICOLIBC_TARGET_CFLAGS}"
7081

7182
# Note: picolibc handles the build/host/target a little bit differently
@@ -113,9 +124,10 @@ EOF
113124
fi
114125

115126
CT_DoExecLog CFG \
116-
meson \
127+
meson setup \
117128
--cross-file picolibc-cross.txt \
118129
--prefix="${picolibc_sysroot_dir}" \
130+
--buildtype="${buildtype}" \
119131
-Dincludedir=include \
120132
-Dlibdir="${picolibc_lib_dir}" \
121133
-Dspecsdir="${CT_SYSROOT_DIR}/lib" \

scripts/build/companion_libs/350-newlib_nano.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ do_newlib_nano_for_target() {
108108
CT_DoLog EXTRA "Configuring Newlib Nano library"
109109

110110
# Multilib is the default, so if it is not enabled, disable it.
111-
if [ "${CT_MULTILIB}" != "y" ]; then
111+
if [ "${CT_MULTILIB_ANY}" != "y" ]; then
112112
newlib_nano_opts+=("-Dmultilib=false")
113113
fi
114114

scripts/build/libc/newlib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ newlib_main()
2929
CT_DoLog EXTRA "Configuring C library"
3030

3131
# Multilib is the default, so if it is not enabled, disable it.
32-
if [ "${CT_MULTILIB}" != "y" ]; then
32+
if [ "${CT_MULTILIB_ANY}" != "y" ]; then
3333
newlib_opts+=("--disable-multilib")
3434
fi
3535

0 commit comments

Comments
 (0)