[PATCH] gcc: Add option to build final-gcc with sysroot option

Carmelo AMOROSO carmelo.amoroso at st.com
Mon Nov 23 09:38:24 UTC 2009


Add gcc config option BR2_GCC_FINAL_NEEDS_SYSROOT to build cross gcc
(final stage) with --with-sysroot option.
This is required to allow libgcc to use the correct the correct unwind
functions implementation with NPTL.

Indeed, if sysroot is not used, the inhibit_libc macro is defined
for the LIBGCC2_CFLAGS (see gcc/configure)

inhibit_libc=false
if { { test x$host != x$target && test "x$with_sysroot" = x ; } ||
       test x$with_newlib = xyes ; } &&
     { test "x$with_headers" = x || test "x$with_headers" = xno ; } ; then
       inhibit_libc=true
fi

If inhibit_libc is defined, the actual implementation of unwind functions
are taken from unwind-dw2-fde-c instead of the correct unwind-dw2-fde-glibc.c
as required for NPTL case.

Signed-off-by: Carmelo Amoroso <carmelo.amoroso at st.com>
---
 toolchain/gcc/Config.in         |    8 ++++++++
 toolchain/gcc/gcc-uclibc-3.x.mk |   10 ++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/toolchain/gcc/Config.in b/toolchain/gcc/Config.in
index 7e58516..ef87915 100644
--- a/toolchain/gcc/Config.in
+++ b/toolchain/gcc/Config.in
@@ -110,6 +110,14 @@ config BR2_GCC_USE_SJLJ_EXCEPTIONS
 	  proper stack unwinding during exception handling.  Most people
 	  can leave this set to n.
 
+config BR2_GCC_FINAL_NEEDS_SYSROOT
+	bool "Gcc (final stage) needs sysroot to be set"
+	default n
+	help
+	  If enabled, gcc (final stage) will be configured with --with-sysroot
+	  set to $(STAGING_DIR) where uClibc runtime system has been installed.
+	  This is required for building a toolchain working with uClibc NPTL.
+
 config BR2_EXTRA_GCC_CONFIG_OPTIONS
 	string "Additional gcc options"
 	default ""
diff --git a/toolchain/gcc/gcc-uclibc-3.x.mk b/toolchain/gcc/gcc-uclibc-3.x.mk
index 6531bfc..386600c 100644
--- a/toolchain/gcc/gcc-uclibc-3.x.mk
+++ b/toolchain/gcc/gcc-uclibc-3.x.mk
@@ -227,7 +227,16 @@ gcc_initial-dirclean:
 # guarantees. mjn3
 
 GCC_BUILD_DIR2:=$(TOOLCHAIN_DIR)/gcc-$(GCC_VERSION)-final
+
+# Configure second pass compiler to use sysroot
+# set to STAGING_DIR
+#
+ifeq ($(strip $(BR2_GCC_FINAL_NEEDS_SYSROOT)),y)
+GCC_FINAL_NEEDS_SYSROOT:=--with-sysroot=$(STAGING_DIR)
+endif
+
 $(GCC_BUILD_DIR2)/.configured: $(GCC_DIR)/.patched $(GCC_STAGING_PREREQ)
+	echo GCC_FINAL_NEEDS_SYSROOT=$(GCC_FINAL_NEEDS_SYSROOT)
 	mkdir -p $(GCC_BUILD_DIR2)
 	# Important! Required for limits.h to be fixed.
 	ln -snf ../include $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/sys-include
@@ -258,6 +267,7 @@ $(GCC_BUILD_DIR2)/.configured: $(GCC_DIR)/.patched $(GCC_STAGING_PREREQ)
 		$(GCC_WITH_ABI) $(GCC_WITH_ARCH) $(GCC_WITH_TUNE) \
 		$(GCC_USE_SJLJ_EXCEPTIONS) \
 		$(DISABLE_LARGEFILE) \
+		$(GCC_FINAL_NEEDS_SYSROOT) \
 		$(EXTRA_GCC_CONFIG_OPTIONS) \
 	)
 	touch $@
-- 
1.6.0.6



More information about the uClibc mailing list