CONFIG: rationalize compiler tuning

- support prefs.compiler with better possibilities to provide
  overload values

STYLE: reduce code for WM_ARCH_OPTION (seldom-used)
This commit is contained in:
Mark Olesen
2020-11-07 18:11:27 +01:00
parent 67b3c01e13
commit 26ec9b5a17
13 changed files with 191 additions and 186 deletions

View File

@ -36,10 +36,17 @@ case ThirdParty:
set default_mpfr_version=mpfr-system
set default_mpc_version=mpc-system
# Clear any old values
set gcc_version=''
set clang_version=''
switch ("$WM_COMPILER")
case Gcc:
set gcc_version="$default_gcc_version"
breaksw
case Gcc102*:
set gcc_version=gcc-10.2.0
breaksw
case Gcc101*:
set gcc_version=gcc-10.1.0
breaksw
@ -121,8 +128,11 @@ case ThirdParty:
case Clang:
set clang_version="$default_clang_version"
breaksw
case Clang110*:
set clang_version=llvm-11.0.0
breaksw
case Clang100*:
set clang_version=llvm-10.0.0
set clang_version=llvm-10.0.1
breaksw
case Clang90*:
set clang_version=llvm-9.0.1
@ -155,7 +165,13 @@ case ThirdParty:
set clang_version=llvm-3.7.1
breaksw
default:
endsw
_foamEtc -config prefs.compiler ## Optional adjustments
_foamEtc -config "compiler-$WM_COMPILER" ## Per-compiler override
# Trap errors
if ( "${gcc_version}${clang_version}" == "" ) then
/bin/cat << UNKNOWN_COMPILER
===============================================================================
Warning in $WM_PROJECT_DIR/etc/config.csh/compiler:
@ -164,14 +180,11 @@ Unknown ThirdParty compiler type/version - '$WM_COMPILER'
Please check your settings
===============================================================================
UNKNOWN_COMPILER
breaksw
endsw
# Per-compiler overrides in "compiler-$WM_COMPILER" files
_foamEtc -config "compiler-$WM_COMPILER"
endif
breaksw
endsw
unset default_gcc_version default_clang_version
unset default_gmp_version default_mpfr_version default_mpc_version

View File

@ -12,10 +12,12 @@
#
# File
# config.csh/example/compiler-Gcc92
# - sourced by OpenFOAM-*/etc/config.csh/compiler
#
# Description
# Example of fine tuning compiler settings with a hook
# Example of tuning compiler settings with a hook (C-shell).
#
# Copy to etc/config.csh (or ~/.OpenFOAM/config.csh) and it will be
# sourced by OpenFOAM-*/etc/config.csh/compiler
#
#------------------------------------------------------------------------------

View File

@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018 OpenCFD Ltd.
# Copyright (C) 2018-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
# config.csh/example/paraview

View File

@ -6,26 +6,26 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017 OpenCFD Ltd.
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# 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
# config.csh/example/prefs.compiler
#
# Description
# Older example of fine tuning compiler settings for OpenFOAM
# Example of tuning compiler settings with a hook (POSIX shell).
#
# The preferred mechanism is now with a "compiler-$WM_COMPILER" file
# Copy to etc/config.sh (or ~/.OpenFOAM/config.sh) and it will be
# sourced by OpenFOAM-*/etc/config.sh/compiler
#
# Note
# The preferred mechanism is often a "compiler-$WM_COMPILER" file
# in one of the etc/ directories.
#
#------------------------------------------------------------------------------
# Load the standard versions
eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh -config -mode=o compiler`
# Modify/override compiler settings
switch ("$WM_COMPILER")
case Gcc70*:

View File

@ -13,14 +13,15 @@
#
# File
# config.csh/example/prefs.csh
# - sourced by OpenFOAM-*/etc/cshrc
#
# Description
# Example of preset variables for the OpenFOAM configuration (C-Shell shell)
# Example of preset variables for configuring OpenFOAM (C-shell)
#
# Copy to OpenFOAM-*/etc (or ~/.OpenFOAM) and it will be sourced by
# OpenFOAM-*/etc/cshrc
#
# See also
# 'foamEtcFile -help' or 'foamEtcFile -list' for information about the
# paths searched
# 'foamEtcFile -help' or 'foamEtcFile -list' for the paths searched
#
#------------------------------------------------------------------------------

View File

@ -19,7 +19,7 @@
# Settings for OpenFOAM
#
#------------------------------------------------------------------------------
setenv WM_ARCH `uname -s` # System name
setenv WM_ARCH `uname -s` # System name
set archOption=64
if ($?WM_ARCH_OPTION) then
@ -28,7 +28,7 @@ endif
unsetenv WM_ARCH_OPTION # Compiling 32-bit on 64-bit system
setenv WM_COMPILER_ARCH # Host compiler type (when different than target)
setenv WM_COMPILER_LIB_ARCH # Additional ending for lib directories
setenv WM_COMPILER_LIB_ARCH # Ending for lib directories
if (! $?WM_COMPILE_OPTION ) setenv WM_COMPILE_OPTION
# Adjust according to system and architecture
@ -37,54 +37,46 @@ case Linux:
setenv WM_ARCH linux
switch (`uname -m`)
case i686:
case x86_64:
if ( "$archOption" == "32" ) then
setenv WM_ARCH_OPTION 32 # Propagate?
setenv WM_COMPILER_ARCH 64 # 64-bit compiler, 32-bit target
else
setenv WM_ARCH linux64 # 64-bit compiler/target
setenv WM_COMPILER_LIB_ARCH 64 # Use lib64
endif
breaksw
case x86_64:
switch ("$archOption")
case 32:
setenv WM_ARCH_OPTION 32 # Need to propagate the value
setenv WM_COMPILER_ARCH 64 # 64-bit compiler, 32-bit target
breaksw
case aarch64:
setenv WM_ARCH linuxARM64
setenv WM_COMPILER_LIB_ARCH 64 # Use lib64
breaksw
case 64:
setenv WM_ARCH linux64
setenv WM_COMPILER_LIB_ARCH 64 # Target with lib64
breaksw
case armv7l:
setenv WM_ARCH linuxARM7
setenv WM_COMPILER_LIB_ARCH 32 # Use lib32
breaksw
default:
echo "Unknown WM_ARCH_OPTION '$archOption', should be 32|64"
breaksw
case ppc64:
setenv WM_ARCH linuxPPC64
setenv WM_COMPILER_LIB_ARCH 64 # Use lib64
breaksw
endsw
case ppc64le:
setenv WM_ARCH linuxPPC64le
setenv WM_COMPILER_LIB_ARCH 64 # Use lib64
breaksw
case i686:
setenv WM_ARCH linux
breaksw
case ia64:
setenv WM_ARCH linuxIA64
breaksw
case armv7l:
setenv WM_ARCH linuxARM7
setenv WM_COMPILER_LIB_ARCH 32
breaksw
case aarch64:
setenv WM_ARCH linuxARM64
setenv WM_COMPILER_LIB_ARCH 64
breaksw
case ppc64:
setenv WM_ARCH linuxPPC64
setenv WM_COMPILER_LIB_ARCH 64
breaksw
case ppc64le:
setenv WM_ARCH linuxPPC64le
setenv WM_COMPILER_LIB_ARCH 64
breaksw
default:
echo Unknown processor type `uname -m` for Linux
echo "openfoam: (`uname -m`) - unknown Linux processor type"
breaksw
endsw
@ -93,17 +85,17 @@ case Linux:
# Presume x86_64, with clang (not gcc) as system compiler
case Darwin:
setenv WM_ARCH darwin64
if ("$WM_COMPILER" == Gcc) setenv WM_COMPILER Clang
echo "Darwin support is clang/llvm only"
if ( "$WM_COMPILER" == Gcc ) setenv WM_COMPILER Clang
echo "openfoam: darwin support is clang/llvm only"
breaksw
# Presume x86_64, with mingw cross-compiled
case MINGW*:
case MSYS*:
WM_ARCH=win64
if ("$WM_COMPILER" == Gcc) setenv WM_COMPILER Mingw
if ( "$WM_COMPILER" == Gcc ) setenv WM_COMPILER Mingw
setenv WM_COMPILER_LIB_ARCH 64 # Consistent with linux64Mingw
echo "Windows support (mingw64) is runtime only"
echo "openfoam: windows support (mingw64) is runtime only"
;;
case SunOS*:
@ -115,7 +107,7 @@ default:
/bin/cat << UNSUPPORTED
===============================================================================
Operating system '$WM_ARCH' is unsupported by this OpenFOAM release.
For further assistance, please contact www.OpenFOAM.com
For further assistance, please contact www.openfoam.com
===============================================================================
UNSUPPORTED
breaksw
@ -238,10 +230,10 @@ case ThirdParty-Gcc*:
if (! $?gmp_version ) set gmp_version=gmp-system
if (! $?mpfr_version ) set mpfr_version=mpfr-system
if (! $?mpc_version ) set mpc_version=mpc-system
set gccDir=$archDir/$gcc_version
set gmpDir=$archDir/$gmp_version
set mpfrDir=$archDir/$mpfr_version
set mpcDir=$archDir/$mpc_version
set gccDir="$archDir/$gcc_version"
set gmpDir="$archDir/$gmp_version"
set mpfrDir="$archDir/$mpfr_version"
set mpcDir="$archDir/$mpc_version"
# Check that the compiler directory can be found
if ( ! -d "$gccDir" ) then
@ -257,24 +249,24 @@ Cannot find '$WM_COMPILER' compiler installation
GCC_NOT_FOUND
endif
_foamAddMan $gccDir/man
_foamAddPath $gccDir/bin
_foamAddMan "$gccDir"/man
_foamAddPath "$gccDir"/bin
# Add ThirdParty compiler libraries to run-time environment
_foamAddLib $gccDir/lib$WM_COMPILER_LIB_ARCH
_foamAddLib "$gccDir/lib$WM_COMPILER_LIB_ARCH"
# Add gmp/mpfr/mpc libraries to run-time environment.
# Require that they exist, automatically find lib64/ or lib/.
if ( "${gmpDir:t}" != "gmp-system" ) then
_foamAddLibAuto $gmpDir
setenv GMP_ARCH_PATH $gmpDir # For non-system CGAL
_foamAddLibAuto "$gmpDir"
setenv GMP_ARCH_PATH "$gmpDir" # For non-system CGAL
endif
if ( "${mpfrDir:t}" != "mpfr-system" ) then
_foamAddLibAuto $mpfrDir
setenv MPFR_ARCH_PATH $mpfrDir # For non-system CGAL
_foamAddLibAuto "$mpfrDir"
setenv MPFR_ARCH_PATH "$mpfrDir" # For non-system CGAL
endif
_foamAddLibAuto $mpcDir
_foamAddLibAuto "$mpcDir"
if ($?FOAM_VERBOSE && $?prompt) then
echo "Using ThirdParty compiler"
@ -283,7 +275,7 @@ GCC_NOT_FOUND
breaksw
case ThirdParty-Clang*:
set clangDir=$archDir/$clang_version
set clangDir="$archDir/$clang_version"
# Check that the compiler directory can be found
if ( ! -d "$clangDir" ) then
@ -299,9 +291,9 @@ Cannot find '$WM_COMPILER' compiler installation
CLANG_NOT_FOUND
endif
_foamAddMan $clangDir/man
_foamAddPath $clangDir/bin
_foamAddLib $clangDir/lib # For things like libomp (openmp) etc
_foamAddMan "$clangDir"/share/man
_foamAddPath "$clangDir"/bin
_foamAddLib "$clangDir"/lib # For things like libomp (openmp) etc
if ($?FOAM_VERBOSE && $?prompt) then
echo "Using ThirdParty compiler"