Skip to contentSkip to conversation

package/gcc: use BR2_USE_WCHAR to set gcc libquadmath option

PATCH New Vicente Olivert Riera 2 participants 6 messages Jun 27, 2016 – Jul 1, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/13 package/gcc: use BR2_USE_WCHAR to set gcc libquadmath option

From: Samuel Martin <[email protected]>

BR2_TOOLCHAIN_BUILDROOT_WCHAR is only defined when uclibc is selected, whereas BR2_USE_WCHAR is always defined.

So, use BR2_USE_WCHAR to drive the gcc libquadmath option.

---
 package/gcc/gcc.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/gcc/gcc.mk +1 -1
index 46f05ff..88d2bc2 100644
@@ -107,7 +107,7 @@ HOST_GCC_COMMON_CONF_OPTS += --disable-libitm
 endif
 
 # gcc 4.6.x quadmath requires wchar
-ifneq ($(BR2_TOOLCHAIN_BUILDROOT_WCHAR),y)
+ifneq ($(BR2_USE_WCHAR),y)
 HOST_GCC_COMMON_CONF_OPTS += --disable-libquadmath
 endif
 
Signature · 1 line
2.7.3
#1 lore raw

PATCH 2/13 package/gcc: fix fortran support

From: Samuel Martin <[email protected]>

Fortran depends on libquadmath, which requires a toolchain with wchar support.

So:
- make sure libquadmath is enable and installed when fortran is enabled;
- propagate the wchar dependency (from libquadmath) to fortran, and add a comment when fortran is not available.

[Vincent: only do "HOST_GCC_FINAL_USR_LIBS += libquadmath" for i386 and x86_64, otherwise it will fail saying "libquadmath.a: file not found"]

---
 package/gcc/Config.in.host         | 4 ++++
 package/gcc/gcc-final/gcc-final.mk | 4 ++++
 package/gcc/gcc.mk                 | 5 +++++
 3 files changed, 13 insertions(+)
package/gcc/Config.in.host +4 -0
index 3180071..54f7e1f 100644
@@ -120,11 +120,15 @@ config BR2_TOOLCHAIN_BUILDROOT_CXX
 
 config BR2_TOOLCHAIN_BUILDROOT_FORTRAN
 	bool "Enable Fortran support"
+	depends on BR2_USE_WCHAR # libquadmath
 	help
 	  Enable this option if you want your toolchain to support the
 	  Fortran language and you want Fortran libraries to be
 	  installed on your target system.
 
+comment "Fortran support needs a toolchain w/ wchar"
+	depends on !BR2_USE_WCHAR
+
 config BR2_GCC_ENABLE_TLS
 	bool "Enable compiler tls support" if BR2_TOOLCHAIN_BUILDROOT_UCLIBC
 	default y
package/gcc/gcc-final/gcc-final.mk +4 -0
index 1d1d72e..e418f51 100644
@@ -163,6 +163,10 @@ endif
 
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT_FORTRAN),y)
 HOST_GCC_FINAL_USR_LIBS += libgfortran
+# fortran needs quadmath on x86 and x86_64
+ifeq ($(BR2_I386)$(BR2_x86_64),y)
+HOST_GCC_FINAL_USR_LIBS += libquadmath
+endif
 endif
 
 ifeq ($(BR2_GCC_ENABLE_OPENMP),y)
package/gcc/gcc.mk +5 -0
index 88d2bc2..cffdb19 100644
@@ -109,6 +109,11 @@ endif
 # gcc 4.6.x quadmath requires wchar
 ifneq ($(BR2_USE_WCHAR),y)
 HOST_GCC_COMMON_CONF_OPTS += --disable-libquadmath
+else
+# fortran needs quadmath on x86 and x86_64
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT_FORTRAN)$(BR2_I386)$(BR2_x86_64),yy)
+HOST_GCC_COMMON_CONF_OPTS += --enable-libquadmath
+endif
 endif
 
 # libsanitizer requires wordexp, not in default uClibc config. Also
Signature · 1 line
2.7.3
#2 lore raw

PATCH 3/13 package/gcc: wrap gfortran

In reply to Vicente Olivert Riera

From: Samuel Martin <[email protected]>

gfortran supports all options supported by gcc, so it can and should be called via the toolchain wrapper.

---
 package/gcc/gcc.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
package/gcc/gcc.mk +3 -1
index cffdb19..8bc34ea 100644
@@ -270,6 +270,8 @@ endif # BR2_CCACHE
 # used. However, we should not add the toolchain wrapper for them, and they
 # match the *cc-* pattern. Therefore, an additional case is added for *-ar,
 # *-ranlib and *-nm.
+# According to gfortran manpage, it supports all options supported by gcc, so
+# add gfortran to the list of the program called via the Buildroot wrapper.
 # Avoid that a .br_real is symlinked a second time.
 # Also create <arch>-linux-<tool> symlinks.
 define HOST_GCC_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
@@ -281,7 +283,7 @@ define HOST_GCC_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
 		*-ar|*-ranlib|*-nm) \
 			ln -snf $$i $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
 			;; \
-		*cc|*cc-*|*++|*++-*|*cpp) \
+		*cc|*cc-*|*++|*++-*|*cpp|*-gfortran) \
 			rm -f $$i.br_real; \
 			mv $$i $$i.br_real; \
 			ln -sf toolchain-wrapper $$i; \
Signature · 1 line
2.7.3
#3 lore raw

PATCH 4/13 pkg-cmake.mk: export the fortran compiler path in the CMake toolchain file

In reply to Vicente Olivert Riera

From: Samuel Martin <[email protected]>

Since the fortran support is conditional, only enable it when needed.

---
 package/pkg-cmake.mk                | 2 ++
 support/misc/toolchainfile.cmake.in | 3 +++
 2 files changed, 5 insertions(+)
package/pkg-cmake.mk +2 -0
index 81dcfcc..d30b66b 100644
@@ -246,6 +246,8 @@ $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake:
 		-e 's#@@TARGET_LDFLAGS@@#$(call qstrip,$(TARGET_LDFLAGS))#' \
 		-e 's#@@TARGET_CC@@#$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CC)))#' \
 		-e 's#@@TARGET_CXX@@#$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CXX)))#' \
+		-e 's#@@TARGET_FC@@#$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_FC)))#' \
 		-e 's#@@CMAKE_SYSTEM_PROCESSOR@@#$(call qstrip,$(CMAKE_SYSTEM_PROCESSOR))#' \
+		-e 's#@@TOOLCHAIN_HAS_FORTRAN@@#$(if $(BR2_TOOLCHAIN_HAS_FORTRAN),1,0)#' \
 		$(TOPDIR)/support/misc/toolchainfile.cmake.in \
 		> $@
support/misc/toolchainfile.cmake.in +3 -0
index 5cf381e..ac81e9a 100644
@@ -29,3 +29,6 @@ set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
 # This toolchain file can be used both inside and outside Buildroot.
 set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@")
 set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@")
+if(@@TOOLCHAIN_HAS_FORTRAN@@)
+  set(CMAKE_Fortran_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_FC@@")
+endif()
Signature · 1 line
2.7.3
#4 lore raw

PATCH 5/13 toolchain: add hidden symbol for fortran support in the toolchain

In reply to Vicente Olivert Riera

From: Samuel Martin <[email protected]>

This symbol should be used in all packages requiring/testing for fortran support.

---
 toolchain/toolchain-common.in | 3 +++
 1 file changed, 3 insertions(+)
toolchain/toolchain-common.in +3 -0
index 1fe28a9..232377f 100644
@@ -21,6 +21,9 @@ config BR2_ENABLE_LOCALE
 config BR2_INSTALL_LIBSTDCPP
 	bool
 
+config BR2_TOOLCHAIN_HAS_FORTRAN
+	bool
+
 config BR2_TOOLCHAIN_HAS_THREADS
 	bool
 
Signature · 1 line
2.7.3
#5 lore raw

PATCH 1/13 package/gcc: use BR2_USE_WCHAR to set gcc libquadmath option

In reply to Vicente Olivert Riera

Hello,

Quoted 9 lines · Vicente Olivert Riera

From: Samuel Martin <[email protected]>

BR2_TOOLCHAIN_BUILDROOT_WCHAR is only defined when uclibc is selected, whereas BR2_USE_WCHAR is always defined.

So, use BR2_USE_WCHAR to drive the gcc libquadmath option.

I've applied, after doing some tweaks, see below.

package/gcc/gcc.mk HOST_GCC_COMMON_CONF_OPTS += --disable-libitm · line 109

Quoted 12 lines
---
 package/gcc/gcc.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/gcc/gcc.mk +0 -0
index 46f05ff..88d2bc2 100644
@@ -107,7 +107,7 @@ HOST_GCC_COMMON_CONF_OPTS += --disable-libitm
 endif
 
 # gcc 4.6.x quadmath requires wchar

I've updated this commit, because the requirement on wchar doesn't apply just to gcc 4.6. It applies *since* 4.6, because that's when libquadmath was introduced.

package/gcc/gcc.mk HOST_GCC_COMMON_CONF_OPTS += --disable-libitm · line 110

Quoted 2 lines
package/gcc/gcc.mk +1 -1
-ifneq ($(BR2_TOOLCHAIN_BUILDROOT_WCHAR),y)
+ifneq ($(BR2_USE_WCHAR),y)

And I've inverted the condition to use positive logic:

ifeq ($(BR2_USE_WCHAR),)

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com