Skip to content
Snippets Groups Projects
Commit a27af5e3 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: add optional control to use clang lld linker (#2449)

Eg,
    export WM_COMPILER=Clang130
    export WM_COMPILE_CONTROL="version=13.0 +lld"

- also support the mold linker (+mold) for clang

STYLE: report as 'link' stage instead of 'ld' in short messages
parent 442c309d
No related branches found
No related tags found
1 merge request!533Code changes and reorganisation preliminary to redistributePar updates (#2436)
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation # Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2016-2021 OpenCFD Ltd. # Copyright (C) 2016-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.
...@@ -86,6 +86,8 @@ export WM_COMPILE_OPTION=Opt ...@@ -86,6 +86,8 @@ export WM_COMPILE_OPTION=Opt
# [WM_COMPILE_CONTROL] - additional control for compiler rules # [WM_COMPILE_CONTROL] - additional control for compiler rules
# +gold : with gold linker # +gold : with gold linker
# +lld : with lld linker (with clang)
# +mold : with mold linker (with clang)
# ~openmp : without openmp # ~openmp : without openmp
# version=... : compiler suffix (eg, "11" for gcc-11) # version=... : compiler suffix (eg, "11" for gcc-11)
#export WM_COMPILE_CONTROL="+gold" #export WM_COMPILE_CONTROL="+gold"
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation # Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2016-2021 OpenCFD Ltd. # Copyright (C) 2016-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.
...@@ -86,6 +86,8 @@ setenv WM_COMPILE_OPTION Opt ...@@ -86,6 +86,8 @@ setenv WM_COMPILE_OPTION Opt
# [WM_COMPILE_CONTROL] - additional control for compiler rules # [WM_COMPILE_CONTROL] - additional control for compiler rules
# +gold : with gold linker # +gold : with gold linker
# +lld : with lld linker (with clang)
# +mold : with mold linker (with clang)
# ~openmp : without openmp # ~openmp : without openmp
# version=... : compiler suffix (eg, "11" for gcc-11) # version=... : compiler suffix (eg, "11" for gcc-11)
#setenv WM_COMPILE_CONTROL "+gold" #setenv WM_COMPILE_CONTROL "+gold"
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation # Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2019-2020 OpenCFD Ltd. # Copyright (C) 2019-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.
...@@ -146,7 +146,7 @@ silent: ...@@ -146,7 +146,7 @@ silent:
$(EXE)$(EXT_EXE): $(OBJECTS) $(EXE)$(EXT_EXE): $(OBJECTS)
@$(WM_SCRIPTS)/makeTargetDir $(EXE) @$(WM_SCRIPTS)/makeTargetDir $(EXE)
$(call QUIET_MESSAGE,ld,$(EXE)$(EXT_EXE)) $(call QUIET_MESSAGE,link,$(EXE)$(EXT_EXE))
$E $(LINKEXE) $(OBJECTS) -L$(LIB_PLATFORMS) \ $E $(LINKEXE) $(OBJECTS) -L$(LIB_PLATFORMS) \
$(EXE_LIBS) $(PROJECT_LIBS) $(SYS_LIBS) \ $(EXE_LIBS) $(PROJECT_LIBS) $(SYS_LIBS) \
$(LINK_LIBS) $(GLIBS) -o $(EXE)$(EXT_EXE) $(LINK_LIBS) $(GLIBS) -o $(EXE)$(EXT_EXE)
...@@ -156,7 +156,7 @@ exe: $(SEXE)$(EXT_EXE) | silent ...@@ -156,7 +156,7 @@ exe: $(SEXE)$(EXT_EXE) | silent
$(SEXE)$(EXT_EXE): $(OBJECTS) $(SEXE)$(EXT_EXE): $(OBJECTS)
@$(WM_SCRIPTS)/makeTargetDir $(SEXE) @$(WM_SCRIPTS)/makeTargetDir $(SEXE)
$(call QUIET_MESSAGE,ld,$(SEXE)$(EXT_EXE)) $(call QUIET_MESSAGE,link,$(SEXE)$(EXT_EXE))
$E $(LINKEXE) $(OBJECTS) $(EXE_LIBS) \ $E $(LINKEXE) $(OBJECTS) $(EXE_LIBS) \
$(SYS_LIBS) $(LINK_LIBS) $(GLIBS) -o $(SEXE)$(EXT_EXE) $(SYS_LIBS) $(LINK_LIBS) $(GLIBS) -o $(SEXE)$(EXT_EXE)
...@@ -174,13 +174,13 @@ libso: $(LIB)$(EXT_SO) | silent ...@@ -174,13 +174,13 @@ libso: $(LIB)$(EXT_SO) | silent
ifneq (,$(findstring windows,$(WM_OSTYPE))) ifneq (,$(findstring windows,$(WM_OSTYPE)))
$(LIB)$(EXT_SO): $(OBJECTS) $(LIB)$(EXT_SO): $(OBJECTS)
@$(WM_SCRIPTS)/makeTargetDir $(LIB) @$(WM_SCRIPTS)/makeTargetDir $(LIB)
$(call QUIET_MESSAGE,ld,$(LIB)$(EXT_SO)) $(call QUIET_MESSAGE,link,$(LIB)$(EXT_SO))
$E $(LINKLIBSO) $(OBJECTS) -L$(LIB_PLATFORMS) \ $E $(LINKLIBSO) $(OBJECTS) -L$(LIB_PLATFORMS) \
$(PROJECT_LIBS) $(LIB_LIBS) $(GLIB_LIBS) -o $(LIB)$(EXT_SO) $(PROJECT_LIBS) $(LIB_LIBS) $(GLIB_LIBS) -o $(LIB)$(EXT_SO)
else else
$(LIB)$(EXT_SO): $(OBJECTS) $(LIB)$(EXT_SO): $(OBJECTS)
@$(WM_SCRIPTS)/makeTargetDir $(LIB) @$(WM_SCRIPTS)/makeTargetDir $(LIB)
$(call QUIET_MESSAGE,ld,$(LIB)$(EXT_SO)) $(call QUIET_MESSAGE,link,$(LIB)$(EXT_SO))
$E $(LINKLIBSO) $(OBJECTS) -L$(LIB_PLATFORMS) \ $E $(LINKLIBSO) $(OBJECTS) -L$(LIB_PLATFORMS) \
$(LIB_LIBS) $(GLIB_LIBS) -o $(LIB)$(EXT_SO) $(LIB_LIBS) $(GLIB_LIBS) -o $(LIB)$(EXT_SO)
endif endif
......
LINK_LIBS = $(c++DBUG)
LINKLIBSO = $(CC) $(c++FLAGS) -shared \
-fuse-ld=lld \
$(FOAM_EXTRA_LDFLAGS)
LINKEXE = $(CC) $(c++FLAGS) \
-fuse-ld=lld \
-L$(FOAM_LIBBIN)/dummy -lPstream \
$(FOAM_EXTRA_LDFLAGS)
LINK_LIBS = $(c++DBUG)
LINKLIBSO = $(CC) $(c++FLAGS) -shared \
-fuse-ld=mold \
$(FOAM_EXTRA_LDFLAGS)
LINKEXE = $(CC) $(c++FLAGS) \
-fuse-ld=mold \
-L$(FOAM_LIBBIN)/dummy -lPstream \
$(FOAM_EXTRA_LDFLAGS)
...@@ -12,8 +12,17 @@ cctoo = $(Ctoo) ...@@ -12,8 +12,17 @@ cctoo = $(Ctoo)
cpptoo = $(Ctoo) cpptoo = $(Ctoo)
cxxtoo = $(Ctoo) cxxtoo = $(Ctoo)
# Linking:
ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL))) ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/Clang/link-gold-c++ 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 else
include $(GENERAL_RULES)/Clang/link-c++ include $(GENERAL_RULES)/Clang/link-c++
endif endif
......
...@@ -12,8 +12,17 @@ cctoo = $(Ctoo) ...@@ -12,8 +12,17 @@ cctoo = $(Ctoo)
cpptoo = $(Ctoo) cpptoo = $(Ctoo)
cxxtoo = $(Ctoo) cxxtoo = $(Ctoo)
# Linking:
ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL))) ifneq (,$(findstring +gold,$(WM_COMPILE_CONTROL)))
include $(GENERAL_RULES)/Clang/link-gold-c++ 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 else
include $(GENERAL_RULES)/Clang/link-c++ include $(GENERAL_RULES)/Clang/link-c++
endif endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment