Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile support to statically link external plugin code #7918

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
try fixing macosx
  • Loading branch information
ajkr committed Feb 8, 2021
commit cb538627992c1685f79f3540cde8da57e04564cb
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,16 @@ LIB_SOURCES += utilities/env_librados.cc
LDFLAGS += -lrados
endif

# Linking with this command prevents linker from dropping unreferenced symbols,
# Linking with `AM_LINK_WHOLE` prevents linker from dropping unreferenced symbols,
# which could include static variables registering plugins in `ObjectLibrary`.
AM_LINK_WHOLE = $(AM_V_CCLD)$(CXX) -L. -Wl,--whole-archive $(patsubst lib%.a, -l%, $(patsubst lib%.$(PLATFORM_SHARED_EXT), -l%, $^)) -Wl,--no-whole-archive $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS)
# To achieve this on Mac OS X, the library must be preceded by `-force_load`
# linker flag. Elsewhere, the library must be surrounded by `--whole-archive` and
# `--no-whole-archive`.
ifeq ($(PLATFORM), OS_MACOSX)
AM_LINK_WHOLE = $(AM_V_CCLD)$(CXX) -L. -Wl,-force_load $(patsubst lib%.a, -l%, $(patsubst lib%.$(PLATFORM_SHARED_EXT), -l%, $^)) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS)
else
AM_LINK_WHOLE = $(AM_V_CCLD)$(CXX) -L. -Wl,--whole-archive $(patsubst lib%.a, -l%, $(patsubst lib%.$(PLATFORM_SHARED_EXT), -l%, $^)) -Wl,--no-whole-archive $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS)
endif
AM_LINK = $(AM_V_CCLD)$(CXX) -L. $(patsubst lib%.a, -l%, $(patsubst lib%.$(PLATFORM_SHARED_EXT), -l%, $^)) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS)
AM_SHARE = $(AM_V_CCLD) $(CXX) $(PLATFORM_SHARED_LDFLAGS)$@ -L. $(patsubst lib%.$(PLATFORM_SHARED_EXT), -l%, $^) $(LDFLAGS) -o $@

Expand Down