From 4dd1433133836698cc119a58a222cd6f9b74c555 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 3 Feb 2020 11:05:04 +0100 Subject: [PATCH] CONFIG: provide separate default settings for clang/gcc (fixes #1566) - the foamConfigurePaths script is quite simplistic and aggressive in what it changes. This was particularly evident when using it to change gcc/clang versions. Restructured the corresponding compiler settings to define default versions (eg, "default_gcc_version") that limits the scope of changes performed by foamConfigurePaths and makes it easier to understand if changing manually. --- bin/tools/foamConfigurePaths | 33 +++--- etc/config.csh/compiler | 25 +++-- etc/config.csh/example/compiler | 10 +- etc/config.csh/example/compiler-Gcc92 | 28 +++++ etc/config.sh/compiler | 150 +++++++++----------------- etc/config.sh/example/compiler | 16 ++- etc/config.sh/example/compiler-Gcc92 | 28 +++++ 7 files changed, 155 insertions(+), 135 deletions(-) create mode 100644 etc/config.csh/example/compiler-Gcc92 create mode 100644 etc/config.sh/example/compiler-Gcc92 diff --git a/bin/tools/foamConfigurePaths b/bin/tools/foamConfigurePaths index c7c44793814..7243e1bfdf4 100755 --- a/bin/tools/foamConfigurePaths +++ b/bin/tools/foamConfigurePaths @@ -7,11 +7,10 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2016-2019 OpenCFD Ltd. +# Copyright (C) 2016-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# <http://www.gnu.org/licenses/>. +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # foamConfigurePaths @@ -39,8 +38,8 @@ Basic Compiler -system NAME specify 'system' compiler to use (eg, Gcc, Icc,...) -third NAME specify 'ThirdParty' compiler to use (eg, Clang40,...) - -gcc VER specify 'gcc_version' for ThirdParty Gcc - -clang VER specify 'clang_version' for ThirdParty Clang + -gcc VER specify 'default_gcc_version' for ThirdParty Gcc + -clang VER specify 'default_clang_version' for ThirdParty Clang gmp-VERSION for ThirdParty gcc (gmp-system for system library) mpfr-VERSION for ThirdParty gcc (mpfr-system for system library) mpc-VERSION for ThirdParty gcc (mpc-system for system library) @@ -344,19 +343,19 @@ do ## Compiler ## -clang) - # Replace clang_version=... + # Replace default_clang_version=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/compiler clang_version "$optionValue" - replace etc/config.csh/compiler clang_version "$optionValue" + replace etc/config.sh/compiler default_clang_version "$optionValue" + replace etc/config.csh/compiler default_clang_version "$optionValue" adjusted=true shift ;; -gcc) - # Replace gcc_version=... + # Replace default_gcc_version=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/compiler gcc_version "$optionValue" - replace etc/config.csh/compiler gcc_version "$optionValue" + replace etc/config.sh/compiler default_gcc_version "$optionValue" + replace etc/config.csh/compiler default_gcc_version "$optionValue" adjusted=true shift ;; @@ -389,22 +388,22 @@ do gmp-[4-9]* | gmp-system) # gcc-related package - replace etc/config.sh/compiler gmp_version "$1" - replace etc/config.csh/compiler gmp_version "$1" + replace etc/config.sh/compiler default_gmp_version "$1" + replace etc/config.csh/compiler default_gmp_version "$1" adjusted=true ;; mpfr-[2-9]* | mpfr-system) # gcc-related package - replace etc/config.sh/compiler mpfr_version "$1" - replace etc/config.csh/compiler mpfr_version "$1" + replace etc/config.sh/compiler default_mpfr_version "$1" + replace etc/config.csh/compiler default_mpfr_version "$1" adjusted=true ;; mpc-[0-9]* | mpc-system) # gcc-related package - replace etc/config.sh/compiler mpc_version "$1" - replace etc/config.csh/compiler mpc_version "$1" + replace etc/config.sh/compiler default_mpc_version "$1" + replace etc/config.csh/compiler default_mpc_version "$1" adjusted=true ;; diff --git a/etc/config.csh/compiler b/etc/config.csh/compiler index 6ae0a03176b..8efe6cebde9 100644 --- a/etc/config.csh/compiler +++ b/etc/config.csh/compiler @@ -6,11 +6,10 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2016 OpenFOAM Foundation -# Copyright (C) 2016-2018 OpenCFD Ltd. +# Copyright (C) 2016-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# <http://www.gnu.org/licenses/>. +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/config.csh/compiler @@ -24,14 +23,19 @@ switch ("$WM_COMPILER_TYPE") case ThirdParty: - # Default versions of GMP, MPFR, MPC - override as necessary + # Default versions (CLANG, GCC, GMP, MPFR, MPC) - override as necessary - set gmp_version=gmp-system - set mpfr_version=mpfr-system - set mpc_version=mpc-system + set default_clang_version=llvm-3.7.1 + set default_gcc_version=gcc-4.8.5 + + set default_gmp_version=gmp-system + set default_mpfr_version=mpfr-system + set default_mpc_version=mpc-system switch ("$WM_COMPILER") case Gcc: + set gcc_version="$default_gcc_version" + breaksw case Gcc48*: set gcc_version=gcc-4.8.5 breaksw @@ -95,7 +99,10 @@ case ThirdParty: case Gcc92*: set gcc_version=gcc-9.2.0 breaksw + case Clang: + set clang_version="$default_clang_version" + breaksw case Clang37*: set clang_version=llvm-3.7.1 breaksw @@ -123,6 +130,7 @@ case ThirdParty: case Clang90*: set clang_version=llvm-9.0.0 breaksw + default: /bin/cat << UNKNOWN_COMPILER =============================================================================== @@ -140,4 +148,7 @@ UNKNOWN_COMPILER breaksw endsw +unset default_gcc_version default_clang_version +unset default_gmp_version default_mpfr_version default_mpc_version + #------------------------------------------------------------------------------ diff --git a/etc/config.csh/example/compiler b/etc/config.csh/example/compiler index 25e7eacddea..9355dac7902 100644 --- a/etc/config.csh/example/compiler +++ b/etc/config.csh/example/compiler @@ -9,15 +9,17 @@ # Copyright (C) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# <http://www.gnu.org/licenses/>. +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # config.csh/example/compiler # - sourced by OpenFOAM-*/etc/config.csh/settings # # Description -# Example of fine tuning ThirdParty compiler settings for OpenFOAM +# Older example of fine tuning compiler settings for OpenFOAM +# +# The preferred mechanism is now with a "compiler-$WM_COMPILER" file +# in one of the etc/ directories. # #------------------------------------------------------------------------------ @@ -26,7 +28,7 @@ eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh -config -mode=o compiler` # Modify/override compiler settings switch ("$WM_COMPILER") -case Gcc70: +case Gcc70*: set gcc_version=gcc-7.0.0 set gmp_version=gmp-6.1.2 set mpfr_version=mpfr-3.1.5 diff --git a/etc/config.csh/example/compiler-Gcc92 b/etc/config.csh/example/compiler-Gcc92 new file mode 100644 index 00000000000..9bf5baeb277 --- /dev/null +++ b/etc/config.csh/example/compiler-Gcc92 @@ -0,0 +1,28 @@ +#----------------------------------*-sh-*-------------------------------------- +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | www.openfoam.com +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# Copyright (C) 2020 OpenCFD Ltd. +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. +# +# File +# config.csh/example/compiler-Gcc92 +# - sourced by OpenFOAM-*/etc/config.csh/compiler +# +# Description +# Example of fine tuning compiler settings with a hook +# +#------------------------------------------------------------------------------ + +# Modify/override compiler settings +set gcc_version=gcc-9.2.0 +set gmp_version=gmp-6.2.0 +set mpfr_version=mpfr-4.0.2 +set mpc_version=mpc-1.1.0 + +#------------------------------------------------------------------------------ diff --git a/etc/config.sh/compiler b/etc/config.sh/compiler index a05fbe392e6..36e4fda3bb1 100644 --- a/etc/config.sh/compiler +++ b/etc/config.sh/compiler @@ -6,11 +6,10 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2016-2018 OpenCFD Ltd. +# Copyright (C) 2016-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# <http://www.gnu.org/licenses/>. +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/config.sh/compiler @@ -24,102 +23,56 @@ case "$WM_COMPILER_TYPE" in ThirdParty) - # Default versions of GMP, MPFR, MPC - override as necessary - gmp_version=gmp-system - mpfr_version=mpfr-system - mpc_version=mpc-system + # Default versions (CLANG, GCC, GMP, MPFR, MPC) - override as necessary + + default_clang_version=llvm-3.7.1 + default_gcc_version=gcc-4.8.5 + + default_gmp_version=gmp-system + default_mpfr_version=mpfr-system + default_mpc_version=mpc-system + + gmp_version="$default_gmp_version" + mpfr_version="$default_mpfr_version" + mpc_version="$default_mpc_version" case "$WM_COMPILER" in - Gcc | Gcc48*) - gcc_version=gcc-4.8.5 - ;; - Gcc49*) - gcc_version=gcc-4.9.4 - ;; - Gcc51*) - gcc_version=gcc-5.1.0 - ;; - Gcc52*) - gcc_version=gcc-5.2.0 - ;; - Gcc53*) - gcc_version=gcc-5.3.0 - ;; - Gcc54*) - gcc_version=gcc-5.4.0 - ;; - Gcc55*) - gcc_version=gcc-5.5.0 - ;; - Gcc61*) - gcc_version=gcc-6.1.0 - ;; - Gcc62*) - gcc_version=gcc-6.2.0 - ;; - Gcc63*) - gcc_version=gcc-6.3.0 - ;; - Gcc64*) - gcc_version=gcc-6.4.0 - ;; - Gcc65*) - gcc_version=gcc-6.5.0 - ;; - Gcc71*) - gcc_version=gcc-7.1.0 - ;; - Gcc72*) - gcc_version=gcc-7.2.0 - ;; - Gcc73*) - gcc_version=gcc-7.3.0 - ;; - Gcc74*) - gcc_version=gcc-7.4.0 - ;; - Gcc81*) - gcc_version=gcc-8.1.0 - ;; - Gcc82*) - gcc_version=gcc-8.2.0 - ;; - Gcc83*) - gcc_version=gcc-8.3.0 - ;; - Gcc91*) - gcc_version=gcc-9.1.0 - ;; - Gcc92*) - gcc_version=gcc-9.2.0 - ;; - Clang | Clang37*) - clang_version=llvm-3.7.1 - ;; - Clang38*) - clang_version=llvm-3.8.1 - ;; - Clang39*) - clang_version=llvm-3.9.1 - ;; - Clang40*) - clang_version=llvm-4.0.1 - ;; - Clang50*) - clang_version=llvm-5.0.2 - ;; - Clang60*) - clang_version=llvm-6.0.1 - ;; - Clang70*) - clang_version=llvm-7.0.1 - ;; - Clang80*) - clang_version=llvm-8.0.1 - ;; - Clang90*) - clang_version=llvm-9.0.0 - ;; + Gcc) gcc_version="$default_gcc_version" ;; + Gcc48*) gcc_version=gcc-4.8.5 ;; + Gcc49*) gcc_version=gcc-4.9.4 ;; + Gcc51*) gcc_version=gcc-5.1.0 ;; + Gcc52*) gcc_version=gcc-5.2.0 ;; + Gcc53*) gcc_version=gcc-5.3.0 ;; + Gcc54*) gcc_version=gcc-5.4.0 ;; + Gcc55*) gcc_version=gcc-5.5.0 ;; + Gcc61*) gcc_version=gcc-6.1.0 ;; + Gcc62*) gcc_version=gcc-6.2.0 ;; + Gcc63*) gcc_version=gcc-6.3.0 ;; + Gcc64*) gcc_version=gcc-6.4.0 ;; + Gcc65*) gcc_version=gcc-6.5.0 ;; + Gcc71*) gcc_version=gcc-7.1.0 ;; + Gcc72*) gcc_version=gcc-7.2.0 ;; + Gcc73*) gcc_version=gcc-7.3.0 ;; + Gcc74*) gcc_version=gcc-7.4.0 ;; + Gcc75*) gcc_version=gcc-7.5.0 ;; + Gcc81*) gcc_version=gcc-8.1.0 ;; + Gcc82*) gcc_version=gcc-8.2.0 ;; + Gcc83*) gcc_version=gcc-8.3.0 ;; + Gcc91*) gcc_version=gcc-9.1.0 ;; + Gcc92*) gcc_version=gcc-9.2.0 ;; + + Clang) clang_version="$default_clang_version" ;; + Clang37*) clang_version=llvm-3.7.1 ;; + Clang38*) clang_version=llvm-3.8.1 ;; + Clang39*) clang_version=llvm-3.9.1 ;; + Clang40*) clang_version=llvm-4.0.1 ;; + Clang50*) clang_version=llvm-5.0.2 ;; + Clang60*) clang_version=llvm-6.0.1 ;; + Clang70*) clang_version=llvm-7.0.1 ;; + Clang71*) clang_version=llvm-7.1.0 ;; + Clang80*) clang_version=llvm-8.0.1 ;; + Clang90*) clang_version=llvm-9.0.0 ;; + *) /bin/cat << UNKNOWN_COMPILER 1>&2 =============================================================================== @@ -137,4 +90,7 @@ UNKNOWN_COMPILER ;; esac +unset default_gcc_version default_clang_version +unset default_gmp_version default_mpfr_version default_mpc_version + #------------------------------------------------------------------------------ diff --git a/etc/config.sh/example/compiler b/etc/config.sh/example/compiler index f55a55b4586..385ef8ae7c4 100644 --- a/etc/config.sh/example/compiler +++ b/etc/config.sh/example/compiler @@ -9,15 +9,17 @@ # Copyright (C) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# <http://www.gnu.org/licenses/>. +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # config.sh/example/compiler # - sourced by OpenFOAM-*/etc/config.sh/settings # # Description -# Example of fine tuning compiler versions and settings for OpenFOAM +# Older example of fine tuning compiler settings for OpenFOAM. +# +# The preferred mechanism is now with a "compiler-$WM_COMPILER" file +# in one of the etc/ directories. # #------------------------------------------------------------------------------ @@ -26,18 +28,12 @@ eval $($WM_PROJECT_DIR/bin/foamEtcFile -sh -config -mode=o compiler) # Modify/override compiler settings case "$WM_COMPILER" in -Gcc70) +Gcc70*) gcc_version=gcc-7.0.0 gmp_version=gmp-6.1.2 mpfr_version=mpfr-3.1.5 mpc_version=mpc-1.0.3 ;; -Gcc48u) - # Example of using the system GCC 4.8 in Ubuntu 15.10. Keep in mind you - # will also need to create the respective directory in "wmake/rules" - export CC='gcc-4.8' - export CXX='g++-4.8' - ;; esac #------------------------------------------------------------------------------ diff --git a/etc/config.sh/example/compiler-Gcc92 b/etc/config.sh/example/compiler-Gcc92 new file mode 100644 index 00000000000..75b4de4cfad --- /dev/null +++ b/etc/config.sh/example/compiler-Gcc92 @@ -0,0 +1,28 @@ +#----------------------------------*-sh-*-------------------------------------- +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | www.openfoam.com +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# Copyright (C) 2020 OpenCFD Ltd. +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. +# +# File +# config.sh/example/compiler-Gcc92 +# - sourced by OpenFOAM-*/etc/config.sh/compiler +# +# Description +# Example of fine tuning compiler settings with a hook +# +#------------------------------------------------------------------------------ + +# Modify/override compiler settings +gcc_version=gcc-9.2.0 +gmp_version=gmp-6.2.0 +mpfr_version=mpfr-4.0.2 +mpc_version=mpc-1.1.0 + +#------------------------------------------------------------------------------ -- GitLab