Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing of gfortran version #47352

Merged
merged 5 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1140,8 +1140,11 @@ USE_BINARYBUILDER ?= 0
endif

# Auto-detect triplet once, create different versions that we use as defaults below for each BB install target
FC_VERSION := $(shell $(FC) --version 2>/dev/null | head -1)
FC_OR_CC_VERSION := $(or $(FC_VERSION),$(shell $(CC) --version 2>/dev/null | head -1))
FC_VERSION := $(shell $(FC) -dM -E - < /dev/null | grep __GNUC__ | cut -d' ' -f3)
ifeq ($(USEGCC)$(FC_VERSION),1)
FC_OR_CC_VERSION := $(shell $(CC) -dumpfullversion -dumpversion 2>/dev/null | cut -d'.' -f1)
# n.b. clang's __GNUC__ macro pretends to be gcc 4.2.1, so leave it as the empty string here if the compiler is not certain to be GCC
endif
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)")
BB_TRIPLET_LIBGFORTRAN := $(subst $(SPACE),-,$(filter-out cxx%,$(subst -,$(SPACE),$(BB_TRIPLET_LIBGFORTRAN_CXXABI))))
BB_TRIPLET_CXXABI := $(subst $(SPACE),-,$(filter-out libgfortran%,$(subst -,$(SPACE),$(BB_TRIPLET_LIBGFORTRAN_CXXABI))))
Expand Down
13 changes: 10 additions & 3 deletions contrib/normalize_triplet.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,16 @@ def p(x):
if not sys.argv[2]:
libgfortran_version = "libgfortran5"
else:
# Take the last thing that looks like a version number, and extract its major component
version_numbers = list(filter(lambda x: re.match("\d+\.\d+(\.\d+)?", x), sys.argv[2].split()))
major_ver = int(version_numbers[-1].split('.')[0])
# Grab the first number in the last word with a number
# This will be the major version number.
major_ver = -1
words = sys.argv[2].split()
for word in words[::-1]:
major_ver = re.search("[0-9]+", word)
if major_ver:
major_ver = int(major_ver.group())
break

if major_ver <= 6:
libgfortran_version = "libgfortran3"
elif major_ver <= 7:
Expand Down