Skip to contentSkip to conversation

Fortran support for all toolchain

PATCH Superseded Samuel Martin 3 participants 37 messages Jul 1, 2016 – Jul 2, 2016

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Fortran support for all toolchain

Hi all,

This second round of the series integrate the work (and fixes ;-]) from Benjamin, plus few others fixes.

Regards,

Benjamin Kamath (2):
package/Makefile.in: set TARGET_FCFLAGS variables package/lapack: new package

Samuel Martin (13):
package/gcc: fix fortran support
package/gcc: wrap gfortran
package/Makefile.in: set variables for legacy f77 checks pkg-cmake.mk: export the fortran compiler path in the CMake toolchain
file
toolchain: add hidden symbol for fortran support in the toolchain package/gcc: select BR2_TOOLCHAIN_HAS_FORTRAN when appropriated package/gcc: used BR2_TOOLCHAIN_HAS_FORTRAN instead of
BR2_TOOLCHAIN_BUILDROOT_FORTRAN
toolchain/helpers: add fortran check toolchain/toolchain-external: enable fortran check when it is selected toolchain/toolchain-external: add libgfortran and libquadmath to the
TOOLCHAIN_EXTERNAL_LIBS list
toolchain/toolchain-external: add knob for fortran support toolchain/toolchain-external: update external toolchain configuration
with BR2_TOOLCHAIN_HAS_FORTRAN
package/fftw: add fortran support

 package/Config.in                                  |  1 +
 package/Makefile.in                                | 11 ++++++++++
 package/fftw/fftw.mk                               |  3 ++-
 package/gcc/Config.in.host                         |  5 +++++
 package/gcc/gcc-final/gcc-final.mk                 |  8 +++++--
 package/gcc/gcc.mk                                 |  9 +++++++-
 package/lapack/0001-case-sensitive-paths.patch     | 22 +++++++++++++++++++
 package/lapack/Config.in                           | 17 +++++++++++++++
 package/lapack/lapack.hash                         |  2 ++
 package/lapack/lapack.mk                           | 25 ++++++++++++++++++++++
 package/pkg-cmake.mk                               |  3 +++
 support/misc/toolchainfile.cmake.in                |  4 ++++
 toolchain/helpers.mk                               | 15 +++++++++++++
 toolchain/toolchain-common.in                      |  3 +++
 toolchain/toolchain-external/Config.in             | 17 +++++++++++++++
 toolchain/toolchain-external/toolchain-external.mk | 13 +++++++++++
 16 files changed, 154 insertions(+), 4 deletions(-)
 create mode 100644 package/lapack/0001-case-sensitive-paths.patch
 create mode 100644 package/lapack/Config.in
 create mode 100644 package/lapack/lapack.hash
 create mode 100644 package/lapack/lapack.mk

--
2.9.0

#1 lore raw

PATCH v2 1/15 package/gcc: fix fortran support

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"]

---
changes v1->v2:
- none

---
 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 44a72f1..673b444 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 78ceeba..f13bc36 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 6e1c02d..e981940 100644
@@ -109,6 +109,11 @@ endif
 # quadmath support requires wchar
 ifeq ($(BR2_USE_WCHAR),)
 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.9.0
#2 lore raw

PATCH v2 1/15 package/gcc: fix fortran support

Hello,

package/gcc/gcc-final/gcc-final.mk endif · line 167

Quoted 10 lines · Samuel Martin
package/gcc/gcc-final/gcc-final.mk +2 -0
index 78ceeba..f13bc36 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)

BR2_I386 doesn't exist, you probably meant BR2_i386.

Quoted 10 lines
package/gcc/gcc-final/gcc-final.mk +2 -0
+HOST_GCC_FINAL_USR_LIBS += libquadmath
+endif
 endif
 
 ifeq ($(BR2_GCC_ENABLE_OPENMP),y)
package/gcc/gcc.mk +0 -0
index 6e1c02d..e981940 100644

package/gcc/gcc.mk endif · line 114

Quoted 6 lines
package/gcc/gcc.mk +3 -0
@@ -109,6 +109,11 @@ endif
 # quadmath support requires wchar
 ifeq ($(BR2_USE_WCHAR),)
 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)

Same here.

package/gcc/gcc.mk endif · line 117

Quoted 3 lines
package/gcc/gcc.mk +2 -0
+HOST_GCC_COMMON_CONF_OPTS += --enable-libquadmath
+endif
 endif

I'm not a big fan of this condition, it looks a bit clunky and complicated. Why don't we simply enable libquadmath as soon as wchar is available? With your condition, there are cases where libquadmath is forced enabled, some cases where libquadmath is forced disabled, and lots of other cases where we neither disable nor enable it. Doesn't look pretty.

Thomas

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

PATCH v2 2/15 package/gcc: wrap gfortran

In reply to Samuel Martin

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

---
changes v1->v2:
- none

---
 package/gcc/gcc.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
package/gcc/gcc.mk +3 -1
index e981940..ff92bbc 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.9.0
#4 lore raw

PATCH v2 2/15 package/gcc: wrap gfortran

Hello,

Quoted 6 lines · Samuel Martin

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

Quoted 6 lines

---
changes v1->v2:
- none

---
 package/gcc/gcc.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Applied to master, thanks.

Thomas

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

PATCH v2 3/15 package/Makefile.in: set TARGET_FCFLAGS variables

In reply to Samuel Martin

From: Benjamin Kamath <[email protected]>

TARGET_FCFLAGS is already added to TARGET_CONFIGURE_OPTS, but was not defined so for.
This change fixes this.

---
changes v1->v2:
- integrate these FCFLAGS changes in this series

---
 package/Makefile.in | 9 +++++++++
 1 file changed, 9 insertions(+)
package/Makefile.in +9 -0
index f6d1e67..471f687 100644
@@ -141,6 +141,7 @@ endif
 TARGET_CPPFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
 TARGET_CXXFLAGS = $(TARGET_CFLAGS)
+TARGET_FCFLAGS = $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
 TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS))
 
 ifeq ($(BR2_BINFMT_FLAT),y)
@@ -148,29 +149,36 @@ TARGET_CFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FL
 	-Wl$(comma)-elf2flt)
 TARGET_CXXFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
 	-Wl$(comma)-elf2flt)
+TARGET_FCFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
+	-Wl$(comma)-elf2flt)
 TARGET_LDFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt)
 endif
 
 ifeq ($(BR2_BINFMT_FLAT_SHARED),y)
 TARGET_LDFLAGS += -mid-shared-library -mshared-library-id=0
 TARGET_CFLAGS += -mid-shared-library -mshared-library-id=0
+TARGET_FCFLAGS += -mid-shared-library -mshared-library-id=0
 TARGET_CXXFLAGS += -mid-shared-library -mshared-library-id=0
 endif
 ifeq ($(BR2_BINFMT_FLAT_SEP_DATA),y)
 TARGET_LDFLAGS += -msep-data
 TARGET_CFLAGS += -msep-data
+TARGET_FCFLAGS += -msep-data
 TARGET_CXXFLAGS += -msep-data
 endif
 
 ifeq ($(BR2_SSP_REGULAR),y)
 TARGET_CFLAGS += -fstack-protector
 TARGET_CXXFLAGS += -fstack-protector
+TARGET_FCFLAGS += -fstack-protector
 else ifeq ($(BR2_SSP_STRONG),y)
 TARGET_CFLAGS += -fstack-protector-strong
 TARGET_CXXFLAGS += -fstack-protector-strong
+TARGET_FCFLAGS += -fstack-protector-strong
 else ifeq ($(BR2_SSP_ALL),y)
 TARGET_CFLAGS += -fstack-protector-all
 TARGET_CXXFLAGS += -fstack-protector-all
+TARGET_FCFLAGS += -fstack-protector-all
 endif
 
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
@@ -373,6 +381,7 @@ ifeq ($(BR2_STATIC_LIBS),y)
 SHARED_STATIC_LIBS_OPTS = --enable-static --disable-shared
 TARGET_CFLAGS += -static
 TARGET_CXXFLAGS += -static
+TARGET_FCFLAGS += -static
 TARGET_LDFLAGS += -static
 else ifeq ($(BR2_SHARED_LIBS),y)
 SHARED_STATIC_LIBS_OPTS = --disable-static --enable-shared
Signature · 1 line
2.9.0
#6 lore raw

PATCH v2 3/15 package/Makefile.in: set TARGET_FCFLAGS variables

Hello,

Quoted 4 lines · Samuel Martin

From: Benjamin Kamath <[email protected]>

TARGET_FCFLAGS is already added to TARGET_CONFIGURE_OPTS, but was not defined so for.

so for -> so far.

Quoted 5 lines

ifeq ($(BR2_BINFMT_FLAT),y)

package/Makefile.in +0 -0
@@ -148,29 +149,36 @@ TARGET_CFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FL
 	-Wl$(comma)-elf2flt)
 TARGET_CXXFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
 	-Wl$(comma)-elf2flt)

package/Makefile.in TARGET_CFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FL · line 161

Quoted 10 lines
package/Makefile.in +3 -0
+TARGET_FCFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
+	-Wl$(comma)-elf2flt)
 TARGET_LDFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt)
 endif
 
 ifeq ($(BR2_BINFMT_FLAT_SHARED),y)
 TARGET_LDFLAGS += -mid-shared-library -mshared-library-id=0
 TARGET_CFLAGS += -mid-shared-library -mshared-library-id=0
+TARGET_FCFLAGS += -mid-shared-library -mshared-library-id=0
 TARGET_CXXFLAGS += -mid-shared-library -mshared-library-id=0

[...]

There's really a lot of duplication between all those definitions, so maybe one day we should clean this up. I'm also not a big fan of the TARGET_ABI variable, but that's really unrelated to this patch.

So: applied, thanks!

Thomas

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

PATCH v2 3/15 package/Makefile.in: set TARGET_FCFLAGS variables

Quoted 18 lines · Thomas Petazzoni
Quoted 15 lines

ifeq ($(BR2_BINFMT_FLAT),y)

package/Makefile.in +3 -0
@@ -148,29 +149,36 @@ TARGET_CFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FL
 	-Wl$(comma)-elf2flt)
 TARGET_CXXFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
 	-Wl$(comma)-elf2flt)
+TARGET_FCFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
+	-Wl$(comma)-elf2flt)
 TARGET_LDFLAGS += $(if $($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),-Wl$(comma)-elf2flt)
 endif
 
 ifeq ($(BR2_BINFMT_FLAT_SHARED),y)
 TARGET_LDFLAGS += -mid-shared-library -mshared-library-id=0
 TARGET_CFLAGS += -mid-shared-library -mshared-library-id=0
+TARGET_FCFLAGS += -mid-shared-library -mshared-library-id=0
 TARGET_CXXFLAGS += -mid-shared-library -mshared-library-id=0

[...]

Quoted 3 lines

There's really a lot of duplication between all those definitions, so maybe one day we should clean this up. I'm also not a big fan of the TARGET_ABI variable, but that's really unrelated to this patch.

IMHO this stuff should go into the toolchain wrapper.

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:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#8 lore raw

PATCH v2 4/15 package/Makefile.in: set variables for legacy f77 checks

In reply to Samuel Martin

For fortran detection, some projects check for fortran availability using the FC/FCFLAGS variables, and others for the legacy F77/FFLAGS ones.
So, make sure the legacy fortran F77 and FFLAGS variables are set in TARGET_CONFIGURE_OPTS.

---
changes v1->v2:
- new patch

---
 package/Makefile.in | 2 ++
 1 file changed, 2 insertions(+)
package/Makefile.in +2 -0
index 471f687..afd5d3a 100644
@@ -250,6 +250,7 @@ TARGET_CONFIGURE_OPTS = \
 	CPP="$(TARGET_CPP)" \
 	CXX="$(TARGET_CXX)" \
 	FC="$(TARGET_FC)" \
+	F77="$(TARGET_FC)" \
 	RANLIB="$(TARGET_RANLIB)" \
 	READELF="$(TARGET_READELF)" \
 	STRIP="$(TARGET_STRIP)" \
@@ -273,6 +274,7 @@ TARGET_CONFIGURE_OPTS = \
 	CXXFLAGS="$(TARGET_CXXFLAGS)" \
 	LDFLAGS="$(TARGET_LDFLAGS)" \
 	FCFLAGS="$(TARGET_FCFLAGS)" \
+	FFLAGS="$(TARGET_FCFLAGS)" \
 	PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
 	STAGING_DIR="$(STAGING_DIR)" \
 	INTLTOOL_PERL=$(PERL)
Signature · 1 line
2.9.0
#9 lore raw

PATCH v2 4/15 package/Makefile.in: set variables for legacy f77 checks

Hello,

Quoted 6 lines · Samuel Martin

For fortran detection, some projects check for fortran availability using the FC/FCFLAGS variables, and others for the legacy F77/FFLAGS ones.
So, make sure the legacy fortran F77 and FFLAGS variables are set in TARGET_CONFIGURE_OPTS.

Quoted 8 lines

---
changes v1->v2:
- new patch

---
 package/Makefile.in | 2 ++
 1 file changed, 2 insertions(+)

Applied to master, thanks.

Thomas

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

PATCH v2 5/15 pkg-cmake.mk: export the fortran compiler path in the CMake toolchain file

In reply to Samuel Martin

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

---
changes v1->v2:
- set CMAKE_Fortran_FLAGS in the toolchainfile.cmake (Benjamin K.)

---
 package/pkg-cmake.mk                | 3 +++
 support/misc/toolchainfile.cmake.in | 4 ++++
 2 files changed, 7 insertions(+)
package/pkg-cmake.mk +3 -0
index 81dcfcc..1fe2e51 100644
@@ -243,9 +243,12 @@ $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake:
 		-e 's#@@STAGING_SUBDIR@@#$(call qstrip,$(STAGING_SUBDIR))#' \
 		-e 's#@@TARGET_CFLAGS@@#$(call qstrip,$(TARGET_CFLAGS))#' \
 		-e 's#@@TARGET_CXXFLAGS@@#$(call qstrip,$(TARGET_CXXFLAGS))#' \
+		-e 's#@@TARGET_FCFLAGS@@#$(call qstrip,$(TARGET_FCFLAGS))#' \
 		-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 +4 -0
index 5cf381e..e550b8f 100644
@@ -29,3 +29,7 @@ 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_FLAGS "@@TARGET_FCFLAGS@@ ${CMAKE_Fortran_FLAGS}" CACHE STRING "Buildroot FCFLAGS")
+  set(CMAKE_Fortran_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_FC@@")
+endif()
Signature · 1 line
2.9.0
#11 lore raw

PATCH v2 5/15 pkg-cmake.mk: export the fortran compiler path in the CMake toolchain file

Hello,

package/pkg-cmake.mk $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake: · line 252

Quoted 1 line · Samuel Martin
package/pkg-cmake.mk +1 -0
+		-e 's#@@TOOLCHAIN_HAS_FORTRAN@@#$(if $(BR2_TOOLCHAIN_HAS_FORTRAN),1,0)#' \

The BR2_TOOLCHAIN_HAS_FORTRAN variable doesn't exist at this point in the patch series, so shouldn't this patch come later?

Or did you assume that because it doesn't exist, it's always false for the moment, and that this patch should be considered a "preparation" patch ?

Thanks,

Thomas

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

PATCH v2 5/15 pkg-cmake.mk: export the fortran compiler path in the CMake toolchain file

Quoted 4 lines · Thomas Petazzoni

Hello,

On Fri, 1 Jul 2016 18:29:10 +0200, Samuel Martin wrote:

Quoted 8 lines
Quoted 1 line

+ -e 's#@@TOOLCHAIN_HAS_FORTRAN@@#$(if $(BR2_TOOLCHAIN_HAS_FORTRAN),1,0)#' \

The BR2_TOOLCHAIN_HAS_FORTRAN variable doesn't exist at this point in the patch series, so shouldn't this patch come later?

Or did you assume that because it doesn't exist, it's always false for the moment, and that this patch should be considered a "preparation" patch ?

Nope, I just screwed my rebase :-S

Quoted 8 lines

Thanks,

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

Signature · 1 line
Samuel
#13 lore raw

PATCH v2 6/15 toolchain: add hidden symbol for fortran support in the toolchain

In reply to Samuel Martin

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

---
changes v1->v2:
- none

---
 toolchain/toolchain-common.in | 3 +++
 1 file changed, 3 insertions(+)
toolchain/toolchain-common.in +3 -0
index 847c905..e8d47fb 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.9.0
#14 lore raw

PATCH v2 6/15 toolchain: add hidden symbol for fortran support in the toolchain

Hello,

Quoted 5 lines · Samuel Martin

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

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

PATCH v2 7/15 package/gcc: select BR2_TOOLCHAIN_HAS_FORTRAN when appropriated

In reply to Samuel Martin

This is only for the Buildroot toolchain backend.

---
changes v1->v2:
- none

---
 package/gcc/Config.in.host | 1 +
 1 file changed, 1 insertion(+)
package/gcc/Config.in.host +1 -0
index 673b444..f19b5e3 100644
@@ -121,6 +121,7 @@ config BR2_TOOLCHAIN_BUILDROOT_CXX
 config BR2_TOOLCHAIN_BUILDROOT_FORTRAN
 	bool "Enable Fortran support"
 	depends on BR2_USE_WCHAR # libquadmath
+	select BR2_TOOLCHAIN_HAS_FORTRAN
 	help
 	  Enable this option if you want your toolchain to support the
 	  Fortran language and you want Fortran libraries to be
Signature · 1 line
2.9.0
#16 lore raw

PATCH v2 7/15 package/gcc: select BR2_TOOLCHAIN_HAS_FORTRAN when appropriated

Hello,

Quoted 4 lines · Samuel Martin

This is only for the Buildroot toolchain backend.

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

PATCH v2 7/15 package/gcc: select BR2_TOOLCHAIN_HAS_FORTRAN when appropriated

In reply to Samuel Martin

Hello,

Quoted 1 line · Samuel Martin

This is only for the Buildroot toolchain backend.

In the title: appropriated -> appropriate

Thomas

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

PATCH v2 8/15 package/gcc: used BR2_TOOLCHAIN_HAS_FORTRAN instead of BR2_TOOLCHAIN_BUILDROOT_FORTRAN

In reply to Samuel Martin

---
changes v1->v2:
- none

---
 package/gcc/gcc-final/gcc-final.mk | 4 ++--
 package/gcc/gcc.mk                 | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
package/gcc/gcc-final/gcc-final.mk +2 -2
index f13bc36..4eb3639 100644
@@ -54,7 +54,7 @@ endef
 # 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_TOOLCHAIN_BUILDROOT_FORTRAN) += fortran
+GCC_FINAL_CROSS_LANGUAGES-$(BR2_TOOLCHAIN_HAS_FORTRAN) += fortran
 GCC_FINAL_CROSS_LANGUAGES = $(subst $(space),$(comma),$(GCC_FINAL_CROSS_LANGUAGES-y))
 
 HOST_GCC_FINAL_CONF_OPTS = \
@@ -161,7 +161,7 @@ ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
 HOST_GCC_FINAL_USR_LIBS += libstdc++
 endif
 
-ifeq ($(BR2_TOOLCHAIN_BUILDROOT_FORTRAN),y)
+ifeq ($(BR2_TOOLCHAIN_HAS_FORTRAN),y)
 HOST_GCC_FINAL_USR_LIBS += libgfortran
 # fortran needs quadmath on x86 and x86_64
 ifeq ($(BR2_I386)$(BR2_x86_64),y)
package/gcc/gcc.mk +1 -1
index ff92bbc..9a8efad 100644
@@ -111,7 +111,7 @@ ifeq ($(BR2_USE_WCHAR),)
 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)
+ifeq ($(BR2_TOOLCHAIN_HAS_FORTRAN)$(BR2_I386)$(BR2_x86_64),yy)
 HOST_GCC_COMMON_CONF_OPTS += --enable-libquadmath
 endif
 endif
Signature · 1 line
2.9.0
#19 lore raw

PATCH v2 8/15 package/gcc: used BR2_TOOLCHAIN_HAS_FORTRAN instead of BR2_TOOLCHAIN_BUILDROOT_FORTRAN

Hello,

In the title: used -> use

package/gcc/gcc-final/gcc-final.mk endef · line 57

Quoted 5 lines · Samuel Martin

# Languages supported by the cross-compiler GCC_FINAL_CROSS_LANGUAGES-y = c GCC_FINAL_CROSS_LANGUAGES-$(BR2_INSTALL_LIBSTDCPP) += c++

package/gcc/gcc-final/gcc-final.mk +1 -1
-GCC_FINAL_CROSS_LANGUAGES-$(BR2_TOOLCHAIN_BUILDROOT_FORTRAN) += fortran
+GCC_FINAL_CROSS_LANGUAGES-$(BR2_TOOLCHAIN_HAS_FORTRAN) += fortran

I am not actually sure of the value of this change, and I would rather suggest that BR2_TOOLCHAIN_BUILDROOT_CXX should be used to enable the C++ support.

To me, BR2_TOOLCHAIN_BUILDROOT_CXX and BR2_TOOLCHAIN_BUILDROOT_FORTRAN indicate that you *want* C++/Fortran support in the gcc being built by Buildroot. Those config options are from gcc, and affect the gcc build.

On the other hand BR2_INSTALL_LIBSTDCPP (which should be named BR2_TOOLCHAIN_HAS_CXX) and BR2_TOOLCHAIN_HAS_FORTRAN should be used by *consumers* that need C++ or Fortran.

So I would be inclined to reject this patch.

Thomas

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

PATCH v2 8/15 package/gcc: used BR2_TOOLCHAIN_HAS_FORTRAN instead of BR2_TOOLCHAIN_BUILDROOT_FORTRAN

Quoted 20 lines · Thomas Petazzoni

Hello,

In the title: used -> use

package/gcc/gcc-final/gcc-final.mk endef · line 57

Quoted 5 lines · Samuel Martin

# Languages supported by the cross-compiler GCC_FINAL_CROSS_LANGUAGES-y = c GCC_FINAL_CROSS_LANGUAGES-$(BR2_INSTALL_LIBSTDCPP) += c++

package/gcc/gcc-final/gcc-final.mk +1 -1
-GCC_FINAL_CROSS_LANGUAGES-$(BR2_TOOLCHAIN_BUILDROOT_FORTRAN) += fortran
+GCC_FINAL_CROSS_LANGUAGES-$(BR2_TOOLCHAIN_HAS_FORTRAN) += fortran

I am not actually sure of the value of this change, and I would rather suggest that BR2_TOOLCHAIN_BUILDROOT_CXX should be used to enable the C++ support.

To me, BR2_TOOLCHAIN_BUILDROOT_CXX and BR2_TOOLCHAIN_BUILDROOT_FORTRAN indicate that you *want* C++/Fortran support in the gcc being built by Buildroot. Those config options are from gcc, and affect the gcc build.

Quoted 5 lines

On the other hand BR2_INSTALL_LIBSTDCPP (which should be named BR2_TOOLCHAIN_HAS_CXX) and BR2_TOOLCHAIN_HAS_FORTRAN should be used by *consumers* that need C++ or Fortran.

So I would be inclined to reject this patch.

I agree.

BTW, we actually can easily change BR2_INSTALL_LIBSTDCPP into
BR2_TOOLCHAIN_HAS_CXX because it's a blind symbol.

BR2_TOOLCHAIN_BUILDROOT_CXX _should_ actually be named BR2_PACKAGE_GCC_CXX, but
that's more difficult because it's not blind.

Regards,
Arnout

Quoted 3 lines

Thomas

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:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#21 lore raw

PATCH v2 9/15 toolchain/helpers: add fortran check

In reply to Samuel Martin

---
changes v1->v2:
- none

---
 toolchain/helpers.mk | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
toolchain/helpers.mk +15 -0
index 108fdaa..3288c90 100644
@@ -311,6 +311,21 @@ check_cplusplus = \
 	fi
 
 #
+#
+# Check that the external toolchain supports Fortran
+#
+# $1: cross-gfortran path
+#
+check_fortran = \
+	__CROSS_FC=$(strip $1) ; \
+	printf 'program hello\n\tprint *, "Hello Fortran!\\n"\nend program hello\n' | \
+		$${__CROSS_FC} -x f95 -o /dev/null - ; \
+	if test $$? -ne 0 ; then \
+		echo "Fortran 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
Signature · 1 line
2.9.0
#22 lore raw

PATCH v2 9/15 toolchain/helpers: add fortran check

Hello,

toolchain/helpers.mk check_cplusplus = \ · line 322

Quoted 4 lines · Samuel Martin
toolchain/helpers.mk +4 -0
+check_fortran = \
+	__CROSS_FC=$(strip $1) ; \
+	printf 'program hello\n\tprint *, "Hello Fortran!\\n"\nend program hello\n' | \
+		$${__CROSS_FC} -x f95 -o /dev/null - ; \

We've seen in the past some toolchains that didn't support this solution of taking the source on the standard input and throwing away the output (see 375bc18850f0f8fec90e1e478c0e9d2159377a64). I'd prefer to use the same solution.

Thanks,

Thomas

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

PATCH v2 10/15 toolchain/toolchain-external: enable fortran check when it is selected

In reply to Samuel Martin

---
changes v1->v2:
- none

---
 toolchain/toolchain-external/toolchain-external.mk | 5 +++++
 1 file changed, 5 insertions(+)
toolchain/toolchain-external/toolchain-external.mk +5 -0
index 7f46234..53a7c7a 100644
@@ -160,6 +160,7 @@ TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += \
 TOOLCHAIN_EXTERNAL_CROSS = $(TOOLCHAIN_EXTERNAL_BIN)/$(TOOLCHAIN_EXTERNAL_PREFIX)-
 TOOLCHAIN_EXTERNAL_CC = $(TOOLCHAIN_EXTERNAL_CROSS)gcc$(TOOLCHAIN_EXTERNAL_SUFFIX)
 TOOLCHAIN_EXTERNAL_CXX = $(TOOLCHAIN_EXTERNAL_CROSS)g++$(TOOLCHAIN_EXTERNAL_SUFFIX)
+TOOLCHAIN_EXTERNAL_FC = $(TOOLCHAIN_EXTERNAL_CROSS)gfortran$(TOOLCHAIN_EXTERNAL_SUFFIX)
 TOOLCHAIN_EXTERNAL_READELF = $(TOOLCHAIN_EXTERNAL_CROSS)readelf$(TOOLCHAIN_EXTERNAL_SUFFIX)
 
 ifeq ($(filter $(HOST_DIR)/%,$(TOOLCHAIN_EXTERNAL_BIN)),)
@@ -529,6 +530,10 @@ define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS
 	if test "$(BR2_INSTALL_LIBSTDCPP)" = "y" ; then \
 		$(call check_cplusplus,$(TOOLCHAIN_EXTERNAL_CXX)) ; \
 	fi ; \
+	if test "$(BR2_TOOLCHAIN_HAS_FORTRAN)" = "y" ; then \
+		$(call check_fortran,\
+			"$(TOOLCHAIN_EXTERNAL_FC) $(TOOLCHAIN_EXTERNAL_CFLAGS)") ; \
+	fi ; \
 	if test "$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC)" = "y" ; then \
 		$(call check_uclibc,$${SYSROOT_DIR}) ; \
 	elif test "$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \
Signature · 1 line
2.9.0
#24 lore raw

PATCH v2 10/15 toolchain/toolchain-external: enable fortran check when it is selected

Hello,

toolchain/toolchain-external/toolchain-external.mk define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS · line 535

Quoted 8 lines · Samuel Martin

ifeq ($(filter $(HOST_DIR)/%,$(TOOLCHAIN_EXTERNAL_BIN)),)

toolchain/toolchain-external/toolchain-external.mk +3 -0
@@ -529,6 +530,10 @@ define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS
 	if test "$(BR2_INSTALL_LIBSTDCPP)" = "y" ; then \
 		$(call check_cplusplus,$(TOOLCHAIN_EXTERNAL_CXX)) ; \
 	fi ; \
+	if test "$(BR2_TOOLCHAIN_HAS_FORTRAN)" = "y" ; then \
+		$(call check_fortran,\
+			"$(TOOLCHAIN_EXTERNAL_FC) $(TOOLCHAIN_EXTERNAL_CFLAGS)") ; \

Why are you passing TOOLCHAIN_EXTERNAL_CFLAGS for the fortran compiler check, while we are not using them for the C++ compiler check ?

Thanks,

Thomas

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

PATCH v2 10/15 toolchain/toolchain-external: enable fortran check when it is selected

Quoted 4 lines · Thomas Petazzoni

Hello,

On Fri, 1 Jul 2016 18:29:15 +0200, Samuel Martin wrote:

Quoted 11 lines

toolchain/toolchain-external/toolchain-external.mk define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS · line 535

Quoted 8 lines

ifeq ($(filter $(HOST_DIR)/%,$(TOOLCHAIN_EXTERNAL_BIN)),)

toolchain/toolchain-external/toolchain-external.mk +3 -0
@@ -529,6 +530,10 @@ define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS
      if test "$(BR2_INSTALL_LIBSTDCPP)" = "y" ; then \
              $(call check_cplusplus,$(TOOLCHAIN_EXTERNAL_CXX)) ; \
      fi ; \
+     if test "$(BR2_TOOLCHAIN_HAS_FORTRAN)" = "y" ; then \
+             $(call check_fortran,\
+                     "$(TOOLCHAIN_EXTERNAL_FC) $(TOOLCHAIN_EXTERNAL_CFLAGS)") ; \

Why are you passing TOOLCHAIN_EXTERNAL_CFLAGS for the fortran compiler check, while we are not using them for the C++ compiler check ?

Well, no real reason to do this indeed... only gfortran is supposed to support gcc option, so it should be harmless.
Anyway, I drop them.

Quoted 8 lines

Thanks,

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

Signature · 1 line
Samuel
#26 lore raw

PATCH v2 11/15 toolchain/toolchain-external: add libgfortran and libquadmath to the TOOLCHAIN_EXTERNAL_LIBS list

In reply to Samuel Martin

---
changes v1->v2:
- s/USR_LIB_EXTERNAL_LIBS/TOOLCHAIN_EXTERNAL_LIBS/
- only install libquadmath for x86{,_64} target (not built on other arch.)

---
 toolchain/toolchain-external/toolchain-external.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
toolchain/toolchain-external/toolchain-external.mk +8 -0
index 53a7c7a..9629c46 100644
@@ -90,6 +90,14 @@ ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
 TOOLCHAIN_EXTERNAL_LIBS += libstdc++.so.*
 endif
 
+ifeq ($(BR2_TOOLCHAIN_HAS_FORTRAN),y)
+TOOLCHAIN_EXTERNAL_LIBS += libgfortran.so.*
+# fortran needs quadmath on x86 and x86_64
+ifeq ($(BR2_I386)$(BR2_x86_64),y)
+TOOLCHAIN_EXTERNAL_LIBS += libquadmath.so*
+endif
+endif
+
 TOOLCHAIN_EXTERNAL_LIBS += $(call qstrip,$(BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS))
 
 # Details about sysroot directory selection.
Signature · 1 line
2.9.0
#27 lore raw

PATCH v2 11/15 toolchain/toolchain-external: add libgfortran and libquadmath to the TOOLCHAIN_EXTERNAL_LIBS list

Hello,

toolchain/toolchain-external/toolchain-external.mk ifeq ($(BR2_INSTALL_LIBSTDCPP),y) · line 99

Quoted 7 lines · Samuel Martin
toolchain/toolchain-external/toolchain-external.mk +7 -0
+ifeq ($(BR2_TOOLCHAIN_HAS_FORTRAN),y)
+TOOLCHAIN_EXTERNAL_LIBS += libgfortran.so.*
+# fortran needs quadmath on x86 and x86_64
+ifeq ($(BR2_I386)$(BR2_x86_64),y)
+TOOLCHAIN_EXTERNAL_LIBS += libquadmath.so*
+endif
+endif

OK. Then maybe on the internal toolchain backend side, we should keep things simple for libquadmath:

1/ Disable it when we know it's not supported (wchar missing)

2/ Forcefully enable it when Fortran is enabled and we're on

    i386/x86_64

3/ Copy it only when Fortran is enabled and i386/x86_64

Which is pretty much what you did originally I believe.

This way, only the people who care about Fortran support will have libquadmath copied to their target. If in the future some other non-Fortran related package needs libquadmath, we can revisit this at this time.

Thomas

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

PATCH v2 11/15 toolchain/toolchain-external: add libgfortran and libquadmath to the TOOLCHAIN_EXTERNAL_LIBS list

Quoted 20 lines · Thomas Petazzoni

Hello,

toolchain/toolchain-external/toolchain-external.mk ifeq ($(BR2_INSTALL_LIBSTDCPP),y) · line 99

Quoted 7 lines · Samuel Martin
toolchain/toolchain-external/toolchain-external.mk +7 -0
+ifeq ($(BR2_TOOLCHAIN_HAS_FORTRAN),y)
+TOOLCHAIN_EXTERNAL_LIBS += libgfortran.so.*
+# fortran needs quadmath on x86 and x86_64
+ifeq ($(BR2_I386)$(BR2_x86_64),y)
+TOOLCHAIN_EXTERNAL_LIBS += libquadmath.so*
+endif
+endif

OK. Then maybe on the internal toolchain backend side, we should keep things simple for libquadmath:

1/ Disable it when we know it's not supported (wchar missing)

2/ Forcefully enable it when Fortran is enabled and we're on

    i386/x86_64
Quoted 8 lines

3/ Copy it only when Fortran is enabled and i386/x86_64

Which is pretty much what you did originally I believe.

This way, only the people who care about Fortran support will have libquadmath copied to their target. If in the future some other non-Fortran related package needs libquadmath, we can revisit this at this time.

fftw you mean? :-)

At this point, it is perhaps better to introduce a blind
BR2_TOOLCHAIN_HAS_QUADMATH option (or should it be USE?) that is selected automatically as appropriate. Later we could add a BR2_PACKAGE_GCC_QUADMATH option to enable it explicitly.

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:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#29 lore raw

PATCH v2 12/15 toolchain/toolchain-external: add knob for fortran support

In reply to Samuel Martin

---
changes v1->v2:
- none

---
 toolchain/toolchain-external/Config.in | 12 ++++++++++++
 1 file changed, 12 insertions(+)
toolchain/toolchain-external/Config.in +12 -0
index 552536e..253aeb1 100644
@@ -1020,6 +1020,18 @@ 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_FORTRAN
+	bool "Toolchain has Fortran support?"
+	depends on BR2_USE_WCHAR # libquadmath
+	select BR2_TOOLCHAIN_HAS_FORTRAN
+	help
+	  Select this option if your external toolchain has fortran
+	  support. If you don't know, leave the default value,
+	  Buildroot will tell you if it's correct or not.
+
+comment "Fortran support needs a toolchain w/ wchar"
+	depends on !BR2_USE_WCHAR
+
 config BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS
 	string "Extra toolchain libraries to be copied to target"
 	help
Signature · 1 line
2.9.0
#30 lore raw

PATCH v2 12/15 toolchain/toolchain-external: add knob for fortran support

Hello,

toolchain/toolchain-external/Config.in config BR2_TOOLCHAIN_EXTERNAL_CXX · line 1025

Quoted 3 lines · Samuel Martin
toolchain/toolchain-external/Config.in +3 -0
+config BR2_TOOLCHAIN_EXTERNAL_FORTRAN
+	bool "Toolchain has Fortran support?"
+	depends on BR2_USE_WCHAR # libquadmath

Is this dependency really needed? Plus libquadmath is only needed on i386/x86_64, so on other architectures, we could have Fortran support without wchar, could we?

toolchain/toolchain-external/Config.in config BR2_TOOLCHAIN_EXTERNAL_CXX · line 1033

Quoted 8 lines
toolchain/toolchain-external/Config.in +8 -0
+	select BR2_TOOLCHAIN_HAS_FORTRAN
+	help
+	  Select this option if your external toolchain has fortran
+	  support. If you don't know, leave the default value,
+	  Buildroot will tell you if it's correct or not.
+
+comment "Fortran support needs a toolchain w/ wchar"
+	depends on !BR2_USE_WCHAR

I think this comment is not needed.

Thomas

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

PATCH v2 12/15 toolchain/toolchain-external: add knob for fortran support

Quoted 11 lines · Thomas Petazzoni

Hello,

toolchain/toolchain-external/Config.in config BR2_TOOLCHAIN_EXTERNAL_CXX · line 1025

Quoted 3 lines · Samuel Martin
toolchain/toolchain-external/Config.in +3 -0
+config BR2_TOOLCHAIN_EXTERNAL_FORTRAN
+     bool "Toolchain has Fortran support?"
+     depends on BR2_USE_WCHAR # libquadmath

Is this dependency really needed? Plus libquadmath is only needed on i386/x86_64, so on other architectures, we could have Fortran support without wchar, could we?

Right, it should be:
depends on (wchar && (i386 || x86_64)) || !(i386 || x86_64)

Quoted 11 lines

toolchain/toolchain-external/Config.in config BR2_TOOLCHAIN_EXTERNAL_CXX · line 1033

Quoted 9 lines
toolchain/toolchain-external/Config.in +8 -0
+     select BR2_TOOLCHAIN_HAS_FORTRAN
+     help
+       Select this option if your external toolchain has fortran
+       support. If you don't know, leave the default value,
+       Buildroot will tell you if it's correct or not.
+
+comment "Fortran support needs a toolchain w/ wchar"
+     depends on !BR2_USE_WCHAR

I think this comment is not needed.

Indeed, if the external toolchain has fortran, then it already meets all the fortran dependencies.

Quoted 6 lines

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

Signature · 1 line
Samuel
#32 lore raw

PATCH v2 13/15 toolchain/toolchain-external: update external toolchain configuration with BR2_TOOLCHAIN_HAS_FORTRAN

In reply to Samuel Martin

[Vincent: BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX also has fortran]

---
changes v1->v2:
- update linaro 2016.02 arm selection

---
 toolchain/toolchain-external/Config.in | 5 +++++
 1 file changed, 5 insertions(+)
toolchain/toolchain-external/Config.in +5 -0
index 253aeb1..f687240 100644
@@ -27,6 +27,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_1
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
+	select BR2_TOOLCHAIN_HAS_FORTRAN
 	help
 	  Linaro toolchain for the ARM architecture. It uses Linaro
 	  GCC 2014.09 (based on gcc 4.9), Linaro GDB 2013.10 (based on
@@ -50,6 +51,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_0
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_5
+	select BR2_TOOLCHAIN_HAS_FORTRAN
 	help
 	  Linaro toolchain for the ARM architecture. It uses Linaro
 	  GCC 2016.02 (based on gcc 5.3), Linaro GDB 2016.02 (based on
@@ -73,6 +75,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB
 	select BR2_INSTALL_LIBSTDCPP
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_1
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
+	select BR2_TOOLCHAIN_HAS_FORTRAN
 	help
 	  Linaro toolchain for the ARM big endian architecture. It
 	  uses Linaro GCC 2014.09 (based on gcc 4.9), Linaro GDB
@@ -522,6 +525,7 @@ config BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX
 	select BR2_HOSTARCH_NEEDS_IA32_LIBS
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_4_3
+	select BR2_TOOLCHAIN_HAS_FORTRAN
 	help
 	  Toolchain for the Blackfin architecture, from
 	  http://blackfin.uclinux.org.
@@ -538,6 +542,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_7
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
+	select BR2_TOOLCHAIN_HAS_FORTRAN
 	help
 	  Toolchain for the AArch64 architecture, from
 	  http://www.linaro.org/engineering/armv8/
Signature · 1 line
2.9.0
#33 lore raw

PATCH v2 14/15 package/fftw: add fortran support

In reply to Samuel Martin

---
changes v1->v2:
- add comment about fortran

---
 package/fftw/fftw.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
package/fftw/fftw.mk +2 -1
index 5045ab6..9e2b2cc 100644
@@ -10,7 +10,8 @@ FFTW_INSTALL_STAGING = YES
 FFTW_LICENSE = GPLv2+
 FFTW_LICENSE_FILES = COPYING
 
-FFTW_CONF_OPTS = --disable-fortran
+# fortran support only enables generation and installation of fortran sources
+FFTW_CONF_OPTS = $(if $(BR2_TOOLCHAIN_HAS_FORTRAN),--enable,--disable)-fortran
 
 FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_PRECISION_SINGLE),--enable,--disable)-single
 FFTW_CONF_OPTS += $(if $(BR2_PACKAGE_FFTW_PRECISION_LONG_DOUBLE),--enable,--disable)-long-double
Signature · 1 line
2.9.0
#34 lore raw

PATCH v2 15/15 package/lapack: new package

In reply to Samuel Martin

From: Benjamin Kamath <[email protected]>

lapack is a fortran-based linear algebra math library.

---
changes v1->v2:
- integrate this patch in this series
- slightly tweak the commit log
- s/BR2_INSTALL_LIBFORTRAN/BR2_TOOLCHAIN_HAS_FORTRAN/

---
 package/Config.in                              |  1 +
 package/lapack/0001-case-sensitive-paths.patch | 22 ++++++++++++++++++++++
 package/lapack/Config.in                       | 17 +++++++++++++++++
 package/lapack/lapack.hash                     |  2 ++
 package/lapack/lapack.mk                       | 25 +++++++++++++++++++++++++
 5 files changed, 67 insertions(+)
 create mode 100644 package/lapack/0001-case-sensitive-paths.patch
 create mode 100644 package/lapack/Config.in
 create mode 100644 package/lapack/lapack.hash
 create mode 100644 package/lapack/lapack.mk
package/Config.in +1 -0
index 26e2059..8e2a2af 100644
@@ -1255,6 +1255,7 @@ menu "Other"
 	source "package/gmp/Config.in"
 	source "package/gsl/Config.in"
 	source "package/gtest/Config.in"
+	source "package/lapack/Config.in"
 	source "package/libargtable2/Config.in"
 	source "package/libatomic_ops/Config.in"
 	source "package/libbsd/Config.in"
package/lapack/0001-case-sensitive-paths.patch new file +22 -0
new file mode 100644
index 0000000..3722b88
@@ -0,0 +1,22 @@
+Fix upper case issue in CMakeLists
+
+Fix the 3.6.0 release of lapack to work with case-sensitive file systems,
+reported as bug 145 in LAPACK's bug list. Corrected in SVN rev 1651.
+
+Signed-off-by: Benjamin Kamath <[email protected]>
+
+diff -rupN lapack-3.6.0/CBLAS/CMakeLists.txt lapack-3.6.0-old/CBLAS/CMakeLists.txt
+--- lapack-3.6.0/CBLAS/CMakeLists.txt	2016-03-17 13:42:31.121248051 -0700
++++ lapack-3.6.0-old/CBLAS/CMakeLists.txt	2016-03-17 13:41:37.819316904 -0700
+@@ -65,9 +65,9 @@ if(ALL_TARGETS)
+   list(GET ALL_TARGETS 0 _cblas_config_build_guard_target)
+ endif()
+ 
+-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMAKE/cblas-config-version.cmake.in
++configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cblas-config-version.cmake.in
+   ${LAPACK_BINARY_DIR}/cblas-config-version.cmake @ONLY)
+-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMAKE/cblas-config-build.cmake.in
++configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cblas-config-build.cmake.in
+   ${LAPACK_BINARY_DIR}/cblas-config.cmake @ONLY)
+ 
+ 
package/lapack/Config.in new file +17 -0
new file mode 100644
index 0000000..8e028bd
@@ -0,0 +1,17 @@
+config BR2_PACKAGE_LAPACK
+	bool "lapack/blas"
+	depends on BR2_TOOLCHAIN_HAS_FORTRAN
+	# _fpu_control is used on PowerPC, but not available with
+	# uClibc
+	depends on !BR2_powerpc || BR2_TOOLCHAIN_USES_GLIBC
+	help
+	  LAPACK and BLAS FORTRAN implementation.
+
+	  http://www.netlib.org/lapack/
+
+config BR2_PACKAGE_LAPACK_COMPLEX
+	bool "Complex/Complex16 support"
+	depends on BR2_PACKAGE_LAPACK
+	default y
+	help
+	  Builds support for COMPLEX and COMPLEX16 data types.
package/lapack/lapack.hash new file +2 -0
new file mode 100644
index 0000000..99d25b5
@@ -0,0 +1,2 @@
+# Locally computed:
+sha256  a9a0082c918fe14e377bbd570057616768dca76cbdc713457d8199aaa233ffc3  lapack-3.6.0.tgz
package/lapack/lapack.mk new file +25 -0
new file mode 100644
index 0000000..7656291
@@ -0,0 +1,25 @@
+################################################################################
+#
+# lapack
+#
+################################################################################
+
+# This package provides 2 libraries:
+# - libblas
+# - liblapack
+
+LAPACK_VERSION = 3.6.0
+LAPACK_SOURCE = lapack-$(LAPACK_VERSION).tgz
+LAPACK_LICENSE = BSD-3c (libblas and liblapack)
+LAPACK_LICENSE_FILES = LICENSE
+LAPACK_SITE = http://www.netlib.org/lapack
+LAPACK_INSTALL_STAGING = YES
+LAPACK_CONF_OPTS = -DLAPACKE=on -DCBLAS=on
+
+ifeq ($(BR2_PACKAGE_LAPACK_COMPLEX),y)
+LAPACK_CONF_OPTS += -DBUILD_COMPLEX=on -DBUILD_COMPLEX16=on
+else
+LAPACK_CONF_OPTS += -DBUILD_COMPLEX=off -DBUILD_COMPLEX16=off
+endif
+
+$(eval $(cmake-package))
Signature · 1 line
2.9.0
#35 lore raw

PATCH v2 15/15 package/lapack: new package

Hello,

package/lapack/Config.in line 6

Quoted 12 lines · Samuel Martin
package/lapack/Config.in new file +6 -0
new file mode 100644
index 0000000..8e028bd
@@ -0,0 +1,17 @@
+config BR2_PACKAGE_LAPACK
+	bool "lapack/blas"
+	depends on BR2_TOOLCHAIN_HAS_FORTRAN
+	# _fpu_control is used on PowerPC, but not available with
+	# uClibc
+	depends on !BR2_powerpc || BR2_TOOLCHAIN_USES_GLIBC

What about musl here ?

Also, just like we have a comment for packages that need C++ support, we should probably have a similar comment for packages that need Fortran support. And of course, the documentation should be updated accordingly.

Quoted 28 lines
package/lapack/Config.in new file +11 -0
+	help
+	  LAPACK and BLAS FORTRAN implementation.
+
+	  http://www.netlib.org/lapack/
+
+config BR2_PACKAGE_LAPACK_COMPLEX
+	bool "Complex/Complex16 support"
+	depends on BR2_PACKAGE_LAPACK
+	default y
+	help
+	  Builds support for COMPLEX and COMPLEX16 data types.
package/lapack/lapack.hash new file +2 -0
new file mode 100644
index 0000000..99d25b5
@@ -0,0 +1,2 @@
+# Locally computed:
+sha256  a9a0082c918fe14e377bbd570057616768dca76cbdc713457d8199aaa233ffc3  lapack-3.6.0.tgz
package/lapack/lapack.mk new file +3 -0
new file mode 100644
index 0000000..7656291
@@ -0,0 +1,25 @@
+################################################################################
+#
+# lapack

package/lapack/lapack.mk line 13

Quoted 10 lines
package/lapack/lapack.mk new file +10 -0
+#
+################################################################################
+
+# This package provides 2 libraries:
+# - libblas
+# - liblapack
+
+LAPACK_VERSION = 3.6.0
+LAPACK_SOURCE = lapack-$(LAPACK_VERSION).tgz
+LAPACK_LICENSE = BSD-3c (libblas and liblapack)

No need to mention "libblas and liblapack" if that's all what the package is installing. Specifying what is under what license is only needed when multiple licenses are used.

package/lapack/lapack.mk line 23

Quoted 10 lines
package/lapack/lapack.mk new file +10 -0
+LAPACK_LICENSE_FILES = LICENSE
+LAPACK_SITE = http://www.netlib.org/lapack
+LAPACK_INSTALL_STAGING = YES
+LAPACK_CONF_OPTS = -DLAPACKE=on -DCBLAS=on
+
+ifeq ($(BR2_PACKAGE_LAPACK_COMPLEX),y)
+LAPACK_CONF_OPTS += -DBUILD_COMPLEX=on -DBUILD_COMPLEX16=on
+else
+LAPACK_CONF_OPTS += -DBUILD_COMPLEX=off -DBUILD_COMPLEX16=off
+endif

Don't we generally use upper-case for ON/OFF in CMake packages ?

Thanks,

Thomas

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

PATCH v2 15/15 package/lapack: new package

Quoted 4 lines · Thomas Petazzoni

Hello,

On Fri, 1 Jul 2016 18:29:20 +0200, Samuel Martin wrote:

Quoted 14 lines

package/lapack/Config.in line 6

Quoted 12 lines
package/lapack/Config.in new file +6 -0
new file mode 100644
index 0000000..8e028bd
@@ -0,0 +1,17 @@
+config BR2_PACKAGE_LAPACK
+     bool "lapack/blas"
+     depends on BR2_TOOLCHAIN_HAS_FORTRAN
+     # _fpu_control is used on PowerPC, but not available with
+     # uClibc
+     depends on !BR2_powerpc || BR2_TOOLCHAIN_USES_GLIBC

What about musl here ?

It does build with musl, so I changed deps to be:
depends on !(BR2_powerpc && BR2_TOOLCHAIN_USES_UCLIBC)

Quoted 5 lines

Also, just like we have a comment for packages that need C++ support, we should probably have a similar comment for packages that need Fortran support. And of course, the documentation should be updated accordingly.

Done

Quoted 35 lines
Quoted 35 lines
package/lapack/Config.in new file +11 -0
+     help
+       LAPACK and BLAS FORTRAN implementation.
+
+       http://www.netlib.org/lapack/
+
+config BR2_PACKAGE_LAPACK_COMPLEX
+     bool "Complex/Complex16 support"
+     depends on BR2_PACKAGE_LAPACK
+     default y
+     help
+       Builds support for COMPLEX and COMPLEX16 data types.
package/lapack/lapack.hash new file +2 -0
new file mode 100644
index 0000000..99d25b5
@@ -0,0 +1,2 @@
+# Locally computed:
+sha256  a9a0082c918fe14e377bbd570057616768dca76cbdc713457d8199aaa233ffc3  lapack-3.6.0.tgz
package/lapack/lapack.mk new file +9 -0
new file mode 100644
index 0000000..7656291
@@ -0,0 +1,25 @@
+################################################################################
+#
+# lapack
+#
+################################################################################
+
+# This package provides 2 libraries:
+# - libblas
+# - liblapack
Quoted 8 lines

package/lapack/lapack.mk line 13

Quoted 4 lines
package/lapack/lapack.mk new file +4 -0
+
+LAPACK_VERSION = 3.6.0
+LAPACK_SOURCE = lapack-$(LAPACK_VERSION).tgz
+LAPACK_LICENSE = BSD-3c (libblas and liblapack)

No need to mention "libblas and liblapack" if that's all what the package is installing. Specifying what is under what license is only needed when multiple licenses are used.

Done

Quoted 13 lines

package/lapack/lapack.mk line 23

Quoted 11 lines
package/lapack/lapack.mk new file +10 -0
+LAPACK_LICENSE_FILES = LICENSE
+LAPACK_SITE = http://www.netlib.org/lapack
+LAPACK_INSTALL_STAGING = YES
+LAPACK_CONF_OPTS = -DLAPACKE=on -DCBLAS=on
+
+ifeq ($(BR2_PACKAGE_LAPACK_COMPLEX),y)
+LAPACK_CONF_OPTS += -DBUILD_COMPLEX=on -DBUILD_COMPLEX16=on
+else
+LAPACK_CONF_OPTS += -DBUILD_COMPLEX=off -DBUILD_COMPLEX16=off
+endif

Don't we generally use upper-case for ON/OFF in CMake packages ?

Done

Quoted 8 lines

Thanks,

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

Signature · 1 line
Samuel