From 85af58487290a46e7252504f2af808ad3c99d5d4 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sun, 13 Mar 2016 13:21:31 -0700 Subject: Unbreak powerpc-unknown-linux-uclibc. There is invalid assembly in dmalloc for PowerPC. The issue is that 'stw' expects a memory operand, and =g constraint allows both registers and memory. Newer GCC tends to choose register even at -O0, resulting in invalid assembly. Instead, force a register constraint in 'mflr' and let GCC decide if it wants to store it into memory at all. Reported this upstream. Signed-off-by: Alexey Neyman diff --git a/patches/dmalloc/5.5.2/170-ppc-bogus-assembly.patch b/patches/dmalloc/5.5.2/170-ppc-bogus-assembly.patch new file mode 100644 index 0000000..d92bd8a --- /dev/null +++ b/patches/dmalloc/5.5.2/170-ppc-bogus-assembly.patch @@ -0,0 +1,13 @@ +diff -ur dmalloc-5.5.2.orig/return.h dmalloc-5.5.2/return.h +--- dmalloc-5.5.2.orig/return.h 2016-03-13 13:11:48.090431764 -0700 ++++ dmalloc-5.5.2/return.h 2016-03-13 13:12:11.246642618 -0700 +@@ -251,8 +251,7 @@ + + #define GET_RET_ADDR(file) \ + do { \ +- asm("mflr 0"); \ +- asm("stw 0,%0" : "=g" (file)); \ ++ asm("mflr %0" : "=r"(file)); \ + } while(0) + + #endif /* __powerpc__ && __GNUC__ && !__OPTIMIZE__ */ diff --git a/samples/powerpc-unknown-linux-uclibc/broken b/samples/powerpc-unknown-linux-uclibc/broken deleted file mode 100644 index e69de29..0000000 -- cgit v0.10.2-6-g49f6 From 2c7f7cf84784dd86ce03665a7e65de927e03c23e Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sun, 13 Mar 2016 15:40:57 -0700 Subject: Unbreak *-uclibc with native GDB. Currently, native GDB 7.11 fails to build with uClibc-ng due to undefined reference to _obstack_free. On IRC [http://crosstool-ng.osuosl.org/download/ibot-logs/2016-02-28.html], it has been suggested to disable obstack in uClibc configuration. I think it is a workaround rather than a fix: if another library/app needs obstack, this leaves no viable configuration. IMO, if uClibc seeks to mimic the glibc API, it should also provide _obstack_free call (an alias for which it already has, even though commented out). Signed-off-by: Alexey Neyman diff --git a/patches/uClibc-ng/1.0.12/100-provide-_obstack_free.patch b/patches/uClibc-ng/1.0.12/100-provide-_obstack_free.patch new file mode 100644 index 0000000..9fd4bc3 --- /dev/null +++ b/patches/uClibc-ng/1.0.12/100-provide-_obstack_free.patch @@ -0,0 +1,12 @@ +diff -ur uClibc-ng-1.0.12.orig/libc/misc/gnu/obstack.c uClibc-ng-1.0.12/libc/misc/gnu/obstack.c +--- uClibc-ng-1.0.12.orig/libc/misc/gnu/obstack.c 2016-03-13 15:08:44.408962824 -0700 ++++ uClibc-ng-1.0.12/libc/misc/gnu/obstack.c 2016-03-13 15:13:30.129322998 -0700 +@@ -385,7 +385,7 @@ + abort (); + } + +-# if 0 ++# if 1 + /* Older versions of libc used a function _obstack_free intended to be + called by non-GCC compilers. */ + strong_alias (obstack_free, _obstack_free) -- cgit v0.10.2-6-g49f6 From 62d357d3c0756ec0f220e9cf3a874e591548a65c Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 15 Mar 2016 11:51:56 -0700 Subject: Unbreak static cross-gdb. GDB's configure mishandles the libexpat.{so,a} libraries when it is given -static in CFLAGS AND --with-libexpat-prefix in configure's args: it checks for /lib/libexpat.so and finding that, attempts to link it as `gcc -static .. conftest.c /lib/libexpat.so`; this obviously fails (.so cannot be statically linked), so configure assumes libexpat is unusable. Thus, --with-libexpat-prefix is dangerous and should be avoided; instead, configure should find the libraries via the supplied CC/LD definitions. diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh index 418e85c..02a8f7e 100644 --- a/scripts/build/debug/300-gdb.sh +++ b/scripts/build/debug/300-gdb.sh @@ -69,7 +69,11 @@ do_debug_gdb_build() { cross_extra_config=("${extra_config[@]}") cross_extra_config+=("--with-expat") - cross_extra_config+=("--with-libexpat-prefix=${CT_HOST_COMPLIBS_DIR}") + # NOTE: DO NOT USE --with-libexpat-prefix (until GDB configure is smarter)!!! + # It conflicts with a static build: GDB's configure script will find the shared + # version of expat and will attempt to link that, despite the -static flag. + # The link will fail, and configure will abort with "expat missing or unusable" + # message. case "${CT_THREADS}" in none) cross_extra_config+=("--disable-threads");; *) cross_extra_config+=("--enable-threads");; @@ -88,11 +92,11 @@ do_debug_gdb_build() { cross_extra_config+=("--disable-nls") fi - CC_for_gdb= - LD_for_gdb= + CC_for_gdb="${CT_HOST}-gcc ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST}" + LD_for_gdb="${CT_HOST}-ld ${CT_LDFLAGS_FOR_HOST}" if [ "${CT_GDB_CROSS_STATIC}" = "y" ]; then - CC_for_gdb="${CT_HOST}-gcc -static" - LD_for_gdb="${CT_HOST}-ld -static" + CC_for_gdb+=" -static" + LD_for_gdb+=" -static" fi # Disable binutils options when building from the binutils-gdb repo. @@ -162,6 +166,11 @@ do_debug_gdb_build() { fi native_extra_config+=("--with-expat") + # NOTE: DO NOT USE --with-libexpat-prefix (until GDB configure is smarter)!!! + # It conflicts with a static build: GDB's configure script will find the shared + # version of expat and will attempt to link that, despite the -static flag. + # The link will fail, and configure will abort with "expat missing or unusable" + # message. CT_DoLog EXTRA "Configuring native gdb" diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in index 9297e3b..3c193c3 100644 --- a/scripts/crosstool-NG.sh.in +++ b/scripts/crosstool-NG.sh.in @@ -509,6 +509,8 @@ if [ -z "${CT_RESTART}" ]; then CT_CFLAGS_FOR_HOST+=" ${CT_EXTRA_CFLAGS_FOR_HOST}" CT_LDFLAGS_FOR_HOST= CT_LDFLAGS_FOR_HOST+=" ${CT_EXTRA_LDFLAGS_FOR_HOST}" + CT_CFLAGS_FOR_HOST+=" -I${CT_HOST_COMPLIBS_DIR}/include" + CT_LDFLAGS_FOR_HOST+=" -L${CT_HOST_COMPLIBS_DIR}/lib" CT_DoLog DEBUG "CFLAGS for host compiler: '${CT_CFLAGS_FOR_HOST}'" CT_DoLog DEBUG "LDFLAGS for host compiler: '${CT_LDFLAGS_FOR_HOST}'" -- cgit v0.10.2-6-g49f6 From 7ac327d6c33fa78f194e816beec0796901f5d002 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 15 Mar 2016 12:23:57 -0700 Subject: Remove --with-expat from extra GDB args. 300-gdb.sh always adds --with-expat, no need to list it in crosstool.config. Signed-off-by: Alexey Neyman diff --git a/samples/aarch64-rpi3-linux-gnueabi/crosstool.config b/samples/aarch64-rpi3-linux-gnueabi/crosstool.config index 7c880c4..2bbece8 100644 --- a/samples/aarch64-rpi3-linux-gnueabi/crosstool.config +++ b/samples/aarch64-rpi3-linux-gnueabi/crosstool.config @@ -11,4 +11,3 @@ CT_BINUTILS_LD_WRAPPER=y CT_BINUTILS_PLUGINS=y CT_CC_LANG_CXX=y CT_DEBUG_gdb=y -CT_GDB_CROSS_EXTRA_CONFIG_ARRAY="--with-expat" diff --git a/samples/aarch64-unknown-linux-gnueabi/crosstool.config b/samples/aarch64-unknown-linux-gnueabi/crosstool.config index 90a2ccc..20b8509 100644 --- a/samples/aarch64-unknown-linux-gnueabi/crosstool.config +++ b/samples/aarch64-unknown-linux-gnueabi/crosstool.config @@ -11,4 +11,3 @@ CT_BINUTILS_LD_WRAPPER=y CT_BINUTILS_PLUGINS=y CT_CC_LANG_CXX=y CT_DEBUG_gdb=y -CT_GDB_CROSS_EXTRA_CONFIG_ARRAY="--with-expat" diff --git a/samples/armv7-rpi2-linux-gnueabihf/crosstool.config b/samples/armv7-rpi2-linux-gnueabihf/crosstool.config index 3c2e478..d56a4f4 100644 --- a/samples/armv7-rpi2-linux-gnueabihf/crosstool.config +++ b/samples/armv7-rpi2-linux-gnueabihf/crosstool.config @@ -12,4 +12,3 @@ CT_BINUTILS_LD_WRAPPER=y CT_BINUTILS_PLUGINS=y CT_CC_LANG_CXX=y CT_DEBUG_gdb=y -CT_GDB_CROSS_EXTRA_CONFIG_ARRAY="--with-expat" diff --git a/samples/armv8-rpi3-linux-gnueabihf/crosstool.config b/samples/armv8-rpi3-linux-gnueabihf/crosstool.config index 2a0ad43..043cc6f 100644 --- a/samples/armv8-rpi3-linux-gnueabihf/crosstool.config +++ b/samples/armv8-rpi3-linux-gnueabihf/crosstool.config @@ -12,4 +12,3 @@ CT_BINUTILS_LD_WRAPPER=y CT_BINUTILS_PLUGINS=y CT_CC_LANG_CXX=y CT_DEBUG_gdb=y -CT_GDB_CROSS_EXTRA_CONFIG_ARRAY="--with-expat" -- cgit v0.10.2-6-g49f6 From 712b617a744aa941b99d32d9ff6d9126c77382fb Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 15 Mar 2016 12:39:03 -0700 Subject: Unbreak sparc-unknown-linux-gnu. GLIBC 2.23 dropped support for pre-v9 SPARC in pthreads. Pass host triplet with s/sparc/sparcv9/ replacement for 2.23. Signed-off-by: Alexey Neyman diff --git a/config/libc/glibc.in b/config/libc/glibc.in index fc7c85b..96879cc 100644 --- a/config/libc/glibc.in +++ b/config/libc/glibc.in @@ -74,7 +74,7 @@ choice config LIBC_GLIBC_V_2_23 bool prompt "2.23" - select LIBC_GLIBC_2_20_or_later + select LIBC_GLIBC_2_23_or_later config LIBC_GLIBC_V_2_22 bool @@ -109,6 +109,11 @@ endchoice endif # ! LIBC_GLIBC_CUSTOM +# Checked by SPARC build: SPARCv8 is dropped in 2.23. +config LIBC_GLIBC_2_23_or_later + select LIBC_GLIBC_2_20_or_later + bool + # DeMark 2.20 as no longer needs to set NPTL as an addon. # It is no longer possible to build glibc without pthread! config LIBC_GLIBC_2_20_or_later diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index 0a09cbd..013c6eb 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -73,6 +73,7 @@ do_libc_backend() { local multi_dir local multi_flags local extra_dir + local target local libc_headers libc_startfiles libc_full local hdr local arg @@ -136,11 +137,24 @@ do_libc_backend() { CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}${extra_dir//\//_}" + target=${CT_TARGET} + case "${target}" in + # SPARC quirk: glibc 2.23 and newer dropped support for SPARCv8 and + # earlier (corresponding pthread barrier code is missing). Until this + # support is reintroduced, configure as sparcv9. + sparc-*) + if [ "${CT_LIBC_GLIBC_2_23_or_later}" = y ]; then + target=${target/#sparc-/sparcv9-} + fi + ;; + esac + do_libc_backend_once extra_dir="${extra_dir}" \ extra_flags="${extra_flags}" \ libc_headers="${libc_headers}" \ libc_startfiles="${libc_startfiles}" \ - libc_full="${libc_full}" + libc_full="${libc_full}" \ + target="${target}" CT_Popd @@ -192,6 +206,7 @@ do_libc_backend_once() { local glibc_cflags local float_extra local endian_extra + local target local arg for arg in "$@"; do @@ -341,7 +356,7 @@ do_libc_backend_once() { "${src_dir}/configure" \ --prefix=/usr \ --build=${CT_BUILD} \ - --host=${CT_TARGET} \ + --host=${target} \ --cache-file="$(pwd)/config.cache" \ --without-cvs \ --disable-profile \ -- cgit v0.10.2-6-g49f6 From cc7f7db7676b828ec3f75cea6463e62f44d1c519 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 15 Mar 2016 18:52:05 -0700 Subject: Mark x86_64-w64-mingw32,x86_64-pc-linux-gnu broken. I couldn't get this sample to build. I tried rolling ct-ng back to 1.22 and back to the commit that introduced it, to no avail. Not sure if it ever built on my machine. The first problem is the failure to build binutils/gold because of the missing in mingw. However, even if CT_BINUTILS_GOLD_THREADS option is unset, the build dies in configure of the pass-1 of the core CC. The config.log states that it failed to link with libmpfr.a, which has a lot of undefined references to symbols like '__imp___iob_func'. Googling shows that these symbols are some dark Cygwin/MinGW magic and I do not have the knowledge of these arcana. Let some other MinGWizard fix it another day. Signed-off-by: Alexey Neyman diff --git a/samples/x86_64-w64-mingw32,x86_64-pc-linux-gnu/broken b/samples/x86_64-w64-mingw32,x86_64-pc-linux-gnu/broken new file mode 100644 index 0000000..e69de29 diff --git a/samples/x86_64-w64-mingw32,x86_64-pc-linux-gnu/crosstool.config b/samples/x86_64-w64-mingw32,x86_64-pc-linux-gnu/crosstool.config index 10ed299..304ad60 100644 --- a/samples/x86_64-w64-mingw32,x86_64-pc-linux-gnu/crosstool.config +++ b/samples/x86_64-w64-mingw32,x86_64-pc-linux-gnu/crosstool.config @@ -1,6 +1,4 @@ CT_EXPERIMENTAL=y -CT_DEBUG_CT=y -CT_DEBUG_CT_SAVE_STEPS=y CT_LOCAL_TARBALLS_DIR="${HOME}/src" CT_SAVE_TARBALLS=y # CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES is not set -- cgit v0.10.2-6-g49f6 From 2162cbbdb7a425505e66f8b65f134c33302324f4 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Wed, 16 Mar 2016 11:41:55 -0700 Subject: Work-around another quirk in GDB configure. Previous fix for cross-gdb broke powerpc-unknown_nofpu-linux-gnu which uses an old GDB (6.8a). That GDB's configure chokes on $CC values with multiple consecutive spaces; see the comment in 300-gdb.sh. Signed-off-by: Alexey Neyman diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh index 02a8f7e..ee4753e 100644 --- a/scripts/build/debug/300-gdb.sh +++ b/scripts/build/debug/300-gdb.sh @@ -99,10 +99,17 @@ do_debug_gdb_build() { LD_for_gdb+=" -static" fi - # Disable binutils options when building from the binutils-gdb repo. - cross_extra_config+=("--disable-binutils") - cross_extra_config+=("--disable-ld") - cross_extra_config+=("--disable-gas") + # Fix up whitespace. Some older GDB releases (e.g. 6.8a) get confused if there + # are multiple consecutive spaces: sub-configure scripts replace them with a + # single space and then complain that $CC value changed from that in + # the master directory. + CC_for_gdb=`echo $CC_for_gdb` + LD_for_gdb=`echo $LD_for_gdb` + + # Disable binutils options when building from the binutils-gdb repo. + cross_extra_config+=("--disable-binutils") + cross_extra_config+=("--disable-ld") + cross_extra_config+=("--disable-gas") CT_DoLog DEBUG "Extra config passed: '${cross_extra_config[*]}'" -- cgit v0.10.2-6-g49f6