Skip to contentSkip to conversation

Fortran support for all toolchains

PATCH Superseded Samuel Martin 3 participants 21 messages Jul 3, 2016 – Jul 5, 2016

lore
Share & tools
lore
#0 lore raw

v3 cover Fortran support for all toolchains

Hi all,

This third round of the series includes:
* refactoring of the libquadmath handling (which is a dependency of fortran on some architecture);
* fixes from last review.

Note that all patches fixing the infrastructures but the last patch (adding lapack package) of this are ready.
I'm still investigating a CMake on mis-behavior on the lapack package (causing build failure unrelated to this rest of this sereis).

Regards,

Benjamin Kamath (1):
package/lapack: new package

Samuel Martin (13):
toolchain/toolchain-common.in: add BR2_TOOLCHAIN_HAS_LIBQUADMATH
hidden symbol
package/gcc: complete the logic on libquadmath package/gcc: fix fortran support
toolchain: add hidden symbol for fortran support in the toolchain docs/manual: document dependency on fortran
package/gcc: select BR2_TOOLCHAIN_HAS_FORTRAN when appropriate pkg-cmake.mk: export the fortran compiler path in the CMake toolchain
file
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

 docs/manual/adding-packages-directory.txt          |  4 ++++
 package/Config.in                                  |  1 +
 package/fftw/fftw.mk                               |  3 ++-
 package/gcc/Config.in.host                         |  8 +++++++
 package/gcc/gcc-final/gcc-final.mk                 |  4 ++++
 package/gcc/gcc.mk                                 |  4 +++-
 package/lapack/0001-case-sensitive-paths.patch     | 22 +++++++++++++++++++
 package/lapack/Config.in                           | 20 +++++++++++++++++
 package/lapack/lapack.hash                         |  2 ++
 package/lapack/lapack.mk                           | 25 ++++++++++++++++++++++
 package/pkg-cmake.mk                               |  3 +++
 support/misc/toolchainfile.cmake.in                |  4 ++++
 toolchain/helpers.mk                               | 18 ++++++++++++++++
 toolchain/toolchain-common.in                      | 13 +++++++++++
 toolchain/toolchain-external/Config.in             | 14 ++++++++++++
 toolchain/toolchain-external/toolchain-external.mk | 13 ++++++++++-
 16 files changed, 155 insertions(+), 3 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 v3 1/14 toolchain/toolchain-common.in: add BR2_TOOLCHAIN_HAS_LIBQUADMATH hidden symbol

This hidden symbol allow to know when libquadmath can be built and installed.

Also, declaring this symbol in toolchain-common.in allows to use it in both external and buildroot toolchain backend.

This will be needed for adding/improving the fortran support.

Cc Thomas Petazzoni <[email protected]>
Cc Vicente Olivert Riera <[email protected]>
Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>

---
changes v2->v3:
- new patch

---
 toolchain/toolchain-common.in | 10 ++++++++++
 1 file changed, 10 insertions(+)
toolchain/toolchain-common.in +10 -0
index 847c905..96ce3d1 100644
@@ -419,3 +419,13 @@ config BR2_TOOLCHAIN_HAS_ATOMIC
 	default y if BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 && BR2_armeb
 	default y if BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 && BR2_xtensa
 	default y if BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 && BR2_ARCH_IS_64
+
+# - libquadmath is not needed/available on all architectures (but gcc
+#   correctly handles this already).
+# - At least, libquadmath is available on:
+#   - i*86
+#   - x86_64
+# - When available, libquadmath requires wchar support.
+config BR2_TOOLCHAIN_HAS_LIBQUADMATH
+	bool
+	default y if BR2_i386 || BR2_x86_64
Signature · 1 line
2.9.0
#2 lore raw

PATCH v3 1/14 toolchain/toolchain-common.in: add BR2_TOOLCHAIN_HAS_LIBQUADMATH hidden symbol

Quoted 27 lines · Samuel Martin

This hidden symbol allow to know when libquadmath can be built and installed.

Also, declaring this symbol in toolchain-common.in allows to use it in both external and buildroot toolchain backend.

This will be needed for adding/improving the fortran support.

Cc Thomas Petazzoni <[email protected]>
Cc Vicente Olivert Riera <[email protected]>
Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>

---
changes v2->v3:
- new patch

---
 toolchain/toolchain-common.in | 10 ++++++++++
 1 file changed, 10 insertions(+)
toolchain/toolchain-common.in +0 -0
index 847c905..96ce3d1 100644
@@ -419,3 +419,13 @@ config BR2_TOOLCHAIN_HAS_ATOMIC
 	default y if BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 && BR2_armeb
 	default y if BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 && BR2_xtensa
 	default y if BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 && BR2_ARCH_IS_64

toolchain/toolchain-common.in config BR2_TOOLCHAIN_HAS_ATOMIC · line 431

Quoted 10 lines
toolchain/toolchain-common.in +10 -0
+
+# - libquadmath is not needed/available on all architectures (but gcc
+#   correctly handles this already).
+# - At least, libquadmath is available on:
+#   - i*86
+#   - x86_64
+# - When available, libquadmath requires wchar support.
+config BR2_TOOLCHAIN_HAS_LIBQUADMATH
+	bool
+	default y if BR2_i386 || BR2_x86_64

Wouldn't it make more sense to add here:

depends on BR2_USE_WCHAR

(and remove it from the .mk file)?

Regards,
Arnout

Quoted 1 line
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
#3 lore raw

PATCH v3 1/14 toolchain/toolchain-common.in: add BR2_TOOLCHAIN_HAS_LIBQUADMATH hidden symbol

Hello,

Quoted 12 lines · Arnout Vandecappelle

toolchain/toolchain-common.in config BR2_TOOLCHAIN_HAS_ATOMIC · line 431

Quoted 9 lines
toolchain/toolchain-common.in +9 -0
+# - libquadmath is not needed/available on all architectures (but gcc
+#   correctly handles this already).
+# - At least, libquadmath is available on:
+#   - i*86
+#   - x86_64
+# - When available, libquadmath requires wchar support.
+config BR2_TOOLCHAIN_HAS_LIBQUADMATH
+	bool
+	default y if BR2_i386 || BR2_x86_64  

Wouldn't it make more sense to add here:

Quoted 3 lines

depends on BR2_USE_WCHAR

(and remove it from the .mk file)?

We thought about this, and discussed it with Samuel, but we had a good reason not to do it. It was yesterday so I already forgot why.

Ah, there it is. Look at this option:

config BR2_TOOLCHAIN_BUILDROOT_FORTRAN
bool "Enable Fortran support"
+ # on architecture building libquadmath, wchar is required
+ depends on !BR2_TOOLCHAIN_HAS_LIBQUADMATH || \
+ (BR2_TOOLCHAIN_HAS_LIBQUADMATH && BR2_USE_WCHAR)

How would express the dependency of Fortran is BR2_TOOLCHAIN_HAS_LIBQUADMATH handles the BR2_USE_WCHAR dependency? libquadmath is only available on i386 and x86_64, and in *this* case wchar is needed for Fortran support.

So, we want to show the Fortran option if:

* We are on an architecture that does not need libquadmath

or

* We are on an architecture that does need libquadmath, in which case we also need wchar.

Do you see a better solution ?

Best regards,

Thomas

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

PATCH v3 2/14 package/gcc: complete the logic on libquadmath

In reply to Samuel Martin

libquadmath requires wchar.

So, turn to positive logic and complete it to only enabling quadmath support when it is available.

Cc Thomas Petazzoni <[email protected]>

---
changes v2->v3:
- new patch

---
 package/gcc/gcc.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
package/gcc/gcc.mk +3 -1
index a796f47..efcaf9b 100644
@@ -107,7 +107,9 @@ HOST_GCC_COMMON_CONF_OPTS += --disable-libitm
 endif
 
 # quadmath support requires wchar
-ifeq ($(BR2_USE_WCHAR),)
+ifeq ($(BR2_USE_WCHAR)$(BR2_TOOLCHAIN_HAS_LIBQUADMATH),yy)
+HOST_GCC_COMMON_CONF_OPTS += --enable-libquadmath
+else
 HOST_GCC_COMMON_CONF_OPTS += --disable-libquadmath
 endif
 
Signature · 1 line
2.9.0
#5 lore raw

PATCH v3 3/14 package/gcc: fix fortran support

In reply to Samuel Martin

Fortran depends on libquadmath when available, make the buildroot toolchain option depends on this new hidden symbol,

[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

changes v2->v3:
- s/BR2_I386/BR2_i386/ (Thomas P.)
- use BR2_TOOLCHAIN_HAS_LIBQUADMATH to install the lib
- rephrase commit log
- update dependencies in Config.in

---
 package/gcc/Config.in.host         | 7 +++++++
 package/gcc/gcc-final/gcc-final.mk | 4 ++++
 2 files changed, 11 insertions(+)
package/gcc/Config.in.host +7 -0
index 44a72f1..8a42828 100644
@@ -118,8 +118,15 @@ config BR2_TOOLCHAIN_BUILDROOT_CXX
 	  C++ language and you want C++ libraries to be installed on
 	  your target system.
 
+comment "Fortran support needs a toolchain w/ wchar"
+	depends on BR2_TOOLCHAIN_HAS_LIBQUADMATH
+	depends on !BR2_USE_WCHAR # libquadmath
+
 config BR2_TOOLCHAIN_BUILDROOT_FORTRAN
 	bool "Enable Fortran support"
+	# on architecture building libqadmath, wchar is required
+	depends on !BR2_TOOLCHAIN_HAS_LIBQUADMATH || \
+		(BR2_TOOLCHAIN_HAS_LIBQUADMATH && BR2_USE_WCHAR)
 	help
 	  Enable this option if you want your toolchain to support the
 	  Fortran language and you want Fortran libraries to be
package/gcc/gcc-final/gcc-final.mk +4 -0
index 78ceeba..284d34c 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_TOOLCHAIN_HAS_LIBQUADMATH),y)
+HOST_GCC_FINAL_USR_LIBS += libquadmath
+endif
 endif
 
 ifeq ($(BR2_GCC_ENABLE_OPENMP),y)
Signature · 1 line
2.9.0
#6 lore raw

PATCH v3 4/14 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

changes v2->v3:
- update A/R/T tags

---
 toolchain/toolchain-common.in | 3 +++
 1 file changed, 3 insertions(+)
toolchain/toolchain-common.in +3 -0
index 96ce3d1..65df31b 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
#7 lore raw

PATCH v3 5/14 docs/manual: document dependency on fortran

In reply to Samuel Martin
Cc Thomas Petazzoni <[email protected]>

---
changes v2->v3:
- new patch

---
 docs/manual/adding-packages-directory.txt | 4 ++++
 1 file changed, 4 insertions(+)
docs/manual/adding-packages-directory.txt +4 -0
index ee4a721..dc66f00 100644
@@ -318,6 +318,10 @@ use in the comment.
 ** Dependency symbol: +BR2_INSTALL_LIBSTDCPP+
 ** Comment string: `C++`
 
+* Fortran support
+** Dependency symbol: +BR2_TOOLCHAIN_HAS_FORTRAN+
+** Comment string: `fortran`
+
 * thread support
 ** Dependency symbol: +BR2_TOOLCHAIN_HAS_THREADS+
 ** Comment string: +threads+ (unless +BR2_TOOLCHAIN_HAS_THREADS_NPTL+
Signature · 1 line
2.9.0
#8 lore raw

PATCH v3 6/14 package/gcc: select BR2_TOOLCHAIN_HAS_FORTRAN when appropriate

In reply to Samuel Martin

This is only for the Buildroot toolchain backend.

---
changes v1->v2:
- none

changes v2->v3:
- fix typo in commit title (Thomas P.)

---
 package/gcc/Config.in.host | 1 +
 1 file changed, 1 insertion(+)
package/gcc/Config.in.host +1 -0
index 8a42828..4954cc0 100644
@@ -127,6 +127,7 @@ config BR2_TOOLCHAIN_BUILDROOT_FORTRAN
 	# on architecture building libqadmath, wchar is required
 	depends on !BR2_TOOLCHAIN_HAS_LIBQUADMATH || \
 		(BR2_TOOLCHAIN_HAS_LIBQUADMATH && BR2_USE_WCHAR)
+	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
#9 lore raw

PATCH v3 7/14 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.)

changes v2->v3:
- none

---
 package/pkg-cmake.mk                | 3 +++
 support/misc/toolchainfile.cmake.in | 4 ++++
 2 files changed, 7 insertions(+)
package/pkg-cmake.mk +3 -0
index 6f0ecf9..9291523 100644
@@ -236,9 +236,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
#10 lore raw

PATCH v3 8/14 toolchain/helpers: add fortran check

In reply to Samuel Martin

---
changes v1->v2:
- none

changes v2->v3:
- use real files as input/output in the test (Thomas P.)

---
 toolchain/helpers.mk | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
toolchain/helpers.mk +18 -0
index 108fdaa..74ec944 100644
@@ -311,6 +311,24 @@ check_cplusplus = \
 	fi
 
 #
+#
+# Check that the external toolchain supports Fortran
+#
+# $1: cross-gfortran path
+#
+check_fortran = \
+	__CROSS_FC=$(strip $1) ; \
+	__o=$(BUILD_DIR)/.br-toolchain-test-fortran.tmp.f.o ; \
+	printf 'program hello\n\tprint *, "Hello Fortran!\\n"\nend program hello\n' | \
+	$${__CROSS_FC} -x f95 -o $${__o} - ; \
+	if test $$? -ne 0 ; then \
+		rm -f $${__o}* ; \
+		echo "Fortran support is selected but is not available in external toolchain" ; \
+		exit 1 ; \
+	fi ; \
+	rm -f $${__o}* \
+
+#
 # Check that the cross-compiler given in the configuration exists
 #
 # $1: cross-gcc path
Signature · 1 line
2.9.0
#11 lore raw

PATCH v3 9/14 toolchain/toolchain-external: enable fortran check when it is selected

In reply to Samuel Martin

---
changes v1->v2:
- none

changes v2->v3:
- remove CFLAGS in the check call (Thomas P.)

---
 toolchain/toolchain-external/toolchain-external.mk | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
toolchain/toolchain-external/toolchain-external.mk +4 -1
index 342bc84..4240a9b 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)),)
@@ -521,6 +522,9 @@ 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)) ; \
+	fi ; \
 	if test "$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC)" = "y" ; then \
 		$(call check_uclibc,$${SYSROOT_DIR}) ; \
 	elif test "$(BR2_TOOLCHAIN_EXTERNAL_MUSL)" = "y" ; then \
@@ -796,4 +800,3 @@ define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_CMDS
 endef
 
 $(eval $(generic-package))
-
Signature · 1 line
2.9.0
#12 lore raw

PATCH v3 10/14 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.)

changes v2->v3:
- s/BR2_I386/BR2_i386/ (Thomas P.)
- use BR2_TOOLCHAIN_HAS_LIBQUADMATH to drive the libquadmath installation

---
 toolchain/toolchain-external/toolchain-external.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
toolchain/toolchain-external/toolchain-external.mk +8 -0
index 4240a9b..d6a3d0e 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_TOOLCHAIN_HAS_LIBQUADMATH),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
#13 lore raw

PATCH v3 11/14 toolchain/toolchain-external: add knob for fortran support

In reply to Samuel Martin

---
changes v1->v2:
- none

changes v2->v3:
- drop the wchar dependency, if the external toolchain has fortran, it means all its requirements are met, so also drop the comment (Thomas P.)

---
 toolchain/toolchain-external/Config.in | 8 ++++++++
 1 file changed, 8 insertions(+)
toolchain/toolchain-external/Config.in +8 -0
index 552536e..02b82e5 100644
@@ -1020,6 +1020,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_FORTRAN
+	bool "Toolchain has Fortran support?"
+	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.
+
 config BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS
 	string "Extra toolchain libraries to be copied to target"
 	help
Signature · 1 line
2.9.0
#14 lore raw

PATCH v3 12/14 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

changes v2->v3:
- update linaro aarch64 2016.02 arm selection

---
 toolchain/toolchain-external/Config.in | 6 ++++++
 1 file changed, 6 insertions(+)
toolchain/toolchain-external/Config.in +6 -0
index 02b82e5..471a844 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/
@@ -554,6 +559,7 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
 	select BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_0
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_5
+	select BR2_TOOLCHAIN_HAS_FORTRAN
 	help
 	  Toolchain for the AArch64 architecture, from
 	  http://www.linaro.org/engineering/armv8/
Signature · 1 line
2.9.0
#15 lore raw

PATCH v3 13/14 package/fftw: add fortran support

In reply to Samuel Martin

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

changes v2->v3:
- none

---
 package/fftw/fftw.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
package/fftw/fftw.mk +2 -1
index e89671f..bc4fb08 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
#16 lore raw

PATCH v3 14/14 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/

changes v2->v3:
- change the powerpc/uclibc dependency to allow build with musl (ThomasP)
- add comment when the toolchain does not have fortran support (ThomasP)
- fix license (ThomasP)
- fix case in config options (ThomasP)

---
 package/Config.in                              |  1 +
 package/lapack/0001-case-sensitive-paths.patch | 22 ++++++++++++++++++++++
 package/lapack/Config.in                       | 20 ++++++++++++++++++++
 package/lapack/lapack.hash                     |  2 ++
 package/lapack/lapack.mk                       | 25 +++++++++++++++++++++++++
 5 files changed, 70 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 73bf32f..8305ffe 100644
@@ -1259,6 +1259,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 +20 -0
new file mode 100644
index 0000000..73b55c5
@@ -0,0 +1,20 @@
+comment "lapack/blas needs a toolchain w/ fortran"
+	depends on !(BR2_powerpc && BR2_TOOLCHAIN_USES_UCLIBC)
+	depends on !BR2_TOOLCHAIN_HAS_FORTRAN
+
+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_UCLIBC)
+	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..af6d627
@@ -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
+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
#17 lore raw

v3 cover Fortran support for all toolchains

In reply to Samuel Martin

Hello,

Quoted 10 lines · Samuel Martin

Samuel Martin (13):
toolchain/toolchain-common.in: add BR2_TOOLCHAIN_HAS_LIBQUADMATH
hidden symbol
package/gcc: complete the logic on libquadmath package/gcc: fix fortran support
toolchain: add hidden symbol for fortran support in the toolchain docs/manual: document dependency on fortran
package/gcc: select BR2_TOOLCHAIN_HAS_FORTRAN when appropriate pkg-cmake.mk: export the fortran compiler path in the CMake toolchain
file

Quoted 8 lines

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

I've applied those patches, with some minor tweaks here and there.

However, I haven't applied the lapack patch since it fails to build with the Linaro toolchain as we discussed.

Thanks,

Thomas

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

v3 cover Fortran support for all toolchains

Hi all,

Quoted 23 lines · Thomas Petazzoni

Hello,

Quoted 10 lines · Samuel Martin

Samuel Martin (13):
toolchain/toolchain-common.in: add BR2_TOOLCHAIN_HAS_LIBQUADMATH
hidden symbol
package/gcc: complete the logic on libquadmath package/gcc: fix fortran support
toolchain: add hidden symbol for fortran support in the toolchain docs/manual: document dependency on fortran
package/gcc: select BR2_TOOLCHAIN_HAS_FORTRAN when appropriate pkg-cmake.mk: export the fortran compiler path in the CMake toolchain
file

Quoted 8 lines

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

Quoted 4 lines

I've applied those patches, with some minor tweaks here and there.

However, I haven't applied the lapack patch since it fails to build with the Linaro toolchain as we discussed.

I've just rebased this patch on top of master (which includes this commit [1] from Vicente), and now lapack builds correctly with external prebuilt vendor toolchains.

[1] https://github.com/buildroot/buildroot/commit/c1d90e9bb7ad1b9737db9f6476a5bdaa27a9fa8a

Regards,

Signature · 1 line
Samuel
#19 lore raw

v3 cover Fortran support for all toolchains

Hello,

Quoted 3 lines · Samuel Martin

I've just rebased this patch on top of master (which includes this commit [1] from Vicente), and now lapack builds correctly with external prebuilt vendor toolchains.

Excellent! So it was really due to the --sysroot being missing, which makes sense.

Will you resubmit the lapack patch ?

Thomas

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

v3 cover Fortran support for all toolchains

Quoted 4 lines · Thomas Petazzoni

Hello,

On Tue, 5 Jul 2016 00:56:06 +0200, Samuel Martin wrote:

Quoted 8 lines
Quoted 3 lines

I've just rebased this patch on top of master (which includes this commit [1] from Vicente), and now lapack builds correctly with external prebuilt vendor toolchains.

Excellent! So it was really due to the --sysroot being missing, which makes sense.

Will you resubmit the lapack patch ?

I wiil.

Quoted 6 lines

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

Signature · 1 line
Samuel