commit b6b91dc1de905ffff78ac43f7f28bc65a6a822db
parent 219c1a7244d99de23646b28b1904f89e1f2a4aca
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 18 Oct 2023 14:56:56 +0200
Partially link static library object files
Make hidden symbols local to the relocatable object to avoid conflicts
with internal symbols in another static library. In release mode, delete
all symbols not required for relocation processing, but keep them in
debug mode.
Diffstat:
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
@@ -46,10 +46,14 @@ $(DEP) $(OBJ): config.mk
$(LIBNAME_SHARED): $(OBJ)
$(CC) -std=c99 $(CFLAGS) $(DPDC_CFLAGS) -o $@ $(OBJ) $(LDFLAGS) $(SOFLAGS) $(DPDC_LIBS)
-$(LIBNAME_STATIC): $(OBJ)
+$(LIBNAME_STATIC): librsimd.o
$(AR) -rc $@ $?
$(RANLIB) $@
+librsimd.o: $(OBJ)
+ $(LD) -r $(OBJ) -o $@
+ $(OBJCOPY) $(OCPFLAGS) $@
+
.config: make.sh config.mk
@if ! $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys; then \
echo "rsys $(RSYS_VERSION) not found"; exit 1; fi
@@ -73,7 +77,8 @@ $(LIBNAME_STATIC): $(OBJ)
all: build_library build_tests
clean__: clean_test
- rm -f $(OBJ) $(TEST_OBJ) $(LIBNAME) rsimd.pc rsimd-local.pc .config .simd .test
+ rm -f $(OBJ) $(TEST_OBJ) $(LIBNAME)
+ rm -f .config .simd .test librsimd.o rsimd.pc rsimd-local.pc
distclean__: clean__
rm -f $(DEP) $(TEST_DEP) .test
diff --git a/config.mk b/config.mk
@@ -16,7 +16,9 @@ BUILD_TYPE = RELEASE
################################################################################
AR = ar
CC = cc
+LD = ld
PKG_CONFIG = pkg-config
+OBJCOPY = objcopy
RANLIB = ranlib
################################################################################
@@ -69,3 +71,7 @@ SOFLAGS = -shared -Wl,--no-undefined
LDFLAGS_DEBUG =
LDFLAGS_RELEASE = -s
LDFLAGS = $(LDFLAGS_$(BUILD_TYPE))
+
+OCPFLAGS_DEBUG = --localize-hidden
+OCPFLAGS_RELEASE = --localize-hidden --strip-unneeded
+OCPFLAGS = $(OCPFLAGS_$(BUILD_TYPE))