CONFIG: support explicit selection of 'ld' linker

- for clang-based compilers the default linker may be lld or simply ld.
  Support '+link-ld' to explicitly select use of the ld linker.

- consolidate linker rules into single files

STYLE: adjust SPDX Identifier
This commit is contained in:
Mark Olesen 2023-12-15 09:37:51 +01:00
parent 5cdc8c6fde
commit 79993bba43
15 changed files with 96 additions and 125 deletions

View File

@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh
exec "@PROJECT_DIR@"/etc/openfoam "$@" exec "@PROJECT_DIR@"/etc/openfoam "$@"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# OpenFOAM file (www.openfoam.com) # This file is part of OpenFOAM (www.openfoam.com)
# #
# Copyright (C) 2020-2021 OpenCFD Ltd. # Copyright (C) 2020-2021 OpenCFD Ltd.
# SPDX-License-Identifier: (GPL-3.0+) # SPDX-License-Identifier: (GPL-3.0-or-later)
# #
# Description # Description
# Forward to OpenFOAM etc/openfoam bash session script. # Forward to OpenFOAM etc/openfoam bash session script.

View File

@ -83,9 +83,10 @@ export WM_LABEL_SIZE=32
export WM_COMPILE_OPTION=Opt export WM_COMPILE_OPTION=Opt
# [WM_COMPILE_CONTROL] - additional control for compilation/linking # [WM_COMPILE_CONTROL] - additional control for compilation/linking
# +gold : with gold linker # +gold : use gold linker
# +lld : with lld linker (with clang) # +link-ld: use ld linker [clang]
# +mold : with mold linker (with clang) # +lld : use lld linker [clang]
# +mold : use mold linker [clang]
# ~libz : without libz compression # ~libz : without libz compression
# ~rpath : without rpath handling [MacOS] # ~rpath : without rpath handling [MacOS]
# +openmp : with openmp # +openmp : with openmp
@ -94,8 +95,8 @@ export WM_COMPILE_OPTION=Opt
# +xcrun : use xcrun and native compilers [MacOS] # +xcrun : use xcrun and native compilers [MacOS]
# +strict : more deprecation warnings (may generate *many* warnings) # +strict : more deprecation warnings (may generate *many* warnings)
# ccache=... : ccache command (unquoted, single/double or <> quoted) # ccache=... : ccache command (unquoted, single/double or <> quoted)
# version=... : compiler suffix (eg, "11" for gcc-11) # version=... : compiler suffix (eg, version=11 -> gcc-11)
#export WM_COMPILE_CONTROL="+gold" #export WM_COMPILE_CONTROL="+strict"
# [WM_MPLIB] - MPI implementation: # [WM_MPLIB] - MPI implementation:
# = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM | # = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM |

View File

@ -83,9 +83,10 @@ setenv WM_LABEL_SIZE 32
setenv WM_COMPILE_OPTION Opt setenv WM_COMPILE_OPTION Opt
# [WM_COMPILE_CONTROL] - additional control for compilation/linking # [WM_COMPILE_CONTROL] - additional control for compilation/linking
# +gold : with gold linker # +gold : use gold linker
# +lld : with lld linker (with clang) # +link-ld: use ld linker [clang]
# +mold : with mold linker (with clang) # +lld : use lld linker [clang]
# +mold : use mold linker [clang]
# ~libz : without libz compression # ~libz : without libz compression
# ~rpath : without rpath handling [MacOS] # ~rpath : without rpath handling [MacOS]
# +openmp : with openmp # +openmp : with openmp
@ -94,8 +95,8 @@ setenv WM_COMPILE_OPTION Opt
# +xcrun : use xcrun and native compilers [MacOS] # +xcrun : use xcrun and native compilers [MacOS]
# +strict : more deprecation warnings (may generate *many* warnings) # +strict : more deprecation warnings (may generate *many* warnings)
# ccache=... : ccache command (unquoted, single/double or <> quoted) # ccache=... : ccache command (unquoted, single/double or <> quoted)
# version=... : compiler suffix (eg, "11" for gcc-11) # version=... : compiler suffix (eg, version=11 -> gcc-11)
#setenv WM_COMPILE_CONTROL "+gold" #setenv WM_COMPILE_CONTROL "+strict"
# [WM_MPLIB] - MPI implementation: # [WM_MPLIB] - MPI implementation:
# = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM | # = SYSTEMOPENMPI | OPENMPI | SYSTEMMPI | MPI | MPICH | MPICH-GM |

View File

@ -8,7 +8,7 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd. # Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# SPDX-License-Identifier: (GPL-3.0+) # SPDX-License-Identifier: (GPL-3.0-or-later)
# #
# Script # Script
# list-modules # list-modules

View File

@ -6,6 +6,7 @@ LINKLIBSO = $(CC) $(c++FLAGS) -shared
LINKEXE = $(CC) $(c++FLAGS) LINKEXE = $(CC) $(c++FLAGS)
# ---------------
# Link dummy stub to resolve libPstream symbols used by libOpenFOAM # Link dummy stub to resolve libPstream symbols used by libOpenFOAM
ifneq (,$(findstring -lOpenFOAM,$(PROJECT_LIBS))) ifneq (,$(findstring -lOpenFOAM,$(PROJECT_LIBS)))
LINKEXE += -L$(FOAM_LIBBIN)/dummy -lPstream LINKEXE += -L$(FOAM_LIBBIN)/dummy -lPstream

View File

@ -1,10 +1,54 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Common linker settings
LINK_LIBS = $(c++DBUG) LINK_LIBS = $(c++DBUG)
LINKLIBSO = $(CC) $(c++FLAGS) -shared LINKLIBSO = $(CC) $(c++FLAGS) -shared
LINKEXE = $(CC) $(c++FLAGS)
LINKEXE = $(CC) $(c++FLAGS) \ undefine LINKEXE_STUB
-Xlinker --add-needed
#------------------------------------------------------------------------------
# Use gold linker
ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
LINKLIBSO += -fuse-ld=gold
LINKEXE += -fuse-ld=gold
LINKEXE_STUB := true
# Use mold linker
else ifneq (,$(findstring +mold,$(WM_COMPILE_CONTROL)))
LINKLIBSO += -fuse-ld=mold
LINKEXE += -fuse-ld=mold
LINKEXE_STUB := true
# Use lld linker
else ifneq (,$(findstring +lld,$(WM_COMPILE_CONTROL)))
LINKLIBSO += -fuse-ld=lld
LINKEXE += -fuse-ld=lld
LINKEXE_STUB := true
# Use ld linker - no dummy stub ('+link-ld' not '+ld' to avoid false matches)
else ifneq (,$(findstring +link-ld,$(WM_COMPILE_CONTROL)))
LINKLIBSO += -fuse-ld=ld
LINKEXE += -fuse-ld=ld -Xlinker --add-needed
# Default linker, assume ld - no dummy stub
else
LINKEXE += -Xlinker --add-needed
endif
# ---------------
# Link dummy stub to resolve libPstream symbols used by libOpenFOAM
ifneq (,$(LINKEXE_STUB))
ifneq (,$(findstring -lOpenFOAM,$(PROJECT_LIBS)))
LINKEXE += -L$(FOAM_LIBBIN)/dummy -lPstream
endif
endif
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -1,16 +0,0 @@
#------------------------------------------------------------------------------
LINK_LIBS = $(c++DBUG)
LINKLIBSO = $(CC) $(c++FLAGS) -shared \
-fuse-ld=gold
LINKEXE = $(CC) $(c++FLAGS) \
-fuse-ld=gold
# Link dummy stub to resolve libPstream symbols used by libOpenFOAM
ifneq (,$(findstring -lOpenFOAM,$(PROJECT_LIBS)))
LINKEXE += -L$(FOAM_LIBBIN)/dummy -lPstream
endif
#------------------------------------------------------------------------------

View File

@ -1,16 +0,0 @@
#------------------------------------------------------------------------------
LINK_LIBS = $(c++DBUG)
LINKLIBSO = $(CC) $(c++FLAGS) -shared \
-fuse-ld=lld
LINKEXE = $(CC) $(c++FLAGS) \
-fuse-ld=lld
# Link dummy stub to resolve libPstream symbols used by libOpenFOAM
ifneq (,$(findstring -lOpenFOAM,$(PROJECT_LIBS)))
LINKEXE += -L$(FOAM_LIBBIN)/dummy -lPstream
endif
#------------------------------------------------------------------------------

View File

@ -1,16 +0,0 @@
#------------------------------------------------------------------------------
LINK_LIBS = $(c++DBUG)
LINKLIBSO = $(CC) $(c++FLAGS) -shared \
-fuse-ld=mold
LINKEXE = $(CC) $(c++FLAGS) \
-fuse-ld=mold
# Link dummy stub to resolve libPstream symbols used by libOpenFOAM
ifneq (,$(findstring -lOpenFOAM,$(PROJECT_LIBS)))
LINKEXE += -L$(FOAM_LIBBIN)/dummy -lPstream
endif
#------------------------------------------------------------------------------

View File

@ -1,13 +1,35 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Common linker settings
LINK_LIBS = $(c++DBUG) LINK_LIBS = $(c++DBUG)
LINKLIBSO = $(CC) $(c++FLAGS) -shared
LINKEXE = $(CC) $(c++FLAGS)
LINKLIBSO = $(CC) $(c++FLAGS) -shared \ undefine LINKEXE_STUB
-Xlinker --add-needed \
-Xlinker --no-as-needed #------------------------------------------------------------------------------
LINKEXE = $(CC) $(c++FLAGS) \ # Use gold linker
-Xlinker --add-needed \ ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
-Xlinker --no-as-needed
LINKLIBSO += -fuse-ld=gold
LINKEXE += -fuse-ld=gold
LINKEXE_STUB := true
# Default linker, assume ld - no dummy stub
else
LINKLIBSO += -Xlinker --add-needed -Xlinker --no-as-needed
LINKEXE += -Xlinker --add-needed -Xlinker --no-as-needed
endif
# Link dummy stub to resolve libPstream symbols used by libOpenFOAM
ifneq (,$(LINKEXE_STUB))
ifneq (,$(findstring -lOpenFOAM,$(PROJECT_LIBS)))
LINKEXE += -L$(FOAM_LIBBIN)/dummy -lPstream
endif
endif
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -1,16 +0,0 @@
#------------------------------------------------------------------------------
LINK_LIBS = $(c++DBUG)
LINKLIBSO = $(CC) $(c++FLAGS) -shared \
-fuse-ld=gold
LINKEXE = $(CC) $(c++FLAGS) \
-fuse-ld=gold
# Link dummy stub to resolve libPstream symbols used by libOpenFOAM
ifneq (,$(findstring -lOpenFOAM,$(PROJECT_LIBS)))
LINKEXE += -L$(FOAM_LIBBIN)/dummy -lPstream
endif
#------------------------------------------------------------------------------

View File

@ -16,19 +16,6 @@ cctoo = $(Ctoo)
cpptoo = $(Ctoo) cpptoo = $(Ctoo)
cxxtoo = $(Ctoo) cxxtoo = $(Ctoo)
# Linking:
ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/Clang/link-gold-c++
else ifneq (,$(findstring +mold,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/Clang/link-mold-c++
else ifneq (,$(findstring +lld,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/Clang/link-lld-c++
else
include $(GENERAL_RULES)/Clang/link-c++ include $(GENERAL_RULES)/Clang/link-c++
endif
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -16,10 +16,6 @@ cctoo = $(Ctoo)
cpptoo = $(Ctoo) cpptoo = $(Ctoo)
cxxtoo = $(Ctoo) cxxtoo = $(Ctoo)
ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/Gcc/link-gold-c++
else
include $(GENERAL_RULES)/Gcc/link-c++ include $(GENERAL_RULES)/Gcc/link-c++
endif
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -16,19 +16,6 @@ cctoo = $(Ctoo)
cpptoo = $(Ctoo) cpptoo = $(Ctoo)
cxxtoo = $(Ctoo) cxxtoo = $(Ctoo)
# Linking:
ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/Clang/link-gold-c++
else ifneq (,$(findstring +mold,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/Clang/link-mold-c++
else ifneq (,$(findstring +lld,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/Clang/link-lld-c++
else
include $(GENERAL_RULES)/Clang/link-c++ include $(GENERAL_RULES)/Clang/link-c++
endif
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -16,10 +16,6 @@ cctoo = $(Ctoo)
cpptoo = $(Ctoo) cpptoo = $(Ctoo)
cxxtoo = $(Ctoo) cxxtoo = $(Ctoo)
ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/Gcc/link-gold-c++
else
include $(GENERAL_RULES)/Gcc/link-c++ include $(GENERAL_RULES)/Gcc/link-c++
endif
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------