Skip to contentSkip to conversation

Toolchain updates

PATCH Superseded Thomas Petazzoni 3 participants 18 messages Aug 28, 2013 – Aug 29, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Toolchain updates

Hello,

Here is a set of updates/improvements to the internal toolchain backend (with some impacts on the external toolchain one). Mainly it:

* Allows to build the toolchain with only two passes of gcc build as opposed to three. Of course, this is only possible in the appropriate situations. This patch had already been posted previously to the list, and was rebased on top of current master.

* Fixes Fortran and Objective-C support, moves the C++ option close to the one for Fortran and Objective-C.

* Adds support for glibc, in addition to eglibc. Note that as suggested by Arnout, I'm proposing a single package to handle both libraries.

* Refactors the Stack Smashing Protection support.

* Refactors the Mudflap support. Note however that I didn't manage to get a Busybox system with mudflap enabled to boot. I am personaly not that much interested in mudflap support, so unless someone steps up to look at the issue, I think I'll propose to remove Mudflap support entirely.

* Makes a small number of related cleanups.

Thomas Petazzoni (12):
package/Makefile.in: fix incorrect comment
eglibc: libstdc++ is not part of the C library
toolchain-internal: skip gcc-intermediate when possible
gcc: fix Fortran support
gcc: fix Objective-C support
gcc: move C++ support option next to Fortran/Objective-C
toolchain: add support for glibc
gcc/gcc-final: use the common HOST_GCC_CONFIGURE_SYMLINK macro
gcc: force symlink creation
toolchain: refactor Stack Smashing Protection support
toolchain: move elf2flt option inclusion to
toolchain-buildroot/Config.in
toolchain: improve mudflap support

 Config.in                                    | 37 +++++++++++++++
 package/Makefile.in                          | 17 +++++--
 package/gcc/Config.in.host                   | 53 ++++++++++++++++++---
 package/gcc/gcc-final/gcc-final.mk           | 31 ++++++++----
 package/gcc/gcc-initial/gcc-initial.mk       |  8 ++++
 package/gcc/gcc.mk                           |  8 +++-
 package/{eglibc/eglibc.mk => glibc/glibc.mk} | 70 ++++++++++++++++------------
 package/psmisc/psmisc.mk                     |  2 +-
 package/uclibc/Config.in                     | 11 +++++
 package/uclibc/uclibc.mk                     |  5 +-
 toolchain/Config.in                          | 11 ++++-
 toolchain/helpers.mk                         | 15 +++++-
 toolchain/toolchain-buildroot/Config.in      | 25 +++++++++-
 toolchain/toolchain-buildroot/Config.in.2    | 31 ------------
 toolchain/toolchain-common.in                |  6 +++
 toolchain/toolchain-external/Config.in       | 18 +++++++
 toolchain/toolchain-external/ext-tool.mk     | 11 +++++
 17 files changed, 270 insertions(+), 89 deletions(-)
 rename package/{eglibc/eglibc.mk => glibc/glibc.mk} (58%)
 delete mode 100644 toolchain/toolchain-buildroot/Config.in.2
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/12 package/Makefile.in: fix incorrect comment

The TARGET_{CC,CXX,LD,...} variables no longer contain any --sysroot option, since we're now using a toolchain wrapper for external toolchains.

---
 package/Makefile.in | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
package/Makefile.in +1 -2
index 91ae1b9..0b1c33a 100644
@@ -143,8 +143,7 @@ endif
 # Quotes are needed for spaces et al in path components.
 TARGET_PATH="$(HOST_DIR)/bin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin/:$(PATH)"
 
-# Define TARGET_xx variables for all common binutils/gcc tools by
-# including the --sysroot option where necessary.
+# Define TARGET_xx variables for all common binutils/gcc
 TARGET_AR       = $(TARGET_CROSS)ar
 TARGET_AS       = $(TARGET_CROSS)as
 TARGET_CC       = $(TARGET_CROSS)gcc
Signature · 1 line
1.8.1.2
#2 lore raw

PATCH 2/12 eglibc: libstdc++ is not part of the C library

In reply to Thomas Petazzoni

For some reason, the eglibc.mk file was trying to install libstdc++.so from eglibc to the target. But the C++ standard library is provided by GCC, not by the C library.

---
 package/eglibc/eglibc.mk | 7 -------
 1 file changed, 7 deletions(-)
package/eglibc/eglibc.mk +0 -7
index 8873a06..fe12299 100644
@@ -89,17 +89,10 @@ ifeq ($(BR2_PACKAGE_GDB_SERVER),y)
 EGLIBC_LIBS_LIB += libthread_db.so
 endif
 
-ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
-EGLIBC_LIBS_USR_LIB += libstdc++.so
-endif
-
 define EGLIBC_INSTALL_TARGET_CMDS
 	for libs in $(EGLIBC_LIBS_LIB); do \
 		$(call copy_toolchain_lib_root,$(STAGING_DIR)/,,lib,$$libs,/lib) ; \
 	done
-	for libs in $(EGLIBC_LIBS_USR_LIB); do \
-		$(call copy_toolchain_lib_root,$(STAGING_DIR)/,,lib,$$libs,/usr/lib) ; \
-	done
 endef
 
 $(eval $(autotools-package))
Signature · 1 line
1.8.1.2
#3 lore raw

PATCH 3/12 toolchain-internal: skip gcc-intermediate when possible

In reply to Thomas Petazzoni

When NPTL support was introduced, gcc required a three stages build process. Since gcc 4.7, this is no longer necessary, and it is possible to get back to a two stages build process. This patch takes advantage of this, by doing a two stages build process when possible.

We introduce a few hidden kconfig options:

* BR2_GCC_VERSION_NEEDS_THREE_STAGE_BUILD, which is set by the gcc Config.in logic to indicate that the compiler might need a three stages build. Currently, all versions prior to 4.7.x are selecting this kconfig option.

* BR2_TOOLCHAIN_LIBC_NEEDS_THREE_STAGE_BUILD, which indicates whether the C library might need a three stages build. This is the case for eglibc, and uClibc when NPTL is enabled.

* BR2_TOOLCHAIN_NEEDS_THREE_STAGE_BUILD finally is enabled when both of the previous options are enabled. It indicates that a three stages build is actually needed.

In addition to those options, the uClibc/gcc build logic is changed to take use only a two stages build process when possible.

---
 package/eglibc/eglibc.mk               |  5 +++--
 package/gcc/Config.in.host             | 11 +++++++++++
 package/gcc/gcc-initial/gcc-initial.mk |  8 ++++++++
 package/uclibc/Config.in               |  1 +
 package/uclibc/uclibc.mk               |  5 +++--
 toolchain/Config.in                    |  9 +++++++++
 6 files changed, 35 insertions(+), 4 deletions(-)
package/eglibc/eglibc.mk +3 -2
index fe12299..0ed908d 100644
@@ -14,8 +14,9 @@ EGLIBC_LICENSE_FILES = libc/COPYING libc/COPYING.LIB libc/LICENSES
 # cross-compiler and the kernel headers
 EGLIBC_DEPENDENCIES = host-gcc-initial linux-headers host-gawk
 
-# Before eglibc is built, we must have the second stage cross-compiler
-eglibc-build: host-gcc-intermediate
+# Before eglibc is built, we must have the second stage
+# cross-compiler, for some gcc versions
+eglibc-build: $(if $(BR2_TOOLCHAIN_NEEDS_THREE_STAGE_BUILD),host-gcc-intermediate)
 
 EGLIBC_SUBDIR = build
 
package/gcc/Config.in.host +11 -0
index a6acaa2..7e6df2d 100644
@@ -3,6 +3,12 @@ comment "GCC Options"
 config BR2_GCC_NEEDS_MPC
 	bool
 
+# Until gcc 4.7, a three stage build process was needed when using
+# NPTL. This hidden option tells whether gcc is a version that
+# requires this three stage build process.
+config BR2_GCC_VERSION_NEEDS_THREE_STAGE_BUILD
+	bool
+
 choice
 	prompt "GCC compiler Version"
 	default BR2_GCC_VERSION_4_4_X if BR2_sparc_sparchfleon || BR2_sparc_sparchfleonv8 || BR2_sparc_sparcsfleon || BR2_sparc_sparcsfleonv8
@@ -16,11 +22,13 @@ choice
 	config BR2_GCC_VERSION_4_2_2_AVR32_2_1_5
 		depends on BR2_avr32
 		bool "gcc 4.2.2-avr32-2.1.5"
+		select BR2_GCC_VERSION_NEEDS_THREE_STAGE_BUILD
 
 	config BR2_GCC_VERSION_4_3_X
 		depends on !BR2_arc && !BR2_avr32 && !BR2_sparc_sparchfleon && !BR2_sparc_sparchfleonv8 && !BR2_sparc_sparcsfleon && !BR2_sparc_sparcsfleonv8 && !BR2_cortex_a5 && !BR2_cortex_a7 && !BR2_cortex_a8 && !BR2_cortex_a9 && !BR2_cortex_a15 && !BR2_x86_atom && !BR2_powerpc_e300c2 && !BR2_powerpc_e300c3 && !BR2_powerpc_e500mc && !BR2_powerpc_464 && !BR2_powerpc_464fp && !BR2_powerpc_476 && !BR2_powerpc_476fp && !BR2_fa526 && !BR2_pj4
 		depends on !BR2_ARM_EABIHF
 		bool "gcc 4.3.x"
+		select BR2_GCC_VERSION_NEEDS_THREE_STAGE_BUILD
 
 	config BR2_GCC_VERSION_4_4_X
 		depends on !BR2_arc && !BR2_avr32 && !BR2_cortex_a5 && !BR2_cortex_a7 && !BR2_cortex_a15 && !BR2_x86_atom && !BR2_powerpc_476 && !BR2_powerpc_476fp && !BR2_fa526 && !BR2_pj4
@@ -29,6 +37,7 @@ choice
 		depends on !BR2_ARM_EABIHF
 		# VFPv4 support appeared in gcc 4.5
 		depends on !BR2_ARM_FPU_VFPV4 && !BR2_ARM_FPU_VFPV4D16
+		select BR2_GCC_VERSION_NEEDS_THREE_STAGE_BUILD
 
 	config BR2_GCC_VERSION_4_5_X
 		depends on !BR2_arc && !BR2_avr32 && !BR2_cortex_a7 && !BR2_cortex_a15 && !BR2_sparc_sparchfleon && !BR2_sparc_sparchfleonv8 && !BR2_sparc_sparcsfleon && !BR2_sparc_sparcsfleonv8 && !BR2_fa526 && !BR2_pj4
@@ -36,11 +45,13 @@ choice
 		# ARM EABIhf support appeared in gcc 4.6
 		depends on !BR2_ARM_EABIHF
 		bool "gcc 4.5.x"
+		select BR2_GCC_VERSION_NEEDS_THREE_STAGE_BUILD
 
 	config BR2_GCC_VERSION_4_6_X
 		depends on !BR2_arc && !BR2_avr32 && !BR2_bfin && !BR2_cortex_a7 && !BR2_sparc_sparchfleon && !BR2_sparc_sparchfleonv8 && !BR2_sparc_sparcsfleon && !BR2_sparc_sparcsfleonv8 && !BR2_pj4
 		select BR2_GCC_NEEDS_MPC
 		bool "gcc 4.6.x"
+		select BR2_GCC_VERSION_NEEDS_THREE_STAGE_BUILD
 
 	config BR2_GCC_VERSION_4_7_X
 		depends on !BR2_arc && !BR2_avr32 && !BR2_bfin && !BR2_sparc_sparchfleon && !BR2_sparc_sparchfleonv8 && !BR2_sparc_sparcsfleon && !BR2_sparc_sparcsfleonv8 && !BR2_pj4
package/gcc/gcc-initial/gcc-initial.mk +8 -0
index e468419..c3ab1ce 100644
@@ -29,6 +29,7 @@ HOST_GCC_INITIAL_CONF_OPT = \
 	--enable-languages=c \
 	--disable-shared \
 	--without-headers \
+	--disable-threads \
 	--with-newlib \
 	--disable-largefile \
 	--disable-nls \
@@ -37,4 +38,11 @@ HOST_GCC_INITIAL_CONF_OPT = \
 HOST_GCC_INITIAL_MAKE_OPT = all-gcc
 HOST_GCC_INITIAL_INSTALL_OPT = install-gcc
 
+ifeq ($(BR2_TOOLCHAIN_NEEDS_THREE_STAGE_BUILD),)
+ifeq ($(BR2_GCC_SUPPORTS_FINEGRAINEDMTUNE),y)
+HOST_GCC_INITIAL_MAKE_OPT += all-target-libgcc
+HOST_GCC_INITIAL_INSTALL_OPT += install-target-libgcc
+endif
+endif
+
 $(eval $(host-autotools-package))
package/uclibc/Config.in +1 -0
index 92e04e9..037ca01 100644
@@ -115,6 +115,7 @@ choice
 	config BR2_PTHREADS_NATIVE
 		bool "Native POSIX Threading (NPTL)"
 		select BR2_TOOLCHAIN_HAS_THREADS
+		select BR2_TOOLCHAIN_LIBC_NEEDS_THREE_STAGE_BUILD
 		depends on !BR2_arc
 		depends on !BR2_avr32
 		depends on !BR2_bfin
package/uclibc/uclibc.mk +3 -2
index 36a5001..cf9e5da 100644
@@ -22,8 +22,9 @@ UCLIBC_INSTALL_STAGING = YES
 # cross-compiler and the kernel headers
 UCLIBC_DEPENDENCIES = host-gcc-initial linux-headers
 
-# Before uClibc is built, we must have the second stage cross-compiler
-uclibc-build: host-gcc-intermediate
+# Before uClibc is built, we must have the second stage
+# cross-compiler, for some gcc versions, and when NPTL is used.
+uclibc-build: $(if $(BR2_TOOLCHAIN_NEEDS_THREE_STAGE_BUILD),host-gcc-intermediate)
 
 # specifying UCLIBC_CONFIG_FILE on the command-line overrides the .config
 # setting.
toolchain/Config.in +9 -0
index 53d2573..64cdf81 100644
@@ -1,5 +1,13 @@
 menu "Toolchain"
 
+config BR2_TOOLCHAIN_NEEDS_THREE_STAGE_BUILD
+	bool
+	default y if BR2_TOOLCHAIN_LIBC_NEEDS_THREE_STAGE_BUILD && \
+		BR2_GCC_VERSION_NEEDS_THREE_STAGE_BUILD
+
+config BR2_TOOLCHAIN_LIBC_NEEDS_THREE_STAGE_BUILD
+	bool
+
 # Should be selected for glibc or eglibc
 config BR2_TOOLCHAIN_USES_GLIBC
 	bool
@@ -10,6 +18,7 @@ config BR2_TOOLCHAIN_USES_GLIBC
 	select BR2_TOOLCHAIN_HAS_THREADS
 	select BR2_TOOLCHAIN_HAS_THREADS_DEBUG
 	select BR2_TOOLCHAIN_HAS_SHADOW_PASSWORDS
+	select BR2_TOOLCHAIN_LIBC_NEEDS_THREE_STAGE_BUILD
 
 config BR2_TOOLCHAIN_USES_UCLIBC
 	bool
Signature · 1 line
1.8.1.2
#4 lore raw

PATCH 4/12 gcc: fix Fortran support

In reply to Thomas Petazzoni

This commit fixes the Fortran support in the gcc package by making sure that the runtime Fortran library is properly installed to the target.

It also takes this opportunity to slightly reword the Config.in option help text, to no longer mention gcc < 4.2 since they are no longer supported in Buildroot, and to have a more meaningful explanation.

Finally, it fixes the gcc-final.mk code to use the correct BR2_INSTALL_FORTRAN option rather than the non-existing BR2_GCC_CROSS_FORTRAN option, to decide whether Fortran support should be enabled or not in the cross-compiler.

---
 package/gcc/Config.in.host         | 8 ++++----
 package/gcc/gcc-final/gcc-final.mk | 6 +++++-
 2 files changed, 9 insertions(+), 5 deletions(-)
package/gcc/Config.in.host +4 -4
index 7e6df2d..b440ee2 100644
@@ -119,13 +119,13 @@ config BR2_INSTALL_OBJC
 	  Build/install Objective-C compiler and runtime?
 
 config BR2_INSTALL_FORTRAN
-	bool "Build/install Fortran compiler and runtime?"
+	bool "Enable Fortran support"
 	depends on !BR2_avr32
 	select BR2_PACKAGE_LIBMPFR
 	help
-	  Build/install Fortran compiler and runtime?
-	  Note that it is highly recommended NOT to use gfortran
-	  from gcc older than 4.2.0
+	  Enable the support for the Fortran language in the
+	  cross-compiler, and install the Fortran runtime to the
+	  target.
 
 config BR2_GCC_ENABLE_TLS
 	bool "Enable compiler tls support" if BR2_TOOLCHAIN_BUILDROOT_UCLIBC
package/gcc/gcc-final/gcc-final.mk +5 -1
index 9f54c68..b5e35b0 100644
@@ -34,7 +34,7 @@ HOST_GCC_FINAL_PRE_CONFIGURE_HOOKS += HOST_GCC_FINAL_CONFIGURE_SYMLINK
 # Languages supported by the cross-compiler
 GCC_FINAL_CROSS_LANGUAGES-y = c
 GCC_FINAL_CROSS_LANGUAGES-$(BR2_INSTALL_LIBSTDCPP) += c++
-GCC_FINAL_CROSS_LANGUAGES-$(BR2_GCC_CROSS_FORTRAN) += fortran
+GCC_FINAL_CROSS_LANGUAGES-$(BR2_INSTALL_FORTRAN) += fortran
 GCC_FINAL_CROSS_LANGUAGES-$(BR2_GCC_CROSS_OBJC)    += objc
 GCC_FINAL_CROSS_LANGUAGES = $(subst $(space),$(comma),$(GCC_FINAL_CROSS_LANGUAGES-y))
 
@@ -127,6 +127,10 @@ ifeq ($(BR2_GCC_ENABLE_OPENMP),y)
 HOST_GCC_FINAL_USR_LIBS += libgomp
 endif
 
+ifeq ($(BR2_INSTALL_FORTRAN),y)
+HOST_GCC_FINAL_USR_LIBS += libgfortran
+endif
+
 ifneq ($(HOST_GCC_FINAL_USR_LIBS),)
 define HOST_GCC_FINAL_INSTALL_USR_LIBS
 	mkdir -p $(TARGET_DIR)/usr/lib
Signature · 1 line
1.8.1.2
#5 lore raw

PATCH 5/12 gcc: fix Objective-C support

In reply to Thomas Petazzoni

This commit fixes the Objective-C support in the gcc package by making sure that the runtime Objective-C library is properly installed to the target.

It also takes this opportunity to slightly reword the Config.in option help text to have a more meaningful explanation.

Finally, it fixes the gcc-final.mk code to use the correct BR2_INSTALL_OBJC option rather than the non-existing BR2_GCC_CROSS_OBJC option, to decide whether Objective-C support should be enabled or not in the cross-compiler.

---
 package/gcc/Config.in.host         | 6 ++++--
 package/gcc/gcc-final/gcc-final.mk | 6 +++++-
 2 files changed, 9 insertions(+), 3 deletions(-)
package/gcc/Config.in.host +4 -2
index b440ee2..a7dbbb6 100644
@@ -113,10 +113,12 @@ config BR2_EXTRA_GCC_CONFIG_OPTIONS
 	  initial, gcc intermediate and gcc final passes.
 
 config BR2_INSTALL_OBJC
-	bool "Build/install Objective-C compiler and runtime?"
+	bool "Enable Objective-C support"
 	depends on !BR2_avr32
 	help
-	  Build/install Objective-C compiler and runtime?
+	  Enable the support for the Objective-C language in the
+	  cross-compiler, and install the Objective-C runtime to the
+	  target.
 
 config BR2_INSTALL_FORTRAN
 	bool "Enable Fortran support"
package/gcc/gcc-final/gcc-final.mk +5 -1
index b5e35b0..02c4007 100644
@@ -35,7 +35,7 @@ HOST_GCC_FINAL_PRE_CONFIGURE_HOOKS += HOST_GCC_FINAL_CONFIGURE_SYMLINK
 GCC_FINAL_CROSS_LANGUAGES-y = c
 GCC_FINAL_CROSS_LANGUAGES-$(BR2_INSTALL_LIBSTDCPP) += c++
 GCC_FINAL_CROSS_LANGUAGES-$(BR2_INSTALL_FORTRAN) += fortran
-GCC_FINAL_CROSS_LANGUAGES-$(BR2_GCC_CROSS_OBJC)    += objc
+GCC_FINAL_CROSS_LANGUAGES-$(BR2_INSTALL_OBJC)    += objc
 GCC_FINAL_CROSS_LANGUAGES = $(subst $(space),$(comma),$(GCC_FINAL_CROSS_LANGUAGES-y))
 
 HOST_GCC_FINAL_CONF_OPT = \
@@ -131,6 +131,10 @@ ifeq ($(BR2_INSTALL_FORTRAN),y)
 HOST_GCC_FINAL_USR_LIBS += libgfortran
 endif
 
+ifeq ($(BR2_INSTALL_OBJC),y)
+HOST_GCC_FINAL_USR_LIBS += libobjc
+endif
+
 ifneq ($(HOST_GCC_FINAL_USR_LIBS),)
 define HOST_GCC_FINAL_INSTALL_USR_LIBS
 	mkdir -p $(TARGET_DIR)/usr/lib
Signature · 1 line
1.8.1.2
#6 lore raw

PATCH 6/12 gcc: move C++ support option next to Fortran/Objective-C

In reply to Thomas Petazzoni

The option to enable C++ support was still located in toolchain/toolchain-buildroot/Config.in.2, with misc other toolchain options. It seems more logical to have this option with the other options to select the languages supported by the cross-compiler, so we move it next to the Fortran/Objective-C options in package/gcc/Config.in.host.

---
 package/gcc/Config.in.host                | 13 +++++++++++++
 toolchain/toolchain-buildroot/Config.in.2 | 13 -------------
 2 files changed, 13 insertions(+), 13 deletions(-)
package/gcc/Config.in.host +13 -0
index a7dbbb6..dbf0f20 100644
@@ -112,6 +112,19 @@ config BR2_EXTRA_GCC_CONFIG_OPTIONS
 	  include. Those options are applied for all of the gcc
 	  initial, gcc intermediate and gcc final passes.
 
+config BR2_TOOLCHAIN_BUILDROOT_CXX
+	bool "Enable C++ support"
+	select BR2_INSTALL_LIBSTDCPP
+	depends on !(BR2_GCC_VERSION_4_2_2_AVR32_2_1_5 && \
+		     BR2_TOOLCHAIN_BUILDROOT_LOCALE)
+	help
+	  Enable this option if you want your toolchain to support the
+	  C++ language and you want C++ libraries to be installed on
+	  your target system.
+
+comment "C++ support broken in uClibc with locale enabled with gcc 4.2"
+	depends on BR2_GCC_VERSION_4_2_2_AVR32_2_1_5 && BR2_TOOLCHAIN_BUILDROOT_LOCALE
+
 config BR2_INSTALL_OBJC
 	bool "Enable Objective-C support"
 	depends on !BR2_avr32
toolchain/toolchain-buildroot/Config.in.2 +0 -13
index bf27e6b..1371c31 100644
@@ -4,19 +4,6 @@ if BR2_TOOLCHAIN_BUILDROOT
 
 comment "Toolchain Options"
 
-config BR2_TOOLCHAIN_BUILDROOT_CXX
-	bool "Enable C++ support"
-	select BR2_INSTALL_LIBSTDCPP
-	depends on !(BR2_GCC_VERSION_4_2_2_AVR32_2_1_5 && \
-		     BR2_TOOLCHAIN_BUILDROOT_LOCALE)
-	help
-	  Enable this option if you want your toolchain to support the
-	  C++ language and you want C++ libraries to be installed on
-	  your target system.
-
-comment "C++ support broken in uClibc with locale enabled with gcc 4.2"
-	depends on BR2_GCC_VERSION_4_2_2_AVR32_2_1_5 && BR2_TOOLCHAIN_BUILDROOT_LOCALE
-
 config BR2_TOOLCHAIN_BUILDROOT_USE_SSP
 	bool "Enable stack protection support"
 	help
Signature · 1 line
1.8.1.2
#7 lore raw

PATCH 7/12 toolchain: add support for glibc

In reply to Thomas Petazzoni

The support for eglibc 2.17 was added to the internal toolchain backend for 2013.08. This commit now adds glibc 2.18 support to the internal toolchain backend.

Since the building procedure is very similar to the one of eglibc, we have renamed the 'eglibc' package to 'glibc', and made it capable of handling either glibc or eglibc.

---
 package/gcc/Config.in.host                   |  2 +-
 package/gcc/gcc-final/gcc-final.mk           |  4 +-
 package/{eglibc/eglibc.mk => glibc/glibc.mk} | 62 +++++++++++++++++-----------
 toolchain/toolchain-buildroot/Config.in      | 24 ++++++++++-
 4 files changed, 64 insertions(+), 28 deletions(-)
 rename package/{eglibc/eglibc.mk => glibc/glibc.mk} (59%)
package/gcc/Config.in.host +1 -1
index dbf0f20..111da3b 100644
@@ -145,7 +145,7 @@ config BR2_INSTALL_FORTRAN
 config BR2_GCC_ENABLE_TLS
 	bool "Enable compiler tls support" if BR2_TOOLCHAIN_BUILDROOT_UCLIBC
 	default y
-	depends on BR2_PTHREADS_NATIVE || BR2_TOOLCHAIN_BUILDROOT_EGLIBC
+	depends on BR2_PTHREADS_NATIVE || BR2_TOOLCHAIN_BUILDROOT_EGLIBC || BR2_TOOLCHAIN_BUILDROOT_GLIBC
 	help
 	  Enable the compiler to generate code for accessing
 	  thread local storage variables
package/gcc/gcc-final/gcc-final.mk +2 -2
index 02c4007..e76038c 100644
@@ -91,11 +91,11 @@ endef
 
 HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_FINAL_CREATE_SIMPLE_SYMLINKS
 
-# In gcc 4.7.x, the ARM EABIhf library loader path for eglibc was not
+# In gcc 4.7.x, the ARM EABIhf library loader path for (e)glibc was not
 # correct, so we create a symbolic link to make things work
 # properly. eglibc installs the library loader as ld-linux-armhf.so.3,
 # but gcc creates binaries that reference ld-linux.so.3.
-ifeq ($(BR2_arm)$(BR2_ARM_EABIHF)$(BR2_GCC_VERSION_4_7_X)$(BR2_TOOLCHAIN_BUILDROOT_EGLIBC),yyyy)
+ifeq ($(BR2_arm)$(BR2_ARM_EABIHF)$(BR2_GCC_VERSION_4_7_X)$(BR2_TOOLCHAIN_USES_GLIBC),yyyy)
 define HOST_GCC_FINAL_LD_LINUX_LINK
 	ln -sf ld-linux-armhf.so.3 $(TARGET_DIR)/lib/ld-linux.so.3
 	ln -sf ld-linux-armhf.so.3 $(STAGING_DIR)/lib/ld-linux.so.3
package/glibc/glibc.mk renamed from package/eglibc/eglibc.mk +38 -24

103 lines not on this page · raw message

toolchain/toolchain-buildroot/Config.in +23 -1
index 396a434..4c1bfb0 100644
@@ -34,12 +34,34 @@ config BR2_TOOLCHAIN_BUILDROOT_EGLIBC
 
 	  http://eglibc.org
 
+config BR2_TOOLCHAIN_BUILDROOT_GLIBC
+	bool "glibc (experimental)"
+	depends on BR2_arm    || BR2_armeb    || BR2_aarch64 || \
+		   BR2_i386   || BR2_mips     || BR2_mipsel  || \
+		   BR2_mips64 || BR2_mips64el || BR2_powerpc || \
+		   BR2_sh     || BR2_sh64     || BR2_sparc   || \
+		   BR2_x86_64
+	select BR2_TOOLCHAIN_USES_GLIBC
+	# our glibc.mk enables RPC support
+	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
+	help
+	  This option selects glibc as the C library for the
+	  cross-compilation toolchain.
+
+	  The glibc support in the Buildroot toolchain backend is
+	  very recent, and therefore marked experimental.
+
+	  http://www.gnu.org/software/libc/
+
 endchoice
 
 config BR2_TOOLCHAIN_BUILDROOT_LIBC
 	string
 	default "uclibc" if BR2_TOOLCHAIN_BUILDROOT_UCLIBC
-	default "eglibc" if BR2_TOOLCHAIN_BUILDROOT_EGLIBC
+	# Both glibc and eglibc are handled by the package called
+	# 'glibc'
+	default "glibc"  if BR2_TOOLCHAIN_BUILDROOT_EGLIBC
+	default "glibc"  if BR2_TOOLCHAIN_BUILDROOT_GLIBC
 
 source "package/uclibc/Config.in"
 
Signature · 1 line
1.8.1.2
#8 lore raw

PATCH 8/12 gcc/gcc-final: use the common HOST_GCC_CONFIGURE_SYMLINK macro

In reply to Thomas Petazzoni

Each stage of the gcc build needs to make a small dance before the configuration step to create a build sub-directory and a symbolic link to the configure script. The common gcc.mk had a HOST_GCC_CONFIGURE_SYMLINK already used by the gcc-initial and gcc-intermediate steps, but the gcc-final step wasn't using it.

This commit fixes this inconsistency, and therefore removes the HOST_GCC_FINAL_CONFIGURE_SYMLINK macro.

---
 package/gcc/gcc-final/gcc-final.mk | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
package/gcc/gcc-final/gcc-final.mk +1 -6
index e76038c..3ead53b 100644
@@ -24,12 +24,7 @@ HOST_GCC_FINAL_POST_PATCH_HOOKS += HOST_GCC_APPLY_PATCHES
 # subdirectory in the gcc sources, and build from there.
 HOST_GCC_FINAL_SUBDIR = build
 
-define HOST_GCC_FINAL_CONFIGURE_SYMLINK
-	mkdir -p $(@D)/build
-	ln -s ../configure $(@D)/build/configure
-endef
-
-HOST_GCC_FINAL_PRE_CONFIGURE_HOOKS += HOST_GCC_FINAL_CONFIGURE_SYMLINK
+HOST_GCC_FINAL_PRE_CONFIGURE_HOOKS += HOST_GCC_CONFIGURE_SYMLINK
 
 # Languages supported by the cross-compiler
 GCC_FINAL_CROSS_LANGUAGES-y = c
Signature · 1 line
1.8.1.2
#9 lore raw

PATCH 9/12 gcc: force symlink creation

In reply to Thomas Petazzoni

The HOST_GCC_CONFIGURE_SYMLINK creates a symbolic link $(@D)/build/configure -> $(@D)/configure for each build step of gcc. However, it was only using 'ln -s' and not 'ln -sf', which was causing problems when doing 'make host-gcc-final-reconfigure' for example, because the configure commands (including this macro) are being re-executed, but the symbolic link already exists.

Changing this symbolic link creation to 'ln -sf' fixes this problem.

---
 package/gcc/gcc.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/gcc/gcc.mk +1 -1
index cd6efed..20d6d14 100644
@@ -76,7 +76,7 @@ endef
 
 define HOST_GCC_CONFIGURE_SYMLINK
 	mkdir -p $(@D)/build
-	ln -s ../configure $(@D)/build/configure
+	ln -sf ../configure $(@D)/build/configure
 endef
 
 #
Signature · 1 line
1.8.1.2
#10 lore raw

PATCH 10/12 toolchain: refactor Stack Smashing Protection support

In reply to Thomas Petazzoni

This commit refactors how Stack Smashing Protection support is handled in Buildroot:

*) It turns the BR2_TOOLCHAIN_BUILDROOT_USE_SSP option into an option
that only enables the SSP support in uClibc, when using the internal toolchain backend.

*) It adds an hidden BR2_TOOLCHAIN_HAS_SSP option that gets enabled
when the toolchain has SSP support. Here we have the usual dance:
glibc/eglibc in internal/external backend always select this option, in the case of uClibc/internal, it gets selected when BR2_TOOLCHAIN_BUILDROOT_USE_SSP is enabled, in the case of uClibc/external, there is a new configuration option that the user must select (or not) depending on whether the toolchain has SSP support.

*) It adds a new options BR2_ENABLE_SSP in the "Build options" menu,
to enable the usage of SSP support, by adding -fstack-protector-all to the CFLAGS.

---
 Config.in                                 | 17 +++++++++++++++++
 package/Makefile.in                       |  2 +-
 package/psmisc/psmisc.mk                  |  2 +-
 package/uclibc/Config.in                  | 10 ++++++++++
 toolchain/Config.in                       |  1 +
 toolchain/helpers.mk                      |  3 ++-
 toolchain/toolchain-buildroot/Config.in.2 |  9 ---------
 toolchain/toolchain-common.in             |  3 +++
 toolchain/toolchain-external/Config.in    |  9 +++++++++
 9 files changed, 44 insertions(+), 12 deletions(-)
Config.in +17 -0
index 78dea3b..590c013 100644
@@ -398,6 +398,23 @@ config BR2_OPTIMIZE_S
 
 endchoice
 
+config BR2_ENABLE_SSP
+	bool "build code with Stack Smashing Protection"
+	depends on BR2_TOOLCHAIN_HAS_SSP
+	help
+	  Enable stack smashing protection support using GCCs
+	  -fstack-protector-all option.
+
+	  See http://www.linuxfromscratch.org/hints/downloads/files/ssp.txt
+          for details.
+
+	  Note that this requires the toolchain to have SSP
+	  support. This is always the case for glibc and eglibc
+	  toolchain, but is optional in uClibc toolchains.
+
+comment "enabling Stack Smashing Protection requires support in the toolchain"
+	depends on !BR2_TOOLCHAIN_HAS_SSP
+
 config BR2_PREFER_STATIC_LIB
 	bool "prefer static libraries"
 	help
package/Makefile.in +1 -1
index 0b1c33a..3eaa2b2 100644
@@ -129,7 +129,7 @@ TARGET_CFLAGS += -msep-data
 TARGET_CXXFLAGS += -msep-data
 endif
 
-ifeq ($(BR2_TOOLCHAIN_BUILDROOT_USE_SSP),y)
+ifeq ($(BR2_ENABLE_SSP),y)
 TARGET_CFLAGS += -fstack-protector-all
 TARGET_CXXFLAGS += -fstack-protector-all
 endif
package/psmisc/psmisc.mk +1 -1
index 1340ee6..61faeab 100644
@@ -10,7 +10,7 @@ PSMISC_LICENSE = GPLv2
 PSMISC_LICENSE_FILES = COPYING
 PSMISC_DEPENDENCIES = ncurses $(if $(BR2_NEEDS_GETTEXT_IF_LOCALE),gettext)
 
-ifneq ($(BR2_TOOLCHAIN_BUILDROOT_USE_SSP),y)
+ifneq ($(BR2_ENABLE_SSP),y)
 # Don't force -fstack-protector
 PSMISC_CONF_OPT = --disable-harden-flags
 endif
package/uclibc/Config.in +10 -0
index 037ca01..eeb3b83 100644
@@ -130,6 +130,16 @@ config BR2_PTHREAD_DEBUG
 	help
 	  Build the thread library with debugging enabled.
 
+config BR2_TOOLCHAIN_BUILDROOT_USE_SSP
+	bool "Enable stack protection support"
+	select BR2_TOOLCHAIN_HAS_SSP
+	help
+	  Enable stack smashing protection support using GCCs
+	  -fstack-protector-all option in uClibc.
+
+	  See http://www.linuxfromscratch.org/hints/downloads/files/ssp.txt
+	  for details.
+
 config BR2_UCLIBC_INSTALL_UTILS
 	bool "Compile and install uClibc utilities"
 	depends on !BR2_bfin
toolchain/Config.in +1 -0
index 64cdf81..da9cd68 100644
@@ -18,6 +18,7 @@ config BR2_TOOLCHAIN_USES_GLIBC
 	select BR2_TOOLCHAIN_HAS_THREADS
 	select BR2_TOOLCHAIN_HAS_THREADS_DEBUG
 	select BR2_TOOLCHAIN_HAS_SHADOW_PASSWORDS
+	select BR2_TOOLCHAIN_HAS_SSP
 	select BR2_TOOLCHAIN_LIBC_NEEDS_THREE_STAGE_BUILD
 
 config BR2_TOOLCHAIN_USES_UCLIBC
toolchain/helpers.mk +2 -1
index 4c988a5..262c052 100644
@@ -269,7 +269,8 @@ check_uclibc = \
 	$(call check_uclibc_feature,__UCLIBC_HAS_LOCALE__,BR2_ENABLE_LOCALE,$${UCLIBC_CONFIG_FILE},Locale support) ;\
 	$(call check_uclibc_feature,__UCLIBC_HAS_WCHAR__,BR2_USE_WCHAR,$${UCLIBC_CONFIG_FILE},Wide char support) ;\
 	$(call check_uclibc_feature,__UCLIBC_HAS_THREADS__,BR2_TOOLCHAIN_HAS_THREADS,$${UCLIBC_CONFIG_FILE},Thread support) ;\
-	$(call check_uclibc_feature,__PTHREADS_DEBUG_SUPPORT__,BR2_TOOLCHAIN_HAS_THREADS_DEBUG,$${UCLIBC_CONFIG_FILE},Thread debugging support)
+	$(call check_uclibc_feature,__PTHREADS_DEBUG_SUPPORT__,BR2_TOOLCHAIN_HAS_THREADS_DEBUG,$${UCLIBC_CONFIG_FILE},Thread debugging support) ;\
+	$(call check_uclibc_feature,__UCLIBC_HAS_SSP__,BR2_TOOLCHAIN_HAS_SSP,$${UCLIBC_CONFIG_FILE},Stack Smashing Protection support)
 
 #
 # Check that the Buildroot configuration of the ABI matches the
toolchain/toolchain-buildroot/Config.in.2 +0 -9
index 1371c31..df26079 100644
@@ -4,15 +4,6 @@ if BR2_TOOLCHAIN_BUILDROOT
 
 comment "Toolchain Options"
 
-config BR2_TOOLCHAIN_BUILDROOT_USE_SSP
-	bool "Enable stack protection support"
-	help
-	  Enable stack smashing protection support using GCCs
-	  -fstack-protector-all option.
-
-	  See http://www.linuxfromscratch.org/hints/downloads/files/ssp.txt
-	  for details.
-
 source "package/elf2flt/Config.in.host"
 
 endif
toolchain/toolchain-common.in +3 -0
index dc3bd2a..1085fb3 100644
@@ -32,6 +32,9 @@ config BR2_TOOLCHAIN_HAS_THREADS_DEBUG
 config BR2_TOOLCHAIN_HAS_SHADOW_PASSWORDS
 	bool
 
+config BR2_TOOLCHAIN_HAS_SSP
+	bool
+
 config BR2_ENABLE_LOCALE_PURGE
 	bool "Purge unwanted locales"
 	help
toolchain/toolchain-external/Config.in +9 -0
index ad1f203..11edc98 100644
@@ -921,6 +921,15 @@ config BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG
 	  debugging support. If you don't know, leave the default
 	  value, Buildroot will tell you if it's correct or not.
 
+config BR2_TOOLCHAIN_EXTERNAL_HAS_SSP
+	bool "Toolchain has SSP support?"
+	select BR2_TOOLCHAIN_HAS_SSP
+	help
+	  Selection this option if your external toolchain has Stack
+	  Smashing Protection support enabled. If you don't know,
+	  leave the default value, Buildroot will tell you if it's
+	  correct or not.
+
 endif # BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC
 
 config BR2_TOOLCHAIN_EXTERNAL_INET_RPC
Signature · 1 line
1.8.1.2
#11 lore raw

PATCH 10/12 toolchain: refactor Stack Smashing Protection support

On 08/28/13 08:35, Thomas Petazzoni wrote:
[snip]

package/psmisc/psmisc.mk PSMISC_LICENSE = GPLv2 · line 16

Quoted 13 lines
package/psmisc/psmisc.mk +1 -1
index 1340ee6..61faeab 100644
@@ -10,7 +10,7 @@ PSMISC_LICENSE = GPLv2
  PSMISC_LICENSE_FILES = COPYING
  PSMISC_DEPENDENCIES = ncurses $(if $(BR2_NEEDS_GETTEXT_IF_LOCALE),gettext)
 
-ifneq ($(BR2_TOOLCHAIN_BUILDROOT_USE_SSP),y)
+ifneq ($(BR2_ENABLE_SSP),y)
  # Don't force -fstack-protector
  PSMISC_CONF_OPT = --disable-harden-flags
  endif

If psmisc normally uses -fstack-protector, then I wouldn't disable that
just because the user hasn't chosen to enable the option globally.

In other words, I'd put

ifneq ($(BR2_TOOLCHAIN_HAS_SSP),y)

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#12 lore raw

PATCH 10/12 toolchain: refactor Stack Smashing Protection support

Dear Arnout Vandecappelle,

Quoted 19 lines · Arnout Vandecappelle

On 08/28/13 08:35, Thomas Petazzoni wrote:
[snip]

package/psmisc/psmisc.mk PSMISC_LICENSE = GPLv2 · line 16

Quoted 13 lines
package/psmisc/psmisc.mk +1 -1
index 1340ee6..61faeab 100644
@@ -10,7 +10,7 @@ PSMISC_LICENSE = GPLv2
  PSMISC_LICENSE_FILES = COPYING
  PSMISC_DEPENDENCIES = ncurses $(if $(BR2_NEEDS_GETTEXT_IF_LOCALE),gettext)
 
-ifneq ($(BR2_TOOLCHAIN_BUILDROOT_USE_SSP),y)
+ifneq ($(BR2_ENABLE_SSP),y)
  # Don't force -fstack-protector
  PSMISC_CONF_OPT = --disable-harden-flags
  endif

If psmisc normally uses -fstack-protector, then I wouldn't disable that
just because the user hasn't chosen to enable the option globally.

Quoted 3 lines

In other words, I'd put

ifneq ($(BR2_TOOLCHAIN_HAS_SSP),y)

Sure, why not.

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#13 lore raw

PATCH 11/12 toolchain: move elf2flt option inclusion to toolchain-buildroot/Config.in

In reply to Thomas Petazzoni

The only remaining thing in toolchain-buildroot/Config.in.2 is the inclusion of the elf2flt option. It doesn't really make sense to have a separate Config.in file for that, so let's move this to toolchain-buildroot/Config.in.

---
 toolchain/Config.in                       | 1 -
 toolchain/toolchain-buildroot/Config.in   | 1 +
 toolchain/toolchain-buildroot/Config.in.2 | 9 ---------
 3 files changed, 1 insertion(+), 10 deletions(-)
 delete mode 100644 toolchain/toolchain-buildroot/Config.in.2
toolchain/Config.in +0 -1
index da9cd68..51c83d9 100644
@@ -62,6 +62,5 @@ source "toolchain/toolchain-buildroot/Config.in"
 source "toolchain/toolchain-external/Config.in"
 source "toolchain/toolchain-crosstool-ng/Config.in"
 source "toolchain/toolchain-common.in"
-source "toolchain/toolchain-buildroot/Config.in.2"
 
 endmenu
toolchain/toolchain-buildroot/Config.in +1 -0
index 4c1bfb0..df3d5c4 100644
@@ -67,4 +67,5 @@ source "package/uclibc/Config.in"
 
 source "package/binutils/Config.in.host"
 source "package/gcc/Config.in.host"
+source "package/elf2flt/Config.in.host"
 endif
toolchain/toolchain-buildroot/Config.in.2 deleted +0 -9
deleted file mode 100644
index df26079..0000000
@@ -1,9 +0,0 @@
-# Buildroot backend specific options
-
-if BR2_TOOLCHAIN_BUILDROOT
-
-comment "Toolchain Options"
-
-source "package/elf2flt/Config.in.host"
-
-endif
Signature · 1 line
1.8.1.2
#14 lore raw

PATCH 12/12 toolchain: improve mudflap support

In reply to Thomas Petazzoni

The mudflap library is only useful if one uses the -fmudflap gcc option, to do more checks on pointers/arrays, which is typically not the case.

This commit:

* Adds an option to enable/disable mudflap support at the gcc level. By default, it is disabled, which saves a little bit of build time.

* Adds a way for the external toolchain backend to tell whether mudflap is supported or not by the external toolchain.

* Adds a global BR2_TOOLCHAIN_HAS_MUDFLAP hidden option, that indicates whether the toolchain (internal or external) supports mudflap.

* Adds a global BR2_ENABLE_MUDFLAP in "Build options" that allows the user to build all packages with mudflap support. It depends on BR2_TOOLCHAIN_HAS_MUDFLAP.

WARNING WARNING: this currently doesn't result into a working system, even with just Busybox. Busybox init crashes with "/sbin/init: symbol lookup error: /lib/libmudflapth.so.0: undefined symbol:
main". According to
http://gcc.gnu.org/ml/gcc-help/2008-03/msg00165.html it is caused by -Wl,--gc-sections (which is used by Busybox), but even after removing it, it still doesn't work. I don't personaly have much interest in mudflap support, so as I couldn't get it to work easily, my suggestion would be to drop support for it entirely, unless someone steps up to fix this issue.

---
 Config.in                                | 20 ++++++++++++++++++++
 package/Makefile.in                      | 12 ++++++++++++
 package/gcc/Config.in.host               | 13 +++++++++++++
 package/gcc/gcc-final/gcc-final.mk       |  8 ++++++++
 package/gcc/gcc.mk                       |  6 ++++++
 toolchain/helpers.mk                     | 12 ++++++++++++
 toolchain/toolchain-common.in            |  3 +++
 toolchain/toolchain-external/Config.in   |  9 +++++++++
 toolchain/toolchain-external/ext-tool.mk | 11 +++++++++++
 9 files changed, 94 insertions(+)
Config.in +20 -0
index 590c013..2ffdfc5 100644
@@ -415,6 +415,26 @@ config BR2_ENABLE_SSP
 comment "enabling Stack Smashing Protection requires support in the toolchain"
 	depends on !BR2_TOOLCHAIN_HAS_SSP
 
+config BR2_ENABLE_MUDFLAP
+	bool "build code with Mudflap pointer debugging"
+	depends on BR2_TOOLCHAIN_HAS_MUDFLAP
+	help
+	   Instrument all risky pointer/array dereferencing
+	   operations, some standard library string/heap functions,
+	   and some other associated constructs with range/validity
+	   tests.  Modules so instrumented should be immune to buffer
+	   overflows, invalid heap use, and some other classes of
+	   C/C++ programming errors.
+
+	   See http://gcc.gnu.org/wiki/Mudflap_Pointer_Debugging for
+	   more details.
+
+	   Note that this requires the toolchain to have Mudflap
+	   support.
+
+comment "enabling Mudflap pointer debugging requires support in the toolchain"
+	depends on !BR2_TOOLCHAIN_HAS_MUDFLAP
+
 config BR2_PREFER_STATIC_LIB
 	bool "prefer static libraries"
 	help
package/Makefile.in +12 -0
index 3eaa2b2..194da11 100644
@@ -134,6 +134,18 @@ TARGET_CFLAGS += -fstack-protector-all
 TARGET_CXXFLAGS += -fstack-protector-all
 endif
 
+ifeq ($(BR2_ENABLE_MUDFLAP),y)
+ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+TARGET_CFLAGS += -fmudflapth
+TARGET_CXXFLAGS += fmudflapth
+TARGET_LDFLAGS += -fmudflapth -ldl -lpthread -lmudflapth
+else
+TARGET_CFLAGS += -fmudflap
+TARGET_CXXFLAGS += -fmudflap
+TARGET_LDFLAGS += -fmudflap -ldl -lmudflap
+endif
+endif
+
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT)$(BR2_TOOLCHAIN_CTNG),y)
 TARGET_CROSS=$(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-
 else
package/gcc/Config.in.host +13 -0
index 111da3b..ac9c5dd 100644
@@ -155,3 +155,16 @@ config BR2_GCC_ENABLE_OPENMP
 	depends on !BR2_PTHREADS_NONE && !BR2_avr32 && !BR2_arc
 	help
 	  Enable OpenMP support for the compiler
+
+config BR2_GCC_ENABLE_LIBMUDFLAP
+	bool "Enable libmudflap support"
+	select BR2_TOOLCHAIN_HAS_MUDFLAP
+	help
+	  libmudflap is a gcc library used for the mudflap pointer
+	  debugging functionality. It is only needed if you intend to
+	  use the -fmudflap gcc flag.
+
+	  See http://gcc.gnu.org/wiki/Mudflap_Pointer_Debugging and
+	  the help of the gcc -fmudflap option for more details.
+
+	  If you're unsure, leave this option disabled.
package/gcc/gcc-final/gcc-final.mk +8 -0
index 3ead53b..c153299 100644
@@ -130,6 +130,14 @@ ifeq ($(BR2_INSTALL_OBJC),y)
 HOST_GCC_FINAL_USR_LIBS += libobjc
 endif
 
+ifeq ($(BR2_GCC_ENABLE_LIBMUDFLAP),y)
+ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+HOST_GCC_FINAL_USR_LIBS += libmudflapth
+else
+HOST_GCC_FINAL_USR_LIBS += libmudflap
+endif
+endif
+
 ifneq ($(HOST_GCC_FINAL_USR_LIBS),)
 define HOST_GCC_FINAL_INSTALL_USR_LIBS
 	mkdir -p $(TARGET_DIR)/usr/lib
package/gcc/gcc.mk +6 -0
index 20d6d14..7630299 100644
@@ -119,6 +119,12 @@ else
 HOST_GCC_COMMON_CONF_OPT += --disable-tls
 endif
 
+ifeq ($(BR2_GCC_ENABLE_LIBMUDFLAP),y)
+HOST_GCC_COMMON_CONF_OPT += --enable-libmudflap
+else
+HOST_GCC_COMMON_CONF_OPT += --disable-libmudflap
+endif
+
 ifeq ($(BR2_PTHREADS_NONE),y)
 HOST_GCC_COMMON_CONF_OPT += \
 	--disable-threads \
toolchain/helpers.mk +12 -0
index 262c052..e8da6dc 100644
@@ -315,6 +315,18 @@ check_cplusplus = \
 	fi
 
 #
+# Check that the external toolchain has mudflap support
+#
+# $1: cross-gcc path
+#
+check_mudflap = \
+	__CROSS_CC=$(strip $1) ; \
+	if ! test -f `$${__CROSS_CC} -print-file-name=libmudflap.a` ; then \
+		echo "Mudflap support is selected but is not available in external toolchain" ; \
+		exit 1 ; \
+	fi
+
+#
 # Check that the cross-compiler given in the configuration exists
 #
 # $1: cross-gcc path
toolchain/toolchain-common.in +3 -0
index 1085fb3..03eab7f 100644
@@ -35,6 +35,9 @@ config BR2_TOOLCHAIN_HAS_SHADOW_PASSWORDS
 config BR2_TOOLCHAIN_HAS_SSP
 	bool
 
+config BR2_TOOLCHAIN_HAS_MUDFLAP
+	bool
+
 config BR2_ENABLE_LOCALE_PURGE
 	bool "Purge unwanted locales"
 	help
toolchain/toolchain-external/Config.in +9 -0
index 11edc98..ddba707 100644
@@ -13,6 +13,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_2013_06
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_HOSTARCH_NEEDS_IA32_LIBS
+	select BR2_TOOLCHAIN_HAS_MUDFLAP
 	help
 	  Linaro toolchain for the ARM architecture. It uses Linaro
 	  GCC 2013.06 (based on gcc 4.8), Linaro GDB 2013.06 (based on
@@ -949,6 +950,14 @@ config BR2_TOOLCHAIN_EXTERNAL_CXX
 	  support. If you don't know, leave the default value,
 	  Buildroot will tell you if it's correct or not.
 
+config BR2_TOOLCHAIN_EXTERNAL_MUDFLAP
+	bool "Toolchain has mudflap support?"
+	select BR2_TOOLCHAIN_HAS_MUDFLAP
+	help
+	  Select this option if your external toolchain has mudflap
+	  support. If you don't know, leave the default value,
+	  Buildroot will tell you if it's correct or not.
+
 config BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS
 	string "Extra toolchain libraries to be copied to target"
 	help
toolchain/toolchain-external/ext-tool.mk +11 -0
index 01be85c..fa2419f 100644
@@ -55,6 +55,14 @@ ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC),y)
 LIB_EXTERNAL_LIBS+=libnss_files.so libnss_dns.so
 endif
 
+ifeq ($(BR2_ENABLE_MUDFLAP),y)
+ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+LIB_EXTERNAL_LIBS+=libmudflapth.so
+else
+LIB_EXTERNAL_LIBS+=libmudflap.so
+endif
+endif
+
 ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
 USR_LIB_EXTERNAL_LIBS+=libstdc++.so
 endif
@@ -376,6 +384,9 @@ $(STAMP_DIR)/ext-toolchain-checked: $(TOOLCHAIN_EXTERNAL_DEPENDENCIES)
 	if test "$(BR2_INSTALL_LIBSTDCPP)" = "y" ; then \
 		$(call check_cplusplus,$(TOOLCHAIN_EXTERNAL_CXX)) ; \
 	fi ; \
+	if test "$(BR2_TOOLCHAIN_EXTERNAL_MUDFLAP)" = "y" ; then \
+		$(call check_mudflap,$(TOOLCHAIN_EXTERNAL_CC)) ; \
+	fi ; \
 	if test "$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC)" = "y" ; then \
 		$(call check_uclibc,$${SYSROOT_DIR}) ; \
 	else \
Signature · 1 line
1.8.1.2
#15 lore raw

PATCH 12/12 toolchain: improve mudflap support

Quoted 21 lines · Thomas Petazzoni

The mudflap library is only useful if one uses the -fmudflap gcc option, to do more checks on pointers/arrays, which is typically not the case.

This commit:

* Adds an option to enable/disable mudflap support at the gcc level. By default, it is disabled, which saves a little bit of build time.

* Adds a way for the external toolchain backend to tell whether mudflap is supported or not by the external toolchain.

* Adds a global BR2_TOOLCHAIN_HAS_MUDFLAP hidden option, that indicates whether the toolchain (internal or external) supports mudflap.

* Adds a global BR2_ENABLE_MUDFLAP in "Build options" that allows the user to build all packages with mudflap support. It depends on BR2_TOOLCHAIN_HAS_MUDFLAP.

Quoted 10 lines

WARNING WARNING: this currently doesn't result into a working system, even with just Busybox. Busybox init crashes with "/sbin/init: symbol lookup error: /lib/libmudflapth.so.0: undefined symbol:
main". According to
http://gcc.gnu.org/ml/gcc-help/2008-03/msg00165.html it is caused by -Wl,--gc-sections (which is used by Busybox), but even after removing it, it still doesn't work. I don't personaly have much interest in mudflap support, so as I couldn't get it to work easily, my suggestion would be to drop support for it entirely, unless someone steps up to fix this issue.

I would drop the option to enable -fmudflap globally, but keep the
option to build mudflap support in the internal toolchain. As you wrote in another mail, mudflap is a debugging tool and not really a hardening tool like SSP.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#16 lore raw

PATCH 12/12 toolchain: improve mudflap support

Dear Arnout Vandecappelle,

Quoted 11 lines · Arnout Vandecappelle
Quoted 10 lines

WARNING WARNING: this currently doesn't result into a working system, even with just Busybox. Busybox init crashes with "/sbin/init: symbol lookup error: /lib/libmudflapth.so.0: undefined symbol:
main". According to
http://gcc.gnu.org/ml/gcc-help/2008-03/msg00165.html it is caused by -Wl,--gc-sections (which is used by Busybox), but even after removing it, it still doesn't work. I don't personaly have much interest in mudflap support, so as I couldn't get it to work easily, my suggestion would be to drop support for it entirely, unless someone steps up to fix this issue.

Quoted 4 lines

I would drop the option to enable -fmudflap globally, but keep the
option to build mudflap support in the internal toolchain. As you wrote in another mail, mudflap is a debugging tool and not really a hardening tool like SSP.

I also agree with this. Gustavo, are you fine with this?

Thanks,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#17 lore raw

PATCH 12/12 toolchain: improve mudflap support

Quoted 6 lines · Thomas Petazzoni
Quoted 4 lines

I would drop the option to enable -fmudflap globally, but keep the
option to build mudflap support in the internal toolchain. As you wrote in another mail, mudflap is a debugging tool and not really a hardening tool like SSP.

I also agree with this. Gustavo, are you fine with this?

+1 we really don't want to make a Kconfig option out of each possible compiler flag and, well, busybox doesn't behave with it which many targets will use.
Regards.