Add -D__GLIBC__ to target CFLAGS

... when using musl to compile strace.

Also, honor CT_TARGET_CFLAGS in scripts compiling target libs/binaries.

Signed-off-by: Alexey Neyman <stilor@att.net>
This commit is contained in:
Alexey Neyman 2017-09-30 18:47:35 -07:00
parent 4c321260b2
commit ca45a8f9ab
7 changed files with 45 additions and 17 deletions

1
TODO
View File

@ -2,6 +2,7 @@ A (slightly) ordered set of tasks for crosstool-NG. Written in a cryptic languag
-- Alexey Neyman (@stilor)
[ ] Migrate .config and build.log into per-target directory, make top-level file into symlinks - this will allow to compare/debug multiple configs side-by-side without overwriting each other
[ ] Need a variant of CT_DoExecLog that only captures stderr - for use where we need stdout for further processing but want to capture errors
[ ] Use in test-package.sh
[ ] mirror: remove crosstool-ng.org mirroring of archives? Use the option only for local mirrors? Archives currently hosted are outdated.

View File

@ -81,6 +81,7 @@ do_libelf_for_target() {
libelf_opts+=( "destdir=${CT_SYSROOT_DIR}" )
libelf_opts+=( "host=${CT_TARGET}" )
libelf_opts+=( "cflags=${CT_TARGET_CFLAGS}" )
libelf_opts+=( "prefix=${prefix}" )
libelf_opts+=( "shared=${CT_SHARED_LIBS}" )
do_libelf_backend "${libelf_opts[@]}"

View File

@ -54,6 +54,7 @@ do_expat_for_target() {
prefix="/usr"
;;
esac
expat_opts+=( "cflags=${CT_TARGET_CFLAGS}" )
expat_opts+=( "prefix=${prefix}" )
expat_opts+=( "destdir=${CT_SYSROOT_DIR}" )
expat_opts+=( "shared=${CT_SHARED_LIBS}" )

View File

@ -96,6 +96,7 @@ do_ncurses_for_target() {
prefix="${prefix}" \
destdir="${CT_SYSROOT_DIR}" \
shared="${CT_SHARED_LIBS}" \
cflags="${CT_TARGET_CFLAGS}" \
"${opts[@]}"
CT_Popd
CT_EndStep

View File

@ -19,8 +19,8 @@ do_debug_duma_build() {
make_args=(
prefix="${CT_DEBUGROOT_DIR}/usr"
HOSTCC="${CT_BUILD}-gcc"
CC="${CT_TARGET}-${CT_CC}"
CXX="${CT_TARGET}-g++"
CC="${CT_TARGET}-${CT_CC} ${CT_TARGET_CFLAGS}"
CXX="${CT_TARGET}-g++ ${CT_TARGET_CFLAGS}"
RANLIB="${CT_TARGET}-ranlib"
OS="${CT_KERNEL}"
)

View File

@ -13,11 +13,6 @@ do_debug_gdb_build() {
gdb_src_dir="${CT_SRC_DIR}/gdb"
# Version 6.3 and below behave badly with gdbmi
case "${CT_GDB_VERSION}" in
6.2*|6.3) extra_config+=("--disable-gdbmi");;
esac
if [ "${CT_GDB_HAS_PKGVERSION_BUGURL}" = "y" ]; then
[ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
[ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
@ -219,15 +214,19 @@ do_debug_gdb_build() {
[ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ] && \
native_extra_config+=("--disable-nls")
CPP_for_gdb="${CT_TARGET}-cpp"
CC_for_gdb="${CT_TARGET}-${CT_CC}"
CXX_for_gdb="${CT_TARGET}-g++"
LD_for_gdb="${CT_TARGET}-ld"
CPP_for_gdb="${CT_TARGET}-cpp ${CT_TARGET_CFLAGS}"
CC_for_gdb="${CT_TARGET}-${CT_CC} ${CT_TARGET_CFLAGS} ${CT_TARGET_LDFLAGS}"
CXX_for_gdb="${CT_TARGET}-g++ ${CT_TARGET_CFLAGS} ${CT_TARGET_LDFLAGS}"
LD_for_gdb="${CT_TARGET}-ld ${CT_TARGET_LDFLAGS}"
if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then
CC_for_gdb+=" -static"
CXX_for_gdb+=" -static"
LD_for_gdb+=" -static"
fi
CPP_for_gdb=`echo $CPP_for_gdb`
CC_for_gdb=`echo $CC_for_gdb`
CXX_for_gdb=`echo $CXX_for_gdb`
LD_for_gdb=`echo $LD_for_gdb`
export ac_cv_func_strncmp_works=yes
@ -321,13 +320,23 @@ do_debug_gdb_build() {
gdbserver_extra_config+=("--disable-ld")
gdbserver_extra_config+=("--disable-gas")
CPP_for_gdb="${CT_TARGET}-cpp ${CT_TARGET_CFLAGS}"
CC_for_gdb="${CT_TARGET}-${CT_CC} ${CT_TARGET_CFLAGS} ${CT_TARGET_LDFLAGS}"
CXX_for_gdb="${CT_TARGET}-g++ ${CT_TARGET_CFLAGS} ${CT_TARGET_LDFLAGS}"
LD_for_gdb="${CT_TARGET}-ld ${CT_TARGET_LDFLAGS}"
CPP_for_gdb=`echo $CPP_for_gdb`
CC_for_gdb=`echo $CC_for_gdb`
CXX_for_gdb=`echo $CXX_for_gdb`
LD_for_gdb=`echo $LD_for_gdb`
CT_DoExecLog CFG \
CC_FOR_BUILD="${CT_BUILD}-gcc" \
CFLAGS_FOR_BUILD="${CT_CFLAGS_FOR_BUILD}" \
LDFLAGS_FOR_BUILD="${CT_LDFLAGS_FOR_BUILD}" \
CC="${CT_TARGET}-${CT_CC}" \
CPP="${CT_TARGET}-cpp" \
LD="${CT_TARGET}-ld" \
CPP="${CPP_for_gdb}" \
CC="${CC_for_gdb}" \
CXX="${CXX_for_gdb}" \
LD="${LD_for_gdb}" \
LDFLAGS="${gdbserver_LDFLAGS}" \
${CONFIG_SHELL} \
"${gdb_src_dir}/gdb/gdbserver/configure" \

View File

@ -1,21 +1,36 @@
# Build script for strace
do_debug_strace_get() {
do_debug_strace_get()
{
CT_Fetch STRACE
}
do_debug_strace_extract() {
do_debug_strace_extract()
{
CT_ExtractPatch STRACE
}
do_debug_strace_build() {
do_debug_strace_build()
{
local cflags="${CT_TARGET_CFLAGS}"
CT_DoStep INFO "Installing strace"
if [ "${CT_LIBC_MUSL}" = "y" ]; then
# Otherwise kernel headers cause errors when included, e.g.
# <netinet/in.h> and <linux/in6.h>. Kernel's libc-compat.h
# only cares about GLIBC. uClibc-ng does the same
# internally, pretending it's GLIBC for kernel headers inclusion.
cflags+=" -D__GLIBC__"
fi
CT_mkdir_pushd "${CT_BUILD_DIR}/build-strace"
CT_DoLog EXTRA "Configuring strace"
CT_DoExecLog CFG \
CC="${CT_TARGET}-${CT_CC}" \
CFLAGS="${cflags}" \
LDFLAGS="${CT_TARGET_LDFLAGS}" \
CPP="${CT_TARGET}-cpp" \
LD="${CT_TARGET}-ld" \
${CONFIG_SHELL} \