CONFIG: reduce reliance on WM_ARCH_OPTION (#517)

- now only needed when specify compiling -m32 on a 64-bit system.

  Internally use the __SIZEOF_LONG__ compiler macro (gcc, icc, llvm)
  to define when long is actually an int32_t.
This commit is contained in:
Mark Olesen
2019-06-14 14:47:35 +02:00
committed by Andrew Heather
parent f0a4f8ee48
commit 16784c6b06
7 changed files with 46 additions and 54 deletions

View File

@ -74,12 +74,6 @@ export WM_COMPILER_TYPE=system
# Clang | Clang3[7-9] | Clang[4-6]0 | Icc | Cray | Arm | Pgi # Clang | Clang3[7-9] | Clang[4-6]0 | Icc | Cray | Arm | Pgi
export WM_COMPILER=Gcc export WM_COMPILER=Gcc
# [WM_ARCH_OPTION] - Memory addressing:
# = 32 | 64
# * on a 64-bit OS this can be 32 or 64
# * on a 32-bit OS, it is always 32-bit and this option is ignored
export WM_ARCH_OPTION=64
# [WM_PRECISION_OPTION] - Floating-point precision: # [WM_PRECISION_OPTION] - Floating-point precision:
# = DP | SP | SPDP # = DP | SP | SPDP
export WM_PRECISION_OPTION=DP export WM_PRECISION_OPTION=DP
@ -103,7 +97,7 @@ export WM_MPLIB=SYSTEMOPENMPI
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# (advanced / legacy) # (advanced / legacy)
#
# [FOAM_SIGFPE] - Trap floating-point exceptions. # [FOAM_SIGFPE] - Trap floating-point exceptions.
# - overrides the 'trapFpe' controlDict entry # - overrides the 'trapFpe' controlDict entry
# = true | false # = true | false
@ -126,6 +120,12 @@ export WM_MPLIB=SYSTEMOPENMPI
# = POSIX # = POSIX
#export WM_OSTYPE=POSIX #export WM_OSTYPE=POSIX
# [WM_ARCH_OPTION] - compiling with -m32 option on 64-bit system
# = 32 | 64
# * on a 64-bit OS this can be 32 or 64
# * on a 32-bit OS this option is ignored (always 32-bit)
export WM_ARCH_OPTION=64
################################################################################ ################################################################################
# Capture values of old directories to be cleaned from PATH, LD_LIBRARY_PATH # Capture values of old directories to be cleaned from PATH, LD_LIBRARY_PATH

View File

@ -22,6 +22,12 @@
setenv WM_ARCH `uname -s` # System name setenv WM_ARCH `uname -s` # System name
## if (! $?WM_OSTYPE ) setenv WM_OSTYPE POSIX # System type (POSIX is default) ## if (! $?WM_OSTYPE ) setenv WM_OSTYPE POSIX # System type (POSIX is default)
set archOption=64
if ($?WM_ARCH_OPTION) then
set archOption="$WM_ARCH_OPTION"
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_ARCH # Host compiler type (when different than target)
setenv WM_COMPILER_LIB_ARCH # Additional ending for lib directories setenv WM_COMPILER_LIB_ARCH # Additional ending for lib directories
@ -32,23 +38,22 @@ case Linux:
switch (`uname -m`) switch (`uname -m`)
case i686: case i686:
setenv WM_ARCH_OPTION 32
breaksw breaksw
case x86_64: case x86_64:
if (! $?WM_ARCH_OPTION ) setenv WM_ARCH_OPTION 64 # Default to 64-bit switch ("$archOption")
switch ($WM_ARCH_OPTION)
case 32: case 32:
setenv WM_ARCH_OPTION 32 # Need to propagate the value
setenv WM_COMPILER_ARCH 64 # 64-bit compiler, 32-bit target setenv WM_COMPILER_ARCH 64 # 64-bit compiler, 32-bit target
breaksw breaksw
case 64: case 64:
setenv WM_ARCH linux64 setenv WM_ARCH linux64
setenv WM_COMPILER_LIB_ARCH 64 # target with lib64 setenv WM_COMPILER_LIB_ARCH 64 # Target with lib64
breaksw breaksw
default: default:
echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32|64" echo "Unknown WM_ARCH_OPTION '$archOption', should be 32|64"
breaksw breaksw
endsw endsw
@ -60,13 +65,11 @@ case Linux:
case armv7l: case armv7l:
setenv WM_ARCH linuxARM7 setenv WM_ARCH linuxARM7
setenv WM_ARCH_OPTION 32
setenv WM_COMPILER_LIB_ARCH 32 setenv WM_COMPILER_LIB_ARCH 32
breaksw breaksw
case aarch64: case aarch64:
setenv WM_ARCH linuxARM64 setenv WM_ARCH linuxARM64
setenv WM_ARCH_OPTION 64
setenv WM_COMPILER_LIB_ARCH 64 setenv WM_COMPILER_LIB_ARCH 64
breaksw breaksw
@ -88,14 +91,8 @@ case Linux:
breaksw breaksw
case Darwin: # Presumably x86_64 case Darwin: # Presumably x86_64
if (! $?WM_ARCH_OPTION ) setenv WM_ARCH_OPTION 64 # Default to 64-bit
setenv WM_ARCH darwin64 setenv WM_ARCH darwin64
/bin/cat << INCOMPLETE echo "Darwin support is clang/llvm only"
===============================================================================
Darwin support (clang only) is incomplete or untested in this OpenFOAM release.
For further assistance, please contact www.OpenFOAM.com
===============================================================================
INCOMPLETE
breaksw breaksw
case SunOS*: case SunOS*:
@ -320,7 +317,7 @@ endsw
# Cleanup # Cleanup
# ~~~~~~~ # ~~~~~~~
unset archDir siteDir foundDir unset archDir siteDir foundDir archOption
unset gcc_version gccDir unset gcc_version gccDir
unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
unset clang_version clangDir unset clang_version clangDir

View File

@ -22,6 +22,8 @@
export WM_ARCH="$(uname -s)" # System name export WM_ARCH="$(uname -s)" # System name
## : ${WM_OSTYPE:=POSIX}; export WM_OSTYPE # System type (POSIX is default) ## : ${WM_OSTYPE:=POSIX}; export WM_OSTYPE # System type (POSIX is default)
archOption="${WM_ARCH_OPTION:-64}"
unset WM_ARCH_OPTION # Compiling 32-bit on 64-bit system
unset WM_COMPILER_ARCH # Host compiler type (when different than target) unset WM_COMPILER_ARCH # Host compiler type (when different than target)
unset WM_COMPILER_LIB_ARCH # Additional ending for lib directories unset WM_COMPILER_LIB_ARCH # Additional ending for lib directories
@ -33,21 +35,20 @@ Linux)
case "$(uname -m)" in case "$(uname -m)" in
i686) i686)
export WM_ARCH_OPTION=32
;; ;;
x86_64) x86_64)
: "${WM_ARCH_OPTION:=64}"; export WM_ARCH_OPTION # Default to 64-bit case "$archOption" in
case "$WM_ARCH_OPTION" in
32) 32)
export WM_ARCH_OPTION=32 # Need to propagate the value
export WM_COMPILER_ARCH=64 # 64-bit compiler, 32-bit target export WM_COMPILER_ARCH=64 # 64-bit compiler, 32-bit target
;; ;;
64) 64)
WM_ARCH=linux64 WM_ARCH=linux64
export WM_COMPILER_LIB_ARCH=64 export WM_COMPILER_LIB_ARCH=64 # Target with lib64
;; ;;
*) *)
echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32|64" 1>&2 echo "Unknown WM_ARCH_OPTION '$archOption', should be 32|64" 1>&2
;; ;;
esac esac
;; ;;
@ -58,13 +59,11 @@ Linux)
armv7l) armv7l)
WM_ARCH=linuxARM7 WM_ARCH=linuxARM7
export WM_ARCH_OPTION=32
export WM_COMPILER_LIB_ARCH=32 export WM_COMPILER_LIB_ARCH=32
;; ;;
aarch64) aarch64)
WM_ARCH=linuxARM64 WM_ARCH=linuxARM64
export WM_ARCH_OPTION=64
export WM_COMPILER_LIB_ARCH=64 export WM_COMPILER_LIB_ARCH=64
;; ;;
@ -85,14 +84,8 @@ Linux)
;; ;;
Darwin) # Presumably x86_64 Darwin) # Presumably x86_64
: ${WM_ARCH_OPTION:=64}; export WM_ARCH_OPTION # Default to 64-bit
WM_ARCH=darwin64 WM_ARCH=darwin64
/bin/cat << INCOMPLETE 1>&2 echo "Darwin support is clang/llvm only" 1>&2
===============================================================================
Darwin support (clang only) is incomplete or untested in this OpenFOAM release.
For further assistance, please contact www.OpenFOAM.com
===============================================================================
INCOMPLETE
;; ;;
SunOS*) SunOS*)
@ -314,7 +307,7 @@ esac
# Cleanup # Cleanup
# ~~~~~~~ # ~~~~~~~
unset archDir siteDir foundDir unset archDir siteDir foundDir archOption
unset gcc_version gccDir unset gcc_version gccDir
unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
unset clang_version clangDir unset clang_version clangDir

View File

@ -76,12 +76,6 @@ setenv WM_COMPILER_TYPE system
# Clang | Clang3[7-9] | Clang[4-6]0 | Icc | Cray | Arm | Pgi # Clang | Clang3[7-9] | Clang[4-6]0 | Icc | Cray | Arm | Pgi
setenv WM_COMPILER Gcc setenv WM_COMPILER Gcc
# [WM_ARCH_OPTION] - Memory addressing:
# = 32 | 64
# * on a 64-bit OS this can be 32 or 64
# * on a 32-bit OS, it is always 32-bit and this option is ignored
setenv WM_ARCH_OPTION 64
# [WM_PRECISION_OPTION] - Floating-point precision: # [WM_PRECISION_OPTION] - Floating-point precision:
# = DP | SP | SPDP # = DP | SP | SPDP
setenv WM_PRECISION_OPTION DP setenv WM_PRECISION_OPTION DP
@ -105,7 +99,7 @@ setenv WM_MPLIB SYSTEMOPENMPI
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# (advanced / legacy) # (advanced / legacy)
#
# [FOAM_SIGFPE] - Trap floating-point exceptions. # [FOAM_SIGFPE] - Trap floating-point exceptions.
# - overrides the 'trapFpe' controlDict entry # - overrides the 'trapFpe' controlDict entry
# = true | false # = true | false
@ -128,6 +122,12 @@ setenv WM_MPLIB SYSTEMOPENMPI
# = POSIX # = POSIX
#setenv WM_OSTYPE POSIX #setenv WM_OSTYPE POSIX
# [WM_ARCH_OPTION] - compiling with -m32 option on 64-bit system
# = 32 | 64
# * on a 64-bit OS this can be 32 or 64
# * on a 32-bit OS this option is ignored (always 32-bit)
setenv WM_ARCH_OPTION 64
################################################################################ ################################################################################
# Old directories to be cleaned from PATH, LD_LIBRARY_PATH # Old directories to be cleaned from PATH, LD_LIBRARY_PATH

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2014-2016 OpenFOAM Foundation | Copyright (C) 2014-2016 OpenFOAM Foundation
@ -46,6 +46,7 @@ SourceFiles
#include "pTraits.H" #include "pTraits.H"
#include "direction.H" #include "direction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
@ -119,9 +120,11 @@ inline bool read(const std::string& str, int32_t& val)
Istream& operator>>(Istream& is, int32_t& val); Istream& operator>>(Istream& is, int32_t& val);
Ostream& operator<<(Ostream& os, const int32_t val); Ostream& operator<<(Ostream& os, const int32_t val);
// 32bit OS: long is not unambiguously (int32_t | int64_t) // 32bit compilation with long as int32_t
// - resolve explicitly for input and output // - resolve explicitly for input and output
#if WM_ARCH_OPTION == 32 //
// Test works for gcc, icc, llvm.
#if (__SIZEOF_LONG__ == 4)
Istream& operator>>(Istream& is, long& val); Istream& operator>>(Istream& is, long& val);
Ostream& operator<<(Ostream& os, const long val); Ostream& operator<<(Ostream& os, const long val);
#endif #endif

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2014-2016 OpenFOAM Foundation | Copyright (C) 2014-2016 OpenFOAM Foundation
@ -125,7 +125,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const int32_t val)
} }
#if WM_ARCH_OPTION == 32 #if (__SIZEOF_LONG__ == 4)
Foam::Istream& Foam::operator>>(Istream& is, long& val) Foam::Istream& Foam::operator>>(Istream& is, long& val)
{ {
return operator>>(is, reinterpret_cast<int32_t&>(val)); return operator>>(is, reinterpret_cast<int32_t&>(val));
@ -133,8 +133,7 @@ Foam::Istream& Foam::operator>>(Istream& is, long& val)
Foam::Ostream& Foam::operator<<(Ostream& os, const long val) Foam::Ostream& Foam::operator<<(Ostream& os, const long val)
{ {
os << int32_t(val); return (os << int32_t(val));
return os;
} }
#endif #endif

View File

@ -7,7 +7,7 @@ RANLIB = ranlib
CPP = cpp CPP = cpp
LD = ld LD = ld
GFLAGS = -D$(WM_VERSION) -DWM_ARCH_OPTION=$(WM_ARCH_OPTION) \ GFLAGS = -D$(WM_VERSION) \
-DWM_$(WM_PRECISION_OPTION) -DWM_LABEL_SIZE=$(WM_LABEL_SIZE) -DWM_$(WM_PRECISION_OPTION) -DWM_LABEL_SIZE=$(WM_LABEL_SIZE)
GINC = GINC =
GLIBS = -lm GLIBS = -lm