mk: Only link dynamic library with --whole-archive

For the executable we should not use this option as it unnecessarily
increases binary size.

There might also be incompatibilities with Mac, see #126

Signed-off-by: Felix Walter <felix.walter@d3tn.com>
This commit is contained in:
Felix Walter 2023-04-03 19:44:18 +02:00
parent e58181818e
commit 602c4ce00a
2 changed files with 5 additions and 3 deletions

View file

@ -41,7 +41,8 @@ $(eval $(call addComponentWithRules,external/util/src))
$(eval $(call generateComponentRules,components/daemon))
$(eval $(call generateComponentRules,test/unit))
build/$(PLATFORM)/libud3tn.so: LDFLAGS += $(LDFLAGS_LIB)
build/$(PLATFORM)/libud3tn.so: LDFLAGS += $(LDFLAGS_LIB) -Wl,--no-whole-archive
build/$(PLATFORM)/libud3tn.so: LDFLAGS_PRE += -Wl,--whole-archive
build/$(PLATFORM)/libud3tn.so: LIBS = $(LIBS_libud3tn.so)
build/$(PLATFORM)/libud3tn.so: $(LIBS_libud3tn.so) | build/$(PLATFORM)
$(call cmd,link)

View file

@ -55,9 +55,10 @@ cmd_ar = "$(AR)" rcs "$@" $(OBJECTS)
quiet_cmd_link = LINK $@
cmd_link = "$(LD)" -o "$@" \
-Wl,--whole-archive -Wl,--start-group \
$(LDFLAGS_PRE) \
-Wl,--start-group \
$(OBJECTS) $(LIBS) \
-Wl,--end-group -Wl,--no-whole-archive \
-Wl,--end-group \
$(LDFLAGS)
quiet_cmd_mkdir = MKDIR $@