CONFIG: improve handling of debian multi-arch
- no guarantee that dpkg-architecture command is actually available, so revert to a reasonable guess from 'uname -m' and 'uname -s'
This commit is contained in:
parent
4dafaa8cfe
commit
87cff55f9e
@ -6,7 +6,7 @@
|
|||||||
# \\ / A nd | www.openfoam.com
|
# \\ / A nd | www.openfoam.com
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Copyright (C) 2020 OpenCFD Ltd.
|
# Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -27,7 +27,7 @@
|
|||||||
#
|
#
|
||||||
# Possible Dependencies
|
# Possible Dependencies
|
||||||
# - dpkg-architecture
|
# - dpkg-architecture
|
||||||
# - mpicc
|
# - mpicc, orte-info
|
||||||
#
|
#
|
||||||
# Notes
|
# Notes
|
||||||
# Run from top-level directory when creating config files
|
# Run from top-level directory when creating config files
|
||||||
@ -42,7 +42,7 @@ usage: ${0##*/} options
|
|||||||
|
|
||||||
options:
|
options:
|
||||||
-dry-run, -n Report but do not write config files
|
-dry-run, -n Report but do not write config files
|
||||||
-no-mpicc Bypass any use of mpicc
|
-no-mpicc Bypass any use of mpicc (or orte-info)
|
||||||
-query-openmpi Report installation directory for system openmpi
|
-query-openmpi Report installation directory for system openmpi
|
||||||
-write-openmpi Query system openmpi and write config files
|
-write-openmpi Query system openmpi and write config files
|
||||||
-write Write config files using FOAM_MPI, MPI_ARCH_PATH
|
-write Write config files using FOAM_MPI, MPI_ARCH_PATH
|
||||||
@ -75,12 +75,18 @@ die()
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Options
|
# Options
|
||||||
unset optDryRun
|
unset optDryRun
|
||||||
withMpicc="mpicc"
|
optUseMpicc=true
|
||||||
|
|
||||||
# Get installation directory for system openmpi
|
# Get installation directory for system openmpi
|
||||||
|
# - from "orte-info"
|
||||||
# - from "mpicc --showme:link"
|
# - from "mpicc --showme:link"
|
||||||
# - manual fallback
|
# - manual fallback
|
||||||
#
|
#
|
||||||
|
# The orte-info content looks like this:
|
||||||
|
# ----
|
||||||
|
# path:prefix:/usr/lib64/mpi/gcc/openmpi2
|
||||||
|
# ----
|
||||||
|
#
|
||||||
# The mpicc content looks like this:
|
# The mpicc content looks like this:
|
||||||
# ----
|
# ----
|
||||||
# ... -L/usr/lib64/mpi/gcc/openmpi/lib64 -lmpi
|
# ... -L/usr/lib64/mpi/gcc/openmpi/lib64 -lmpi
|
||||||
@ -92,10 +98,22 @@ query_system_openmpi()
|
|||||||
{
|
{
|
||||||
unset arch_path
|
unset arch_path
|
||||||
|
|
||||||
if [ -n "$withMpicc" ]
|
# Query as per etc/config.sh/mpi
|
||||||
|
if [ -n "$optUseMpicc" ]
|
||||||
then
|
then
|
||||||
arch_path=$(mpicc --showme:link 2>/dev/null | sed -e 's/^.*-L\([^ ]*\).*/\1/')
|
# On the assumption that this is being called during compilation,
|
||||||
arch_path="${arch_path%/*}" # prefix from libdir
|
# skip orte-info and just take mpicc information
|
||||||
|
## Use <orte-info> (openmpi only command) to query configuration.
|
||||||
|
## Parse "path:prefix:<pathname>" type of output
|
||||||
|
#arch_path="$(orte-info --path prefix --parsable 2>/dev/null | sed -e 's#^path:[^:]*:##')"
|
||||||
|
|
||||||
|
# Use <mpicc> to get the link information and (slight hack)
|
||||||
|
# strip off 'lib' to get the prefix directory
|
||||||
|
if [ -z "$arch_path" ]
|
||||||
|
then
|
||||||
|
arch_path="$(mpicc --showme:link 2>/dev/null | sed -ne 's#.*-L\([^ ]*\).*#\1#p')"
|
||||||
|
arch_path="${arch_path%/*}" # Prefix from libdir
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$arch_path" ]
|
if [ -n "$arch_path" ]
|
||||||
then
|
then
|
||||||
@ -103,22 +121,32 @@ query_system_openmpi()
|
|||||||
return 0 # Clean exit
|
return 0 # Clean exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "No mpicc found. Attempt manually" 1>&2
|
echo "No orte-info or mpicc found. Attempt manually" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Manual discovery
|
# Manual discovery
|
||||||
if [ -z "$DEB_TARGET_MULTIARCH" ]
|
|
||||||
|
# Handle debian multi-arch...
|
||||||
|
# but dpkg-architecture command may also be missing
|
||||||
|
target_multiarch="$DEB_TARGET_MULTIARCH"
|
||||||
|
if [ -z "$target_multiarch" ] && [ -f /etc/debian_version ]
|
||||||
then
|
then
|
||||||
DEB_TARGET_MULTIARCH=$(dpkg-architecture -qDEB_TARGET_MULTIARCH 2>/dev/null || true)
|
target_multiarch="$(dpkg-architecture -qDEB_TARGET_MULTIARCH 2>/dev/null || true)"
|
||||||
|
if [ -z "$target_multiarch" ] && [ "$(uname -s)" = Linux ]
|
||||||
|
then
|
||||||
|
# Reasonable guess at a multi-arch name (eg, x86_64-linux-gnu)
|
||||||
|
# TODO: aarch64 -> arm64 ?
|
||||||
|
target_multiarch="$(uname -m)-linux-gnu"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Include is under /usr/lib... (eg, debian, openSUSE)
|
# Include is under /usr/lib... (eg, debian, openSUSE)
|
||||||
# Note this cannot handle (openmpi | openmpi1 | openmpi2 | ...) include directories
|
# Note this cannot handle (openmpi | openmpi1 | openmpi2 | ...) include directories
|
||||||
# unless we also try to grab information out of PATH or LD_LIBRARY_PATH
|
# unless we also try to grab information out of PATH or LD_LIBRARY_PATH
|
||||||
for testdir in \
|
for testdir in \
|
||||||
/usr/lib/"${DEB_TARGET_MULTIARCH:+${DEB_TARGET_MULTIARCH}/}"openmpi \
|
|
||||||
/usr/lib64/mpi/gcc/openmpi \
|
/usr/lib64/mpi/gcc/openmpi \
|
||||||
|
/usr/lib/"${target_multiarch}${target_multiarch:+/}"openmpi \
|
||||||
|
/usr/lib/openmpi \
|
||||||
;
|
;
|
||||||
do
|
do
|
||||||
if [ -e "$testdir/include/mpi.h" ]
|
if [ -e "$testdir/include/mpi.h" ]
|
||||||
@ -250,7 +278,7 @@ do
|
|||||||
-n | -dry-run) optDryRun="(dry-run) " ;;
|
-n | -dry-run) optDryRun="(dry-run) " ;;
|
||||||
|
|
||||||
-no-mpicc)
|
-no-mpicc)
|
||||||
unset withMpicc
|
unset optUseMpicc
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-query-openmpi | -query-system-openmpi)
|
-query-openmpi | -query-system-openmpi)
|
||||||
|
@ -33,6 +33,9 @@
|
|||||||
# WM_COMPILER_LIB_ARCH
|
# WM_COMPILER_LIB_ARCH
|
||||||
# DEB_TARGET_MULTIARCH
|
# DEB_TARGET_MULTIARCH
|
||||||
#
|
#
|
||||||
|
# Possible Dependencies
|
||||||
|
# - dpkg-architecture
|
||||||
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
if [ -z "$WMAKE_SCRIPTS_SYSFUNCTIONS" ]
|
if [ -z "$WMAKE_SCRIPTS_SYSFUNCTIONS" ]
|
||||||
@ -40,10 +43,17 @@ then
|
|||||||
# Load once, but do not rely on this variable elsewhere
|
# Load once, but do not rely on this variable elsewhere
|
||||||
WMAKE_SCRIPTS_SYSFUNCTIONS=loaded
|
WMAKE_SCRIPTS_SYSFUNCTIONS=loaded
|
||||||
|
|
||||||
# Debian multi-arch, ignore missing/bad dpkg-architecture.
|
# Handle debian multi-arch...
|
||||||
if [ -z "$DEB_TARGET_MULTIARCH" ]
|
# but dpkg-architecture command may also be missing
|
||||||
|
if [ -z "$DEB_TARGET_MULTIARCH" ] && [ -f /etc/debian_version ]
|
||||||
then
|
then
|
||||||
DEB_TARGET_MULTIARCH=$(dpkg-architecture -qDEB_TARGET_MULTIARCH 2>/dev/null || true)
|
DEB_TARGET_MULTIARCH="$(dpkg-architecture -qDEB_TARGET_MULTIARCH 2>/dev/null || true)"
|
||||||
|
if [ -z "$DEB_TARGET_MULTIARCH" ] && [ "${WM_ARCH#linux}" != "${WM_ARCH}" ]
|
||||||
|
then
|
||||||
|
# Reasonable guess at a multi-arch name (eg, x86_64-linux-gnu)
|
||||||
|
# TODO: aarch64 -> arm64 ?
|
||||||
|
DEB_TARGET_MULTIARCH="$(uname -m)-linux-gnu"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# True if OS is <darwin>.
|
# True if OS is <darwin>.
|
||||||
|
Loading…
Reference in New Issue
Block a user