From e6c62d55dca3616283e03ec0fb130a95ebda47c7 Mon Sep 17 00:00:00 2001 From: Adam Novak Date: Tue, 9 Apr 2024 10:12:49 -0400 Subject: [PATCH 1/2] Pad libdeflate for renaming on Mac This should fix #4257 --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f77ae12c82e..e845540f65e 100644 --- a/Makefile +++ b/Makefile @@ -215,6 +215,9 @@ ifeq ($(shell uname -s),Darwin) # We don't actually do any static linking on Mac, so we leave this empty. START_STATIC = END_STATIC = + + # We need to use special flags to let us rename libraries + LD_RENAMEABLE_FLAGS = -headerpad -headerpad_max_install_names else # We are not running on OS X $(info OS is Linux) @@ -252,7 +255,8 @@ else # Note that END_STATIC is only safe to use in a mostly-dynamic build, and has to appear or we will try to statically link secret trailing libraries. END_STATIC = -Wl,-Bdynamic - + # We don't need any flags because we don't need to rename libraries with install_name_tool + LD_RENAMEABLE_FLAGS = endif # Set the C++ standard we are using @@ -656,7 +660,7 @@ ifeq ($(shell uname -s),Darwin) endif $(LIB_DIR)/libdeflate.a: $(LIBDEFLATE_DIR)/*.h $(LIBDEFLATE_DIR)/lib/*.h $(LIBDEFLATE_DIR)/lib/*/*.h $(LIBDEFLATE_DIR)/lib/*.c $(LIBDEFLATE_DIR)/lib/*/*.c - +. ./source_me.sh && cd $(LIBDEFLATE_DIR) && V=1 $(MAKE) $(FILTER) && cp libdeflate.a $(CWD)/$(LIB_DIR) && cp libdeflate.h $(CWD)/$(INC_DIR) + +. ./source_me.sh && cd $(LIBDEFLATE_DIR) && V=1 LDFLAGS="$(LDFLAGS) $(LD_RENAMEABLE_FLAGS)" $(MAKE) $(FILTER) && cp libdeflate.a $(CWD)/$(LIB_DIR) && cp libdeflate.h $(CWD)/$(INC_DIR) # We build htslib after libdeflate so it can use libdeflate. # We need to do some wizardry to get it to pick up the right build and target system types on modern autotools. From 2352c3db2bc3a1896baef96561757b33f141fcc1 Mon Sep 17 00:00:00 2001 From: Adam Novak Date: Mon, 6 May 2024 17:02:14 -0400 Subject: [PATCH 2/2] Protect linker arguments from Clang --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e845540f65e..6c8fd7262a1 100644 --- a/Makefile +++ b/Makefile @@ -217,7 +217,7 @@ ifeq ($(shell uname -s),Darwin) END_STATIC = # We need to use special flags to let us rename libraries - LD_RENAMEABLE_FLAGS = -headerpad -headerpad_max_install_names + LD_RENAMEABLE_FLAGS = -Wl,-headerpad -Wl,-headerpad_max_install_names else # We are not running on OS X $(info OS is Linux)