aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-24 00:10:00 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-24 00:10:00 +0100
commitc1f3a1a89b717e73c2a8c2315067c495e246457c (patch)
treefdbee1ce96a53c5ad99a223129d444149c680e18
parent5a1114ecdbbd115ec8aeb1a98326d793ff3e8058 (diff)
Disallow undefined symbols in dynamic libraries by default
This encourages that each library declares its own dependencies properly.
-rw-r--r--Makefile.lib14
-rw-r--r--src/libmain/Makefile.new2
2 files changed, 12 insertions, 4 deletions
diff --git a/Makefile.lib b/Makefile.lib
index 612550e92..f5872c88b 100644
--- a/Makefile.lib
+++ b/Makefile.lib
@@ -27,6 +27,7 @@ QUIET = @
ifeq ($(BUILD_SHARED_LIBS), 1)
GLOBAL_CFLAGS += -fPIC
GLOBAL_CXXFLAGS += -fPIC
+ GLOBAL_LDFLAGS += -Wl,--no-copy-dt-needed-entries
endif
@@ -60,9 +61,13 @@ define LIBS_template =
ifeq ($(BUILD_SHARED_LIBS), 1)
+ ifndef $(1)_ALLOW_UNDEFINED
+ $(1)_LDFLAGS += -z defs
+ endif
+
_lib := $$(_d)/$(1).so
$$(_lib): $$($(1)_OBJS) $$(_libs)
- $(QUIET) $(CC) -o $$@ -shared -Wl,--no-copy-dt-needed-entries $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
+ $(QUIET) $(CXX) -o $$@ -shared $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
$(1)_LDFLAGS_USE += -L$$(_d) -Wl,-rpath,$$(abspath $$(_d)) -l$$(patsubst lib%,%,$$(strip $(1)))
@@ -74,7 +79,7 @@ define LIBS_template =
$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final)
install -d $$($(1)_INSTALL_DIR)
- $(QUIET) $(CC) -o $$@ -shared -Wl,--no-copy-dt-needed-entries $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
+ $(QUIET) $(CXX) -o $$@ -shared $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
$(1)_LDFLAGS_USE_INSTALLED += -L$$($(1)_INSTALL_DIR) -Wl,-rpath,$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $(1)))
@@ -92,6 +97,7 @@ define LIBS_template =
$(1)_LDFLAGS_USE += $$($(1)_LDFLAGS_PROPAGATED)
$(1)_LDFLAGS_USE_INSTALLED += $$($(1)_LDFLAGS_PROPAGATED)
+
$(1)_NAME := $$(_lib)
# Propagate CXXFLAGS to the individual object files.
@@ -118,7 +124,7 @@ define PROGRAMS_template =
$(1)_PATH := $$(_d)/$(1)
$$($(1)_PATH): $$($(1)_OBJS) $$(_libs)
- $(QUIET) $(CXX) -o $$@ -Wl,--no-copy-dt-needed-entries $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
+ $(QUIET) $(CXX) -o $$@ $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
$(1)_INSTALL_PATH := $$(bindir)/$(1)
@@ -130,7 +136,7 @@ define PROGRAMS_template =
$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final)
install -d $$(dir $$($(1)_INSTALL_PATH))
- $(QUIET) $(CXX) -o $$($(1)_INSTALL_PATH) -Wl,--no-copy-dt-needed-entries $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
+ $(QUIET) $(CXX) -o $$($(1)_INSTALL_PATH) $(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
else
diff --git a/src/libmain/Makefile.new b/src/libmain/Makefile.new
index 6ca49d583..2ead94ca6 100644
--- a/src/libmain/Makefile.new
+++ b/src/libmain/Makefile.new
@@ -5,3 +5,5 @@ libmain_DIR := $(d)
libmain_SOURCES = shared.cc stack.cc
libmain_LIBS = libstore libutil libformat
+
+libmain_ALLOW_UNDEFINED = 1