Skip to content

Commit 88fe335

Browse files
committed
Specify header path in CT_CC_SYSROOT_ARG only for glibc
When building a non-sysrooted toolchain, `--with-headers` argument is specified in `CT_CC_SYSROOT_ARG` as a hack, supposedly because "final gcc will define disable_glibc while building libgcc, and you'll have no profiling." This, however, leads to `--with-headers` being specified multiple times when building libstdc++ for additional libc variants (e.g. newlib-nano and picolibc) and results in wrong libc headers being used by the libstdc++ build under certain circumstances -- GCC does not use the last specified `--with-headers` when building for macOS and Windows hosts. Since the above hack is intended for glibc only, this commit adds a check to ensure that `--with-headers` is added to `CT_CC_SYSROOT_ARG` only when building glibc. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent d43d7bf commit 88fe335

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

scripts/crosstool-NG.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,12 @@ if [ -z "${CT_RESTART}" ]; then
361361
# binutils 2.14 and later obey it, older binutils ignore it.
362362
# Lets you build a working 32->64 bit cross gcc
363363
CT_BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
364-
# Use --with-headers, else final gcc will define disable_glibc while
365-
# building libgcc, and you'll have no profiling
366364
CT_CC_CORE_SYSROOT_ARG="--without-headers"
367-
CT_CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
365+
if [ "${CT_LIBC_GLIBC}" = "y" ]; then
366+
# Use --with-headers, else final gcc will define disable_glibc while
367+
# building libgcc, and you'll have no profiling
368+
CT_CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
369+
fi
368370
fi
369371
CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}"
370372
CT_DoExecLog ALL mkdir -p "${CT_DEBUGROOT_DIR}"

0 commit comments

Comments
 (0)