From de7ac041467bd35b0d24c699ebdacc142e9abbfc Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 15 Jan 2018 13:04:49 +0100 Subject: [PATCH] COMP: adjustments to makeCGAL for compilation with alternative mpfr/gmp - document special steps for using ThirdParty mpfr/gmp with clang etc --- BUILD.md | 64 +++++++++++++++++--- makeCGAL | 179 +++++++++++++++++++++++++++++++++++++++---------------- makeGcc | 6 +- 3 files changed, 188 insertions(+), 61 deletions(-) diff --git a/BUILD.md b/BUILD.md index 8c9bffa..ec11a64 100644 --- a/BUILD.md +++ b/BUILD.md @@ -83,9 +83,9 @@ automatically as part of the top-level OpenFOAM `Allwmake`. Nonetheless it may be necessary or useful to build various ThirdParty components prior to building OpenFOAM itself. +### Bootstrapping *(optional)* -### Build Sequence -1. `makeGcc` _or_ `makeLLVM` *(optional)* +* `makeGcc` _or_ `makeLLVM` - Makes a third-party [gcc](#gcc-compiler) or [clang](#clang-compiler) installation, which is needed if the system gcc is [too old](#gcc-compiler). If your system compiler is recent enough, you can skip this step. @@ -93,30 +93,75 @@ ThirdParty components prior to building OpenFOAM itself. OpenFOAM `etc/bashrc` or your equivalent `prefs.sh` file: - `WM_COMPILER_TYPE=ThirdParty` - `WM_COMPILER=Gcc48` (for example) - - or `WM_COMPILER=Clang` and adjust the `clang_version` entry in the OpenFOAM + - `WM_COMPILER=Clang40` (for example) + - or `WM_COMPILER=Clang` and adjust `clang_version` in the OpenFOAM `etc/config.sh/compiler` or equivalent. - More description is contained in the header comments of the `makeGcc` and `makeLLVM` files. - *Attention*: If you are building a newer version of clang, you may need to update your CMake beforehand. -2. `makeCmake` *(optional)* +* `makeCmake` - Makes a third-party [CMake](#general-packages) installation, which is needed if a system CMake does not exist or is [too old](#min-cmake), - Note that CMake is being used by an number of third-party packages (CGAL, LLVM, ParaView, VTK, ...) so this may become an increasingly important aspect of the build. -3. `Allwmake` + +Note that the order of the bootstrapping process may need to be +reversed, or even require a few loops. For example, if you may need a +newer version of CMake before being able to build LLVM/Clang and +subsequently use the newly build clang to create a newer version of +CMake in the desired location. + +Additionally, if you are using clang but with ThirdParty locations for +gmp/mpfr you will need some extra work. Here is an example: + +* Compile a new ThirdParty clang version: + + ./makeLLVM llvm-4.0.1 + +* Now adjust the OpenFOAM `prefs.sh` to use the new compiler settings, + and update the OpenFOAM environment (eg, `wmRefresh`) + +* Next use (abuse) the `makeGcc` script to compile gmp/mpfr libraries. + It is best to pass the desired versions explicitly, and necessary + to set the CC/CXX variables so that the correct compiler is used: + + CC=clang CXX=clang++ ./makeGcc gmp-6.1.2 mpfr-4.0.0 gcc-system + + specifying `gcc-system` effectively disables building of gcc, + but will build the gmp/mpfr components. + +* As a final step, it will be necessary to add the ThirdParty + gmp/mpfr locations in the OpenFOAM config files since they are + normally only used in combination with a ThirdParty gcc. + The location to make these changes is in the `etc/config.sh/CGAL`, + since this is the component that uses the mpfr library. + For example, + + gmp_version=gmp-6.1.2 + mpfr_version=mpfr-4.0.0 + + export GMP_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$gmp_version + export GMP_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$mpfr_version + +* Update update the OpenFOAM environment (eg, `wmRefresh`) again. + + +### Build Sequence + +1. `Allwmake` - This will be automatically invoked by the top-level OpenFOAM `Allwmake`, but can also be invoked directly to find possible build errors. - Builds an mpi library (openmpi or mpich), scotch decomposition, boost, CGAL, FFTW. - If the optional kahip or metis directories are found, they will also be compiled. -4. `makeParaView` *(optional but highly recommended)* +2. `makeParaView` *(optional but highly recommended)* - This is optional, but extremely useful for visualization and for run-time post-processing function objects. You can build this at a later point in time, but then you should remember to rebuild the post-processing function objects and the reader module as well. -5. Make any additional optional components +3. Make any additional optional components #### Optional Components @@ -180,6 +225,9 @@ and save some disk space. ## Build Notes +### CGAL +- The zlib library and zlib development headers are required. + ### Scotch - The zlib library and zlib development headers are required. @@ -480,4 +528,4 @@ that clang compiler for building the newer llvm/clang version. --- -Copyright 2016-2017 OpenCFD Ltd +Copyright 2016-2018 OpenCFD Ltd diff --git a/makeCGAL b/makeCGAL index e40e44e..27c5d54 100755 --- a/makeCGAL +++ b/makeCGAL @@ -60,11 +60,10 @@ cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || { } . etc/tools/ThirdPartyFunctions #------------------------------------------------------------------------------ - -unset BOOST_ARCH_PATH CGAL_ARCH_PATH # Purge current values +unset BOOST_ARCH_PATH CGAL_ARCH_PATH GMP_ARCH_PATH MPFR_ARCH_PATH # Purge old # CGAL, boost and gmp/mpfr versions from OpenFOAM etc/config.sh files. -# Get compiler first and let CGAL config override GMP (eg, when there is no GMP) +# Get compiler first and let CGAL config override GMP and MPFR _foamEtc config.sh/compiler _foamEtc config.sh/CGAL @@ -124,24 +123,26 @@ do gmpPACKAGE="gmp-system" mpfrPACKAGE="mpfr-system" boostPACKAGE="boost-system" - unset BOOST_ARCH_PATH # avoid inconsistency + unset BOOST_ARCH_PATH GMP_ARCH_PATH MPFR_ARCH_PATH ;; -no-lib) optHeadersOnly=true ;; gmp-[4-9]* | gmp-system | gmp-none) gmpPACKAGE="${1%%/}" + unset GMP_ARCH_PATH ;; mpfr-[2-9]* | mpfr-system | mpfr-none) mpfrPACKAGE="${1%%/}" - ;; - CGAL-[0-9]*) - cgalPACKAGE="${1%%/}" - unset CGAL_ARCH_PATH # avoid inconsistency + unset MPFR_ARCH_PATH ;; boost-[0-9]* | boost_[0-9]* | boost-system ) boostPACKAGE="${1%%/}" - unset BOOST_ARCH_PATH # avoid inconsistency + unset BOOST_ARCH_PATH + ;; + CGAL-[0-9]*) + cgalPACKAGE="${1%%/}" + unset CGAL_ARCH_PATH ;; *) die "unknown option/argument: '$1'" @@ -186,14 +187,37 @@ then echo "Using boost-system (skip ThirdParty build of BOOST)" # Tagged as 'system' but could actually point to a central location - [ -d "$BOOST_ARCH_PATH/include" ] || { + + if [ -d "$boostInc" ] + then + if BOOST_ARCH_PATH=$(cd $BOOST_ARCH_PATH 2>/dev/null && pwd -P) + then + boostPACKAGE=${BOOST_ARCH_PATH##*/} + else + echo "ERROR: bad path for BOOST_ARCH_PATH" + echo "stopping build" + exit 1 + fi + + libdir="$BOOST_ARCH_PATH/lib" + else boostInc="/usr/include" boostLib="/usr/lib$WM_COMPILER_LIB_ARCH" - } + libdir="/usr/lib" + fi + + # Use lib/ when lib64/ does not exist + [ ! -d "$boostLib" -a -d "$libdir" ] && boostLib="$libdir" elif [ -f "$boostInc/boost/version.hpp" ] then echo "Using $boostPACKAGE" + + libdir="$BOOST_ARCH_PATH/lib" + + # Use lib when lib64 does not exist + [ ! -d "$boostLib" -a -d "$libdir" ] && boostLib="$libdir" + else echo "Starting build: $boostPACKAGE" echo @@ -218,7 +242,7 @@ else } fi -# nothing left to build +# Nothing left to build if _foamIsSystem $cgalPACKAGE then echo "Using cgal-system (skip ThirdParty build of CGAL)" @@ -239,18 +263,6 @@ else exit 1 fi -#------------------------------------------------------------------------------ - -cat</dev/null && pwd -P) + then + gmpPACKAGE=${GMP_ARCH_PATH##*/} + else + echo "ERROR: bad path for GMP_ARCH_PATH" + echo "stopping build" + exit 1 + fi + else + GMP_ARCH_PATH=system + fi + + if [ -d "$MPFR_ARCH_PATH" ] + then + if MPFR_ARCH_PATH=$(cd $MPFR_ARCH_PATH 2>/dev/null && pwd -P) + then + mpfrPACKAGE=${MPFR_ARCH_PATH##*/} + else + echo "ERROR: bad path for MPFR_ARCH_PATH" + echo "stopping build" + exit 1 + fi + else + MPFR_ARCH_PATH=system + fi +else + GMP_ARCH_PATH=$mpfrBASE/$gmpPACKAGE + MPFR_ARCH_PATH=$mpfrBASE/$mpfrPACKAGE fi +#------------------------------------------------------------------------------ + +cat</dev/null) + # Only need VAR=... (also avoids embedded '#' that bothers some shells) + local info=$(sed -n -e '/^[A-Z]/p' $buildInfoFile 2>/dev/null) [ -n "$info" ] || return 1 local libDirName="lib$WM_COMPILER_LIB_ARCH" @@ -381,17 +433,20 @@ fi # See http://doc.cgal.org/latest/Manual/installation.html if _foamIsSystem $boostPACKAGE then - echo " system : boost" # Tagged as 'system' but could actually point to a central location if [ -d "$BOOST_ARCH_PATH/include" ] then + echo " boost : ${BOOST_ARCH_PATH##*/}" configBoost="-DBOOST_ROOT=$BOOST_ARCH_PATH" + else + echo " boost : system" fi + ## For system - possible that /usr/lib64 not being found? ## configBoost="-DBoost_LIBRARY_DIRS=$boostLib" elif [ -d "$BOOST_ARCH_PATH" ] then - echo " ThirdParty : boost" + echo " boost : $boostPACKAGE" configBoost=$(cat </dev/null || { } . etc/tools/ThirdPartyFunctions #------------------------------------------------------------------------------ +unset GMP_ARCH_PATH MPFR_ARCH_PATH # Purge old [ "${WM_COMPILER#Gcc}" = "$WM_COMPILER" ] && WM_COMPILER=Gcc # Force gcc WM_COMPILER_TYPE=ThirdParty # Ensure we get the correct settings @@ -99,12 +100,15 @@ do gmpPACKAGE="gmp-system" mpfrPACKAGE="mpfr-system" mpcPACKAGE="mpc-system" + unset GMP_ARCH_PATH MPFR_ARCH_PATH ;; gmp-[4-9]* | gmp-system) gmpPACKAGE="${1%%/}" + unset GMP_ARCH_PATH ;; mpfr-[2-9]* | mpfr-system) mpfrPACKAGE="${1%%/}" + unset MPFR_ARCH_PATH ;; mpc-[0-9]* | mpc-system) mpcPACKAGE="${1%%/}" @@ -169,7 +173,7 @@ addLib() # Build GMP # ================ echo "---------------" -if [ -d $GMP_ARCH_PATH ] +if [ -d "$GMP_ARCH_PATH" ] then echo "Already built: $gmpPACKAGE" elif _foamIsSystem $GMP_ARCH_PATH