Skip to content

Commit 78a4346

Browse files
author
Damian Rouson
authored
Merge pull request #705 from sourceryinstitute/default-to-gcc-10
Update GCC default-minimum version to 10.1.0 & fix compiler version check
2 parents 78fa980 + e3b29f6 commit 78a4346

11 files changed

+104
-95
lines changed

INSTALL

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ Developer/quickstart installation guide
1111
How to build OpenCoarrays for the very impatient
1212
------------------------------------------------
1313

14-
mkdir opencoarrays-build
15-
cd opencoarrays-build
16-
export FC=/path/to/gfortran
17-
export CC=/path/to/gcc
18-
cmake /path/to/OpenCoarrays/source \
19-
-DCMAKE_INSTALL_PREFIX=/path/to/desired/installation/location
14+
git clone https://github.com/sourceryinstitute/OpenCoarrays
15+
cd OpenCoarrays
16+
mkdir build
17+
cd build
18+
cmake ..
2019
make
2120
make test # optional; verify build works
22-
make install
23-
21+
sudo make install
2422

2523
Intended audience
2624
-----------------

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2016, Sourcery Institute
3+
Copyright (c) 2016-2020, Sourcery Institute
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

install.sh-usage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-b --install-branch [arg] Install the specified repository development branch (Examples: -b trunk or -b gcc-7-branch).
1+
-b --install-branch [arg] Install the specified repository development branch (Examples: -b master).
22
-c --with-c [arg] Use specified C compiler (Example: -c /usr/local/bin/gcc).
33
-C --with-cxx [arg] Use specified C++ compiler (Example: -C /usr/local/bin/g++).
44
-d --debug Enable debug mode.

prerequisites/acceptable_compiler.f90

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
! POSSIBILITY OF SUCH DAMAGE.
3434

3535
program main
36-
!! input: acceptable compiler version the form major.minor.patch
36+
!! input: acceptable compiler version in the form major.minor.patch
3737
!! output:
3838
!! .true. if compiler version >= acceptable version
3939
!! .false. otherwise
@@ -47,35 +47,40 @@ program main
4747
call get_command_argument(first_argument,acceptable_version,status=stat)
4848
call validate_command_line( stat )
4949

50-
associate( compiler_version=> compiler_version() )
51-
associate(major_version=>major(compiler_version), acceptable_major=>major(acceptable_version))
52-
if ( major_version > acceptable_major ) then
53-
print *,.true.
54-
else if ( major_version == acceptable_major ) then
55-
associate(minor_version=>minor(compiler_version), acceptable_minor=>minor(acceptable_version))
56-
if ( minor_version > acceptable_minor ) then
57-
print *,.true.
58-
else if ( minor_version == acceptable_minor ) then
59-
associate(patch_version=>patch(compiler_version), acceptable_patch=>patch(acceptable_version))
60-
if ( patch_version >= acceptable_patch ) then
61-
print *,.true.
62-
else
63-
print *,.false.
64-
end if
65-
end associate
66-
else
67-
print *,.false.
50+
print *, meets_minimum( acceptable_version )
51+
52+
contains
53+
54+
pure function meets_minimum( required_version ) result( acceptable)
55+
character(len=*), intent(in) :: required_version
56+
logical acceptable
57+
58+
acceptable = .false. ! default result
59+
60+
associate( actual_version => compiler_version() )
61+
associate(major_version=>major(actual_version), acceptable_major=>major(required_version))
62+
if (major_version < acceptable_major) return
63+
if (major_version > acceptable_major) then
64+
acceptable = .true.
65+
return
66+
end if
67+
associate(minor_version=>minor(actual_version), acceptable_minor=>minor(required_version))
68+
if (minor_version < acceptable_minor) return
69+
if (minor_version > acceptable_minor) then
70+
acceptable = .true.
71+
return
6872
end if
73+
associate(patch_version=>patch(actual_version), acceptable_patch=>patch(required_version))
74+
if (patch_version < acceptable_patch) return
75+
acceptable = .true.
76+
end associate
6977
end associate
70-
else
71-
print *,.false.
72-
end if
78+
end associate
7379
end associate
74-
end associate
7580

76-
contains
81+
end function
7782

78-
subroutine validate_command_line( command_line_status )
83+
pure subroutine validate_command_line( command_line_status )
7984
integer, intent(in) :: command_line_status
8085
select case(command_line_status)
8186
case(-1)
@@ -118,29 +123,31 @@ pure function minor(version_string) result(minor_value)
118123
end function
119124

120125
pure function patch(version_string) result(patch_value)
126+
use iso_fortran_env, only : iostat_end
121127
character(len=*), intent(in) :: version_string
122-
integer patch_value
128+
integer patch_value, io_stat
123129
character(len=:), allocatable :: trailing_digits
124130

125131
associate( first_dot => scan(version_string, '.') )
126132
associate( second_dot => first_dot + scan(version_string(first_dot+1:), '.') )
127-
associate( first_non_digit=> second_dot + first_printable_non_digit(version_string(second_dot+1:)) )
128-
trailing_digits = version_string( second_dot+1 : first_non_digit-1 )
129-
read(trailing_digits,*) patch_value
133+
associate( next_non_digit=> second_dot + next_printable_non_digit(version_string(second_dot+1:)) )
134+
trailing_digits = version_string( second_dot+1 : next_non_digit-1 )
135+
read(trailing_digits, * , iostat=io_stat) patch_value
130136
end associate
131137
end associate
132138
end associate
133139

134140
end function
135141

136-
pure function first_printable_non_digit( string ) result(location)
142+
pure function next_printable_non_digit( string ) result(location)
137143
character(len=*), intent(in) :: string
138144
integer i, location
139145
integer, parameter :: ASCII_non_digit(*)=[(i,i=32,47),(i,i=58,126)]
140146
character(len=1), parameter :: non_digit(*)=[( char(ASCII_non_digit(i)) , i=1, size(ASCII_non_digit) )]
141147
character(len=size(non_digit)) non_digit_string
142148
write(non_digit_string,'(85a)') non_digit
143149
location = scan(string,non_digit_string)
150+
if (location==0) location=len(string)+1
144151
end function
145152

146153
end program

prerequisites/build-functions/build_and_install.sh

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,30 @@ build_and_install()
7979
# Warn about header prerequisite on macOS Mojave or subsequent versions
8080
if [[ $(uname) == "Darwin" ]]; then
8181
export kernel=$(uname -r)
82-
export Mojave="18.7.0"
82+
export Mojave="18.0.0"
83+
export Catalina="19.0.0"
8384
if [ $(version $kernel) -ge $(version $Mojave) ]; then
84-
info ""
85-
info "______________________________________________________________________________"
86-
info "Detected Darwin $kernel >= $Mojave (Mojave). If $package_to_build build fails"
87-
info "due to a missing header (*.h) file, please try something like the following bash command:"
88-
info "open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg"
89-
info "Follow the prompts to install the missing headers. Then restart this $this_script."
90-
info "See https://bit.ly/build-gcc-on-mojave for more details."
91-
if [[ "${arg_y}" == "${__flag_present}" ]]; then
92-
info "-y or --yes-to-all flag present. Proceeding with non-interactive build."
85+
if [ $(version $kernel) -ge $(version $Catalina) ]; then
86+
export with_sysroot="--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
9387
else
94-
info "Would you like to proceed anyway? (Y/n)"
95-
read -r proceed
96-
if [[ "${proceed}" == "n" || "${proceed}" == "N" || "${proceed}" == "no" ]]; then
97-
info "n"
98-
emergency "Aborting. [exit 80]"
88+
info ""
89+
info "______________________________________________________________________________"
90+
info "Detected Darwin $kernel (Mojave). If $package_to_build build fails due to a"
91+
info "missing header (*.h) file, please try something like the following bash command:"
92+
info "open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg"
93+
info "Follow the prompts to install the missing headers. Then restart this $this_script."
94+
info "See https://bit.ly/build-gcc-on-mojave for more details."
95+
if [[ "${arg_y}" == "${__flag_present}" ]]; then
96+
info "-y or --yes-to-all flag present. Proceeding with non-interactive build."
9997
else
100-
info "y"
98+
info "Would you like to proceed anyway? (Y/n)"
99+
read -r proceed
100+
if [[ "${proceed}" == "n" || "${proceed}" == "N" || "${proceed}" == "no" ]]; then
101+
info "n"
102+
emergency "Aborting. [exit 80]"
103+
else
104+
info "y"
105+
fi
101106
fi
102107
fi
103108
fi
@@ -127,8 +132,8 @@ build_and_install()
127132
info "popd"
128133
popd || emergency "build_and_install.sh: popd failed"
129134
info "Configuring gcc/g++/gfortran builds with the following command:"
130-
info "${download_path}/${package_source_directory}/configure --prefix=${install_path} --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror ${bootstrap_configure}"
131-
"${download_path}/${package_source_directory}/configure" --prefix="${install_path}" --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror "${bootstrap_configure}"
135+
info "${download_path}/${package_source_directory}/configure --prefix=${install_path} --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror ${bootstrap_configure} ${with_sysroot:-}"
136+
"${download_path}/${package_source_directory}/configure" --prefix="${install_path}" --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror "${bootstrap_configure}" "${with_sysroot:-}"
132137
info "Building with the following command: make -j ${num_threads} ${bootstrap_build}"
133138
make -j ${num_threads} ${bootstrap_build:-}
134139
if [[ -n "${SUDO:-}" ]]; then

prerequisites/build-functions/download_if_necessary.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ download_if_necessary()
5858
;;
5959
esac
6060

61-
if [[ -f "${download_path}/${url_tail}" || -d "${download_path}/${url_tail##*branches/}" && ! -z ${url_tail##*branches/} ]]; then
61+
if [[ -f "${download_path}/${url_tail}" || -d "${download_path}/${url_tail}" ]]; then
6262
info "Found '${url_tail##*branches/}' in ${download_path}."
6363
info "If it resulted from an incomplete download, building ${package_name} could fail."
6464
if [[ "${arg_y}" == "${__flag_present}" ]]; then

prerequisites/build-functions/set_or_print_default_version.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,21 @@ set_or_print_default_version()
2020
exit 0
2121
fi
2222

23+
if [[ $(uname) == "Darwin" ]]; then
24+
apple_flex_version="2.5.35"
25+
fi
26+
2327
[ "${package_name}" == "opencoarrays" ] &&
2428
emergency "Please use this script with a previously downloaded opencoarrays source archive. This script does not download opencoarrays "
2529
# This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
2630
# denominator because, for licensing reasons, OS X only has bash 3 by default.)
2731
# See http://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
2832
package_version=(
2933
"cmake:3.10.0"
30-
"gcc:8.3.0"
34+
"gcc:10.1.0"
3135
"mpich:3.2"
3236
"wget:1.16.3"
33-
"flex:2.6.0"
37+
"flex:${apple_flex_version:-2.6.0}"
3438
"bison:3.0.4"
3539
"pkg-config:0.28"
3640
"make:4.1"

prerequisites/build-functions/set_or_print_downloader.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ set_or_print_downloader()
77
{
88
# Verify requirements
99
[ ! -z "${arg_D}" ] && [ ! -z "${arg_p:-${arg_P:-${arg_U:-${arg_V}}}}" ] &&
10-
emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
10+
emergency "Please pass only one of {-D, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
1111

1212
package_name="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}"
1313

14-
if [[ "${package_name}" == "ofp" ]]; then
14+
if [[ "${package_name}" == "gcc" ]]; then
15+
arg_b=${arg_b:-releases/gcc-${version_to_build}}
16+
elif [[ "${package_name}" == "ofp" ]]; then
1517
"${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh" "${@}"
1618
exit 0
1719
fi
1820

1921
# Choose the first available download mechanism, prioritizing first any absolute requirement
20-
# (git for gcc development branches) and second robustness:
22+
# (git for gcc) and second robustness:
2123
info "Checking available download mechanisms: ftp, wget, and curl."
2224
info "\${package_name}=${package_name} \${arg_b:-}=${arg_b:-}"
2325

@@ -26,15 +28,15 @@ set_or_print_downloader()
2628
elif type wget &> /dev/null; then
2729
gcc_prereqs_fetch=wget
2830
elif type ftp &> /dev/null; then
29-
if [[ "${package_name}" == "gcc" || "${package_name}" == "wget" || "${package_name}" == "make" ||
31+
if [[ "${package_name}" == "wget" || "${package_name}" == "make" ||
3032
"${package_name}" == "bison" || "${package_name}" == "m4" ]]; then
3133
gcc_prereqs_fetch=ftp_url
3234
fi
3335
else
3436
tried="curl, wget, and ftp"
3537
fi
3638

37-
if [[ "${package_name}" == "gcc" && ! -z "${arg_b}" ]]; then
39+
if [[ "${package_name}" == "gcc" ]]; then
3840
if type git &> /dev/null; then
3941
fetch=git
4042
else
@@ -45,7 +47,7 @@ set_or_print_downloader()
4547
fi
4648

4749
if [[ -z "${fetch:-}" ]]; then
48-
emergency "No available download mechanism. Option tried: ${tried}"
50+
emergency "No available download mechanism. Option(s) tried: ${tried}"
4951
fi
5052

5153
# If a printout of the download mechanism was requested, then print it and exit with normal status

prerequisites/build-functions/set_or_print_url.sh

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,9 @@ else
1919

2020
if [[ "${package_to_build}" == 'cmake' ]]; then
2121
major_minor="${version_to_build%.*}"
22-
elif [[ "${package_to_build}" == "gcc" ]]; then
23-
if [[ -z "${arg_b}" ]]; then
24-
gcc_url_head="https://ftpmirror.gnu.org/gcc/gcc-${version_to_build}/"
25-
else
26-
gcc_url_head="git://gcc.gnu.org/git/"
27-
fi
2822
fi
2923
package_url_head=(
30-
"gcc;${gcc_url_head-}"
24+
"gcc;https://gcc.gnu.org/git/"
3125
"wget;https://ftpmirror.gnu.org/gnu/wget/"
3226
"m4;https://ftpmirror.gnu.org/gnu/m4/"
3327
"pkg-config;https://pkgconfig.freedesktop.org/releases/"
@@ -51,15 +45,8 @@ else
5145
done
5246

5347
# Set differing tails for GCC release downloads versus development branch checkouts
54-
if [[ "${package_to_build}" == 'gcc' ]]; then
55-
if [[ "${fetch}" == 'git' ]]; then
56-
gcc_tail="gcc"
57-
else
58-
gcc_tail="gcc-${version_to_build}.tar.gz"
59-
fi
60-
fi
6148
package_url_tail=(
62-
"gcc;${gcc_tail-}"
49+
"gcc;gcc"
6350
"wget;wget-${version_to_build-}.tar.gz"
6451
"m4;m4-${version_to_build-}.tar.bz2"
6552
"pkg-config;pkg-config-${version_to_build-}.tar.gz"

prerequisites/build.sh-usage

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
-b --install-branch [arg] Install the specified repository development branch.
2-
-B --list-branches [arg] List the available branches in the specified package's repository.
1+
-b --install-branch [arg] Install the specified repository development branch (Examples: -b master).
32
-c --with-c [arg] Use the specified C compiler. Default="gcc"
43
-C --with-cxx [arg] Use the specified C++ compiler. Default="g++"
54
-d --debug Enable debug mode.

prerequisites/check_version.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# -- Verify whether an OpenCoarrays prerequisite meets the required minimum version number.
66
#
77
# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
8-
# Copyright (c) 2015-2016, Sourcery, Inc.
9-
# Copyright (c) 2015-2016, Sourcery Institute
8+
# Copyright (c) 2015-2020, Sourcery, Inc.
9+
# Copyright (c) 2015-2020, Sourcery Institute
1010
# All rights reserved.
1111
#
1212
# Redistribution and use in source and binary forms, with or without modification,
@@ -44,7 +44,7 @@ this_script=$(basename "$0")
4444
usage()
4545
{
4646
echo ""
47-
echo " $this_script - Bash script for verifyin minimum version numbers for OpenCoarrays prerequisites"
47+
echo " $this_script - Bash script for verifying minimum version numbers for OpenCoarrays prerequisites"
4848
echo ""
4949
echo " Usage (optional arguments in square brackets): "
5050
echo " $this_script [<option>]"
@@ -104,21 +104,28 @@ if [[ "$verbose" == "--verbose" ]]; then
104104
echo "$package_version_header"
105105
fi
106106

107-
# Extract the text after the final space:
108-
version=${package_version_header##* }
109-
major=${version%%.*}
110-
minor_patch=${version#*.}
111-
minor=${minor_patch%%.*}
112-
patch=${version##*.}
107+
before_first_dot="${package_version_header%%.*}"
108+
major="${before_first_dot##* }" # grab text after final space in remaining string
109+
110+
after_first_dot="${package_version_header#*.}"
111+
minor="${after_first_dot%%.*}"
112+
113+
after_final_dot="${package_version_header##*.}" # grab text after final dot
114+
if [[ "$after_final_dot" == "$after_first_dot" ]]; then
115+
patch=""
116+
else
117+
patch="${after_final_dot%% *}"
118+
fi
119+
113120
if [[ "$verbose" == "--verbose" ]]; then
114-
echo "$version = $major . $minor . $patch"
121+
echo "$major . $minor . $patch"
115122
fi
116123

117-
# Extract the text after the final space:
118124
min_major=${minimum_version%%.*}
119125
min_minor_patch=${minimum_version#*.}
120126
min_minor=${min_minor_patch%%.*}
121127
min_patch=${minimum_version##*.}
128+
122129
if [[ "$verbose" == "--verbose" ]]; then
123130
echo "$minimum_version = $min_major . $min_minor . $min_patch"
124131
fi

0 commit comments

Comments
 (0)