From 717d979e6adae9801089208c1f336efd3e3bee93 Mon Sep 17 00:00:00 2001 From: Gerhard Theurich Date: Sun, 22 Oct 2023 22:24:12 -0700 Subject: [PATCH] Consolidate preload logic. Implement logic into preload.sh to cater to Darwin issues with empty incoming DYLD_INSERT_LIBRARIES variable. --- build/common.mk | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/build/common.mk b/build/common.mk index 05703cb980..c648a65e5f 100644 --- a/build/common.mk +++ b/build/common.mk @@ -1148,14 +1148,10 @@ ifeq ($(ESMF_OS),MinGW) ESMF_LIB_SUFFIX = lib endif -# - Shared library and preload environment variable +# - Shared library ESMF_SL_SUFFIX = so -ESMF_PRELOAD = LD_PRELOAD -ESMF_PRELOAD_DELIMIT = ' ' ifeq ($(ESMF_OS),Darwin) ESMF_SL_SUFFIX = dylib -ESMF_PRELOAD = DYLD_INSERT_LIBRARIES -ESMF_PRELOAD_DELIMIT = ':' endif ifeq ($(ESMF_OS),Cygwin) ESMF_SL_SUFFIX = dll.a @@ -2027,9 +2023,11 @@ ESMF_TRACE_LDPRELOAD := $(ESMF_LIBDIR)/libesmftrace_preload.$(ESMF_SL_SUFFIX) ESMF_PRELOADSCRIPT = $(ESMF_LIBDIR)/preload.sh ifneq ($(ESMF_OS),Darwin) -ESMF_ENV_PRELOAD = LD_PRELOAD +ESMF_ENV_PRELOAD = LD_PRELOAD +ESMF_ENV_PRELOAD_DELIMIT = ' ' else -ESMF_ENV_PRELOAD = DYLD_INSERT_LIBRARIES +ESMF_ENV_PRELOAD = DYLD_INSERT_LIBRARIES +ESMF_ENV_PRELOAD_DELIMIT = ':' endif # MPI implementations do not pick up LD_PRELOAD @@ -2052,7 +2050,11 @@ endif build_preload_script: -@echo "#!/bin/sh" > $(ESMF_PRELOADDIR)/preload.sh -@echo "# Script to preload ESMF dynamic trace library" >> $(ESMF_PRELOADDIR)/preload.sh - -@echo 'env $(ESMF_PRELOAD)="$$$(ESMF_PRELOAD)$(ESMF_PRELOAD_DELIMIT)$(ESMF_PRELOADDIR)/libesmftrace_preload.$(ESMF_SL_SUFFIX)" $$*' >> $(ESMF_PRELOADDIR)/preload.sh + -@echo 'if [ "$(ESMF_ENV_PRELOAD)" != "" ]; then' >> $(ESMF_PRELOADDIR)/preload.sh + -@echo 'env $(ESMF_ENV_PRELOAD)="$$$(ESMF_ENV_PRELOAD)$(ESMF_ENV_PRELOAD_DELIMIT)$(ESMF_PRELOADDIR)/libesmftrace_preload.$(ESMF_SL_SUFFIX)" $$*' >> $(ESMF_PRELOADDIR)/preload.sh + -@echo 'else' >> $(ESMF_PRELOADDIR)/preload.sh + -@echo 'env $(ESMF_ENV_PRELOAD)="$(ESMF_PRELOADDIR)/libesmftrace_preload.$(ESMF_SL_SUFFIX)" $$*' >> $(ESMF_PRELOADDIR)/preload.sh + -@echo 'fi' >> $(ESMF_PRELOADDIR)/preload.sh chmod 755 $(ESMF_PRELOADDIR)/preload.sh ESMF_TRACE_STATICLINKLIBS := -lesmftrace_static