From c8f28f373af6208a9b23c04a0201a61ba161a113 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 27 Dec 2022 09:28:22 -0800 Subject: [PATCH] bundle: OSX use -rpath for bundled libevent --- .github/workflows/ci-scripts-build.yml | 3 +++ bundle/Makefile | 4 +++- configure/CONFIG_PVXS_MODULE | 3 +++ configure/RULES_PVXS_MODULE | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index 0cc781500..b5959da39 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -149,6 +149,9 @@ jobs: run: | sudo apt-get -y install doxygen python-is-python3 python3-breathe make -C documentation + - name: otool + if: runner.os == 'macOS' + run: otool -D -L bundle/usr/*/lib/*.dylib lib/*/*.dylib bin/*/pvxinfo - name: Host info run: python .ci/cue.py --add-path "{TOP}/bin/{EPICS_HOST_ARCH}" --add-path "{TOP}/bundle/usr/{EPICS_HOST_ARCH}/lib" exec pvxinfo -D - name: Run main module tests diff --git a/bundle/Makefile b/bundle/Makefile index 909eb08e4..58b7b27e7 100644 --- a/bundle/Makefile +++ b/bundle/Makefile @@ -30,6 +30,8 @@ CMAKEFLAGS += -DEVENT__DISABLE_SAMPLES=ON CMAKEFLAGS += -DEVENT__DISABLE_TESTS=ON CMAKEFLAGS += -DEVENT__DISABLE_BENCHMARK=ON +CMAKEFLAGS += -DCMAKE_MACOSX_RPATH=ON -DCMAKE_SKIP_INSTALL_RPATH=OFF + # searched for toolchain files CMAKEFLAGS += -DCMAKE_MODULE_PATH:DIR="$(abspath $(TOP)/bundle/cmake)" @@ -120,7 +122,7 @@ ifneq (,$(filter %mingw,$(T_A))) ifeq (NO,$(SHARED_LIBRARIES)) $(CP) $(LIBEVENT_$(T_A))/lib/libevent_core.a $(LIBEVENT_$(T_A))/lib/event_core.lib # HACK: when STATIC_BUILD=YES we (in configure/RULES_PVXS_MODULE) inject the event_core -# dependency via _LIBS += event_core which requires end existance of +# dependency via _LIBS += event_core which requires the existance of # $(event_core_DIR)/event_core.lib however, cmake outputs the *nix style name # libevent_core.a (probably because it can coexist with the dll import library # named libevent_core.dll.a). diff --git a/configure/CONFIG_PVXS_MODULE b/configure/CONFIG_PVXS_MODULE index 150fb08ae..3eda048b2 100644 --- a/configure/CONFIG_PVXS_MODULE +++ b/configure/CONFIG_PVXS_MODULE @@ -28,6 +28,9 @@ LIBEVENT_BUNDLE_LIBS += $(LIBEVENT_BUNDLE_LIBS_POSIX_$(POSIX)) LIBEVENT_SYS_LIBS_WIN32 = bcrypt iphlpapi netapi32 ws2_32 LIBEVENT_SYS_LIBS += $(LIBEVENT_SYS_LIBS_$(OS_CLASS)) +LIBEVENT_BUNDLE_LDFLAGS_Darwin_NO = -Wl,-rpath,$(LIBEVENT)/lib +LIBEVENT_BUNDLE_LDFLAGS += $(LIBEVENT_BUNDLE_LDFLAGS_$(OS_CLASS)_$(STATIC_BUILD)) + event_core_DIR = $(LIBEVENT)/lib event_pthreads_DIR = $(LIBEVENT)/lib diff --git a/configure/RULES_PVXS_MODULE b/configure/RULES_PVXS_MODULE index e51cee1a1..a37382857 100644 --- a/configure/RULES_PVXS_MODULE +++ b/configure/RULES_PVXS_MODULE @@ -12,6 +12,7 @@ endif _PVXS_CHECK_VARS := PROD TESTPROD LIB $(PROD) $(TESTPROD) $(LIBRARY) ifeq (,$(LIBEVENT)) +# libevent in default search path # $(1) is PROD or LIBRARY name define _PVXS_ADD_LIBEVENT @@ -20,11 +21,13 @@ $(1)_SYS_LIBS := $$($(1)_SYS_LIBS) $$(if $$(filter pvxs,$$($(1)_LIBS)),$$(LIBEVE endef else +# libevent in specific location # $(1) is PROD or LIBRARY name define _PVXS_ADD_LIBEVENT $(1)_LIBS := $$($(1)_LIBS) $$(if $$(filter pvxs,$$($(1)_LIBS)),$$(LIBEVENT_BUNDLE_LIBS)) $(1)_SYS_LIBS := $$($(1)_SYS_LIBS) $$(if $$(filter pvxs,$$($(1)_LIBS)),$$(LIBEVENT_SYS_LIBS)) +$(1)_LDFLAGS := $$($(1)_LDFLAGS) $$(if $$(filter pvxs,$$($(1)_LIBS)),$$(LIBEVENT_BUNDLE_LDFLAGS)) endef endif