Skip to content

Commit 6b91bbb

Browse files
authored
Allow building without gfortran if we're just using everything from BB (#39338)
On systems where we don't have `gfortran` installed, there's no reason to require it, because nowadays we get everything from Yggdrasil anyway. Simply soldier on and assume that the user wants the latest support libraries, unless they are trying to build from source.
1 parent 658ee46 commit 6b91bbb

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

Make.inc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,9 @@ USE_BINARYBUILDER ?= 0
11731173
endif
11741174

11751175
# Auto-detect triplet once, create different versions that we use as defaults below for each BB install target
1176-
BB_TRIPLET_LIBGFORTRAN_CXXABI := $(shell $(call invoke_python,$(JULIAHOME)/contrib/normalize_triplet.py) $(or $(XC_HOST),$(XC_HOST),$(BUILD_MACHINE)) "$(shell $(FC) --version | head -1)" "$(or $(shell echo '\#include <string>' | $(CXX) $(CXXFLAGS) -x c++ -dM -E - | grep _GLIBCXX_USE_CXX11_ABI | awk '{ print $$3 }' ),1)")
1176+
FC_VERSION := $(shell $(FC) --version 2>/dev/null | head -1)
1177+
FC_OR_CC_VERISON := $(or $(FC_VERSION),$(shell $(CC) --version 2>/dev/null | head -1))
1178+
BB_TRIPLET_LIBGFORTRAN_CXXABI := $(shell $(call invoke_python,$(JULIAHOME)/contrib/normalize_triplet.py) $(or $(XC_HOST),$(XC_HOST),$(BUILD_MACHINE)) "$(FC_OR_CC_VERSION)" "$(or $(shell echo '\#include <string>' | $(CXX) $(CXXFLAGS) -x c++ -dM -E - | grep _GLIBCXX_USE_CXX11_ABI | awk '{ print $$3 }' ),1)")
11771179
BB_TRIPLET_LIBGFORTRAN := $(subst $(SPACE),-,$(filter-out cxx%,$(subst -,$(SPACE),$(BB_TRIPLET_LIBGFORTRAN_CXXABI))))
11781180
BB_TRIPLET_CXXABI := $(subst $(SPACE),-,$(filter-out libgfortran%,$(subst -,$(SPACE),$(BB_TRIPLET_LIBGFORTRAN_CXXABI))))
11791181
BB_TRIPLET := $(subst $(SPACE),-,$(filter-out cxx%,$(filter-out libgfortran%,$(subst -,$(SPACE),$(BB_TRIPLET_LIBGFORTRAN_CXXABI)))))
@@ -1196,6 +1198,14 @@ endef
11961198
$(foreach proj,$(BB_PROJECTS),$(eval $(call SET_BB_DEFAULT,$(proj))))
11971199

11981200

1201+
# Warn if the user tries to build something that requires `gfortran` but they don't have it installed.
1202+
ifeq ($(FC_VERSION),)
1203+
ifneq ($(USE_BINARYBUILDER_OPENBLAS)$(USE_BINARYBUILDER_SUITESPARSE),11)
1204+
$(error "Attempting to build OpenBLAS or SuiteSparse without a functioning fortran compiler!")
1205+
endif
1206+
endif
1207+
1208+
11991209
# OS specific stuff
12001210

12011211
# install_name_tool

contrib/normalize_triplet.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,22 @@ def p(x):
106106

107107
# If the user passes in a GCC version (like 8.2.0) use that to force a
108108
# "-libgfortran5" tag at the end of the triplet, but only if it has otherwise
109-
# not been specified
109+
# not been specified.
110110
if libgfortran_version == "blank_libgfortran":
111111
if len(sys.argv) >= 3:
112-
libgfortran_version = {
113-
"4": "libgfortran3",
114-
"5": "libgfortran3",
115-
"6": "libgfortran3",
116-
"7": "libgfortran4",
117-
"8": "libgfortran5",
118-
"9": "libgfortran5",
119-
"10": "libgfortran5",
120-
"11": "libgfortran5",
121-
}[list(filter(lambda x: re.match("\d+\.\d+(\.\d+)?", x), sys.argv[2].split()))[-1].split('.')[0]]
112+
# If there was no gfortran/gcc version passed in, default to the latest libgfortran version
113+
if not sys.argv[2]:
114+
libgfortran_version = "libgfortran5"
115+
else:
116+
# Take the last thing that looks like a version number, and extract its major component
117+
version_numbers = list(filter(lambda x: re.match("\d+\.\d+(\.\d+)?", x), sys.argv[2].split()))
118+
major_ver = int(version_numbers[-1].split('.')[0])
119+
if major_ver <= 6:
120+
libgfortran_version = "libgfortran3"
121+
elif major_ver <= 7:
122+
libgfortran_version = "libgfortran4"
123+
else:
124+
libgfortran_version = "libgfortran5"
122125

123126
if cxx_abi == "blank_cxx_abi":
124127
if len(sys.argv) == 4:

0 commit comments

Comments
 (0)