Skip to content

Commit

Permalink
Merge branch 'fix/darwin_gfortranclang_openmpi_preload_861' into patc…
Browse files Browse the repository at this point in the history
…h/8.6.1

This is equivalent to pull request #221 but for the patch/8.6.1 branch

Fix build of libesmftrace_preload.dylib on Darwin-openmpi

With Darwin-openmpi, we use a Fortran linker for libesmftrace_preload.dylib. But the link command was using flags appropriate for a C++ linker rather than a Fortran linker. This PR changes the link flags to be appropriate for a Fortran linker in this case.

In the context of the develop branch:
- I have tested this on my Mac (green, with gfortranclang+openmpi) and confirmed that this resolves the build issues I was running into.
- I have also tested this on catania and derecho to ensure that this doesn't break the build / test on other systems.
  • Loading branch information
billsacks committed Feb 7, 2024
2 parents c3d0bb0 + ab7a898 commit 7804b54
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions build/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2032,13 +2032,19 @@ ESMF_TRACE_LDPRELOAD := $(ESMF_LIBDIR)/libesmftrace_preload.$(ESMF_SL_SUFFIX)
ESMF_PRELOADSCRIPT = $(ESMF_LIBDIR)/preload.sh

ESMF_SL_PRELOAD_LIBLINKER = $(ESMF_CXXCOMPILER)
ESMF_SL_PRELOAD_LIBOPTS = $(ESMF_CXXLINKOPTS)
ESMF_SL_PRELOAD_LIBLIBS = $(ESMF_CXXLINKPATHS) $(ESMF_CXXLINKRPATHS) $(ESMF_CXXLINKLIBS)

ifeq ($(ESMF_OS),Darwin)
ESMF_ENV_PRELOAD = DYLD_INSERT_LIBRARIES
ESMF_ENV_PRELOAD_DELIMIT = ':'
ifeq ($(ESMF_COMM),openmpi)
# make sure to link in the Fortran MPI bindings
ESMF_SL_PRELOAD_LIBLINKER = $(ESMF_F90COMPILER)
# and since we're using the F90 compiler as the linker, make sure to use link
# options and libs appropriate for the F90 compiler instead of the C++ compiler
ESMF_SL_PRELOAD_LIBOPTS = $(ESMF_F90LINKOPTS)
ESMF_SL_PRELOAD_LIBLIBS = $(ESMF_F90LINKPATHS) $(ESMF_F90LINKRPATHS) $(ESMF_F90LINKLIBS)
endif
else
ESMF_ENV_PRELOAD = LD_PRELOAD
Expand Down
3 changes: 1 addition & 2 deletions build_config/Darwin.gfortranclang.default/build_rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ ESMF_F90LINKLIBS += -lgfortran
############################################################
# Shared library options
ESMF_SL_LIBOPTS += -dynamiclib
# No need for "$(ESMF_F90LINKPATHS) $(ESMF_F90LINKLIBS)" in the following because they are identical to the CXX versions:
ESMF_SL_LIBLIBS += $(ESMF_CXXLINKPATHS) $(ESMF_CXXLINKLIBS)
ESMF_SL_LIBLIBS += $(ESMF_F90LINKPATHS) $(ESMF_F90LINKLIBS) $(ESMF_CXXLINKPATHS) $(ESMF_CXXLINKLIBS)

############################################################
# Static builds on Darwin do not support trace lib due to missing linker option
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/Trace/preload/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ifeq ($(ESMF_OS),MinGW)
endif

tracelib_preload: preload.o preload_mpi.o wrappers.o wrappers_mpi.o
$(ESMF_SL_PRELOAD_LIBLINKER) $(ESMF_SL_LIBOPTS) -o $(ESMF_LDIR)/libesmftrace_preload.$(ESMF_SL_SUFFIX) $^ $(ESMF_CXXLINKOPTS) $(ESMF_CXXLINKPATHS) $(ESMF_CXXLINKRPATHS) $(ESMF_CXXLINKLIBS) $(ESMF_TRACE_ESMFLIB)
$(ESMF_SL_PRELOAD_LIBLINKER) $(ESMF_SL_LIBOPTS) -o $(ESMF_LDIR)/libesmftrace_preload.$(ESMF_SL_SUFFIX) $^ $(ESMF_SL_PRELOAD_LIBOPTS) $(ESMF_SL_PRELOAD_LIBLIBS) $(ESMF_TRACE_ESMFLIB)
$(MAKE) ESMF_PRELOADDIR=$(ESMF_LIBDIR) build_preload_script

tracelib_static: wrappers_io.o wrappers_mpi.o wrappers.o
Expand Down

0 comments on commit 7804b54

Please sign in to comment.