Skip to content

Commit

Permalink
Merge pull request #705 from sourceryinstitute/default-to-gcc-10
Browse files Browse the repository at this point in the history
Update GCC default-minimum version to 10.1.0 & fix compiler version check
  • Loading branch information
rouson authored Jun 11, 2020
2 parents 78fa980 + e3b29f6 commit 78a4346
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 95 deletions.
14 changes: 6 additions & 8 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ Developer/quickstart installation guide
How to build OpenCoarrays for the very impatient
------------------------------------------------

mkdir opencoarrays-build
cd opencoarrays-build
export FC=/path/to/gfortran
export CC=/path/to/gcc
cmake /path/to/OpenCoarrays/source \
-DCMAKE_INSTALL_PREFIX=/path/to/desired/installation/location
git clone /~https://github.com/sourceryinstitute/OpenCoarrays
cd OpenCoarrays
mkdir build
cd build
cmake ..
make
make test # optional; verify build works
make install

sudo make install

Intended audience
-----------------
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2016, Sourcery Institute
Copyright (c) 2016-2020, Sourcery Institute
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion install.sh-usage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-b --install-branch [arg] Install the specified repository development branch (Examples: -b trunk or -b gcc-7-branch).
-b --install-branch [arg] Install the specified repository development branch (Examples: -b master).
-c --with-c [arg] Use specified C compiler (Example: -c /usr/local/bin/gcc).
-C --with-cxx [arg] Use specified C++ compiler (Example: -C /usr/local/bin/g++).
-d --debug Enable debug mode.
Expand Down
67 changes: 37 additions & 30 deletions prerequisites/acceptable_compiler.f90
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
! POSSIBILITY OF SUCH DAMAGE.

program main
!! input: acceptable compiler version the form major.minor.patch
!! input: acceptable compiler version in the form major.minor.patch
!! output:
!! .true. if compiler version >= acceptable version
!! .false. otherwise
Expand All @@ -47,35 +47,40 @@ program main
call get_command_argument(first_argument,acceptable_version,status=stat)
call validate_command_line( stat )

associate( compiler_version=> compiler_version() )
associate(major_version=>major(compiler_version), acceptable_major=>major(acceptable_version))
if ( major_version > acceptable_major ) then
print *,.true.
else if ( major_version == acceptable_major ) then
associate(minor_version=>minor(compiler_version), acceptable_minor=>minor(acceptable_version))
if ( minor_version > acceptable_minor ) then
print *,.true.
else if ( minor_version == acceptable_minor ) then
associate(patch_version=>patch(compiler_version), acceptable_patch=>patch(acceptable_version))
if ( patch_version >= acceptable_patch ) then
print *,.true.
else
print *,.false.
end if
end associate
else
print *,.false.
print *, meets_minimum( acceptable_version )

contains

pure function meets_minimum( required_version ) result( acceptable)
character(len=*), intent(in) :: required_version
logical acceptable

acceptable = .false. ! default result

associate( actual_version => compiler_version() )
associate(major_version=>major(actual_version), acceptable_major=>major(required_version))
if (major_version < acceptable_major) return
if (major_version > acceptable_major) then
acceptable = .true.
return
end if
associate(minor_version=>minor(actual_version), acceptable_minor=>minor(required_version))
if (minor_version < acceptable_minor) return
if (minor_version > acceptable_minor) then
acceptable = .true.
return
end if
associate(patch_version=>patch(actual_version), acceptable_patch=>patch(required_version))
if (patch_version < acceptable_patch) return
acceptable = .true.
end associate
end associate
else
print *,.false.
end if
end associate
end associate
end associate

contains
end function

subroutine validate_command_line( command_line_status )
pure subroutine validate_command_line( command_line_status )
integer, intent(in) :: command_line_status
select case(command_line_status)
case(-1)
Expand Down Expand Up @@ -118,29 +123,31 @@ pure function minor(version_string) result(minor_value)
end function

pure function patch(version_string) result(patch_value)
use iso_fortran_env, only : iostat_end
character(len=*), intent(in) :: version_string
integer patch_value
integer patch_value, io_stat
character(len=:), allocatable :: trailing_digits

associate( first_dot => scan(version_string, '.') )
associate( second_dot => first_dot + scan(version_string(first_dot+1:), '.') )
associate( first_non_digit=> second_dot + first_printable_non_digit(version_string(second_dot+1:)) )
trailing_digits = version_string( second_dot+1 : first_non_digit-1 )
read(trailing_digits,*) patch_value
associate( next_non_digit=> second_dot + next_printable_non_digit(version_string(second_dot+1:)) )
trailing_digits = version_string( second_dot+1 : next_non_digit-1 )
read(trailing_digits, * , iostat=io_stat) patch_value
end associate
end associate
end associate

end function

pure function first_printable_non_digit( string ) result(location)
pure function next_printable_non_digit( string ) result(location)
character(len=*), intent(in) :: string
integer i, location
integer, parameter :: ASCII_non_digit(*)=[(i,i=32,47),(i,i=58,126)]
character(len=1), parameter :: non_digit(*)=[( char(ASCII_non_digit(i)) , i=1, size(ASCII_non_digit) )]
character(len=size(non_digit)) non_digit_string
write(non_digit_string,'(85a)') non_digit
location = scan(string,non_digit_string)
if (location==0) location=len(string)+1
end function

end program
41 changes: 23 additions & 18 deletions prerequisites/build-functions/build_and_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,30 @@ build_and_install()
# Warn about header prerequisite on macOS Mojave or subsequent versions
if [[ $(uname) == "Darwin" ]]; then
export kernel=$(uname -r)
export Mojave="18.7.0"
export Mojave="18.0.0"
export Catalina="19.0.0"
if [ $(version $kernel) -ge $(version $Mojave) ]; then
info ""
info "______________________________________________________________________________"
info "Detected Darwin $kernel >= $Mojave (Mojave). If $package_to_build build fails"
info "due to a missing header (*.h) file, please try something like the following bash command:"
info "open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg"
info "Follow the prompts to install the missing headers. Then restart this $this_script."
info "See https://bit.ly/build-gcc-on-mojave for more details."
if [[ "${arg_y}" == "${__flag_present}" ]]; then
info "-y or --yes-to-all flag present. Proceeding with non-interactive build."
if [ $(version $kernel) -ge $(version $Catalina) ]; then
export with_sysroot="--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
else
info "Would you like to proceed anyway? (Y/n)"
read -r proceed
if [[ "${proceed}" == "n" || "${proceed}" == "N" || "${proceed}" == "no" ]]; then
info "n"
emergency "Aborting. [exit 80]"
info ""
info "______________________________________________________________________________"
info "Detected Darwin $kernel (Mojave). If $package_to_build build fails due to a"
info "missing header (*.h) file, please try something like the following bash command:"
info "open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg"
info "Follow the prompts to install the missing headers. Then restart this $this_script."
info "See https://bit.ly/build-gcc-on-mojave for more details."
if [[ "${arg_y}" == "${__flag_present}" ]]; then
info "-y or --yes-to-all flag present. Proceeding with non-interactive build."
else
info "y"
info "Would you like to proceed anyway? (Y/n)"
read -r proceed
if [[ "${proceed}" == "n" || "${proceed}" == "N" || "${proceed}" == "no" ]]; then
info "n"
emergency "Aborting. [exit 80]"
else
info "y"
fi
fi
fi
fi
Expand Down Expand Up @@ -127,8 +132,8 @@ build_and_install()
info "popd"
popd || emergency "build_and_install.sh: popd failed"
info "Configuring gcc/g++/gfortran builds with the following command:"
info "${download_path}/${package_source_directory}/configure --prefix=${install_path} --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror ${bootstrap_configure}"
"${download_path}/${package_source_directory}/configure" --prefix="${install_path}" --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror "${bootstrap_configure}"
info "${download_path}/${package_source_directory}/configure --prefix=${install_path} --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror ${bootstrap_configure} ${with_sysroot:-}"
"${download_path}/${package_source_directory}/configure" --prefix="${install_path}" --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror "${bootstrap_configure}" "${with_sysroot:-}"
info "Building with the following command: make -j ${num_threads} ${bootstrap_build}"
make -j ${num_threads} ${bootstrap_build:-}
if [[ -n "${SUDO:-}" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion prerequisites/build-functions/download_if_necessary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ download_if_necessary()
;;
esac

if [[ -f "${download_path}/${url_tail}" || -d "${download_path}/${url_tail##*branches/}" && ! -z ${url_tail##*branches/} ]]; then
if [[ -f "${download_path}/${url_tail}" || -d "${download_path}/${url_tail}" ]]; then
info "Found '${url_tail##*branches/}' in ${download_path}."
info "If it resulted from an incomplete download, building ${package_name} could fail."
if [[ "${arg_y}" == "${__flag_present}" ]]; then
Expand Down
8 changes: 6 additions & 2 deletions prerequisites/build-functions/set_or_print_default_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@ set_or_print_default_version()
exit 0
fi

if [[ $(uname) == "Darwin" ]]; then
apple_flex_version="2.5.35"
fi

[ "${package_name}" == "opencoarrays" ] &&
emergency "Please use this script with a previously downloaded opencoarrays source archive. This script does not download opencoarrays "
# This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
# denominator because, for licensing reasons, OS X only has bash 3 by default.)
# See http://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
package_version=(
"cmake:3.10.0"
"gcc:8.3.0"
"gcc:10.1.0"
"mpich:3.2"
"wget:1.16.3"
"flex:2.6.0"
"flex:${apple_flex_version:-2.6.0}"
"bison:3.0.4"
"pkg-config:0.28"
"make:4.1"
Expand Down
14 changes: 8 additions & 6 deletions prerequisites/build-functions/set_or_print_downloader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ set_or_print_downloader()
{
# Verify requirements
[ ! -z "${arg_D}" ] && [ ! -z "${arg_p:-${arg_P:-${arg_U:-${arg_V}}}}" ] &&
emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected)."
emergency "Please pass only one of {-D, -p, -P, -U, -V} or a longer equivalent (multiple detected)."

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

if [[ "${package_name}" == "ofp" ]]; then
if [[ "${package_name}" == "gcc" ]]; then
arg_b=${arg_b:-releases/gcc-${version_to_build}}
elif [[ "${package_name}" == "ofp" ]]; then
"${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh" "${@}"
exit 0
fi

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

Expand All @@ -26,15 +28,15 @@ set_or_print_downloader()
elif type wget &> /dev/null; then
gcc_prereqs_fetch=wget
elif type ftp &> /dev/null; then
if [[ "${package_name}" == "gcc" || "${package_name}" == "wget" || "${package_name}" == "make" ||
if [[ "${package_name}" == "wget" || "${package_name}" == "make" ||
"${package_name}" == "bison" || "${package_name}" == "m4" ]]; then
gcc_prereqs_fetch=ftp_url
fi
else
tried="curl, wget, and ftp"
fi

if [[ "${package_name}" == "gcc" && ! -z "${arg_b}" ]]; then
if [[ "${package_name}" == "gcc" ]]; then
if type git &> /dev/null; then
fetch=git
else
Expand All @@ -45,7 +47,7 @@ set_or_print_downloader()
fi

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

# If a printout of the download mechanism was requested, then print it and exit with normal status
Expand Down
17 changes: 2 additions & 15 deletions prerequisites/build-functions/set_or_print_url.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,9 @@ else

if [[ "${package_to_build}" == 'cmake' ]]; then
major_minor="${version_to_build%.*}"
elif [[ "${package_to_build}" == "gcc" ]]; then
if [[ -z "${arg_b}" ]]; then
gcc_url_head="https://ftpmirror.gnu.org/gcc/gcc-${version_to_build}/"
else
gcc_url_head="git://gcc.gnu.org/git/"
fi
fi
package_url_head=(
"gcc;${gcc_url_head-}"
"gcc;https://gcc.gnu.org/git/"
"wget;https://ftpmirror.gnu.org/gnu/wget/"
"m4;https://ftpmirror.gnu.org/gnu/m4/"
"pkg-config;https://pkgconfig.freedesktop.org/releases/"
Expand All @@ -51,15 +45,8 @@ else
done

# Set differing tails for GCC release downloads versus development branch checkouts
if [[ "${package_to_build}" == 'gcc' ]]; then
if [[ "${fetch}" == 'git' ]]; then
gcc_tail="gcc"
else
gcc_tail="gcc-${version_to_build}.tar.gz"
fi
fi
package_url_tail=(
"gcc;${gcc_tail-}"
"gcc;gcc"
"wget;wget-${version_to_build-}.tar.gz"
"m4;m4-${version_to_build-}.tar.bz2"
"pkg-config;pkg-config-${version_to_build-}.tar.gz"
Expand Down
3 changes: 1 addition & 2 deletions prerequisites/build.sh-usage
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
-b --install-branch [arg] Install the specified repository development branch.
-B --list-branches [arg] List the available branches in the specified package's repository.
-b --install-branch [arg] Install the specified repository development branch (Examples: -b master).
-c --with-c [arg] Use the specified C compiler. Default="gcc"
-C --with-cxx [arg] Use the specified C++ compiler. Default="g++"
-d --debug Enable debug mode.
Expand Down
29 changes: 18 additions & 11 deletions prerequisites/check_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# -- Verify whether an OpenCoarrays prerequisite meets the required minimum version number.
#
# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
# Copyright (c) 2015-2016, Sourcery, Inc.
# Copyright (c) 2015-2016, Sourcery Institute
# Copyright (c) 2015-2020, Sourcery, Inc.
# Copyright (c) 2015-2020, Sourcery Institute
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -44,7 +44,7 @@ this_script=$(basename "$0")
usage()
{
echo ""
echo " $this_script - Bash script for verifyin minimum version numbers for OpenCoarrays prerequisites"
echo " $this_script - Bash script for verifying minimum version numbers for OpenCoarrays prerequisites"
echo ""
echo " Usage (optional arguments in square brackets): "
echo " $this_script [<option>]"
Expand Down Expand Up @@ -104,21 +104,28 @@ if [[ "$verbose" == "--verbose" ]]; then
echo "$package_version_header"
fi

# Extract the text after the final space:
version=${package_version_header##* }
major=${version%%.*}
minor_patch=${version#*.}
minor=${minor_patch%%.*}
patch=${version##*.}
before_first_dot="${package_version_header%%.*}"
major="${before_first_dot##* }" # grab text after final space in remaining string

after_first_dot="${package_version_header#*.}"
minor="${after_first_dot%%.*}"

after_final_dot="${package_version_header##*.}" # grab text after final dot
if [[ "$after_final_dot" == "$after_first_dot" ]]; then
patch=""
else
patch="${after_final_dot%% *}"
fi

if [[ "$verbose" == "--verbose" ]]; then
echo "$version = $major . $minor . $patch"
echo "$major . $minor . $patch"
fi

# Extract the text after the final space:
min_major=${minimum_version%%.*}
min_minor_patch=${minimum_version#*.}
min_minor=${min_minor_patch%%.*}
min_patch=${minimum_version##*.}

if [[ "$verbose" == "--verbose" ]]; then
echo "$minimum_version = $min_major . $min_minor . $min_patch"
fi
Expand Down

0 comments on commit 78a4346

Please sign in to comment.