From 2fcbc9d169d80c24e7acf3eedba90a94622f00ec Mon Sep 17 00:00:00 2001 From: Evan Shelhamer Date: Wed, 1 Oct 2014 11:50:42 -0700 Subject: [PATCH] [fix] translate g++ whole archive to force load for clang++ compilation To build with the layer registry clang++ requires `-force_load` as g++ requires `--whole-archive`. --- Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b0b2515..aac8205 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,6 @@ endif LIB_BUILD_DIR := $(BUILD_DIR)/lib STATIC_NAME := $(LIB_BUILD_DIR)/lib$(PROJECT).a DYNAMIC_NAME := $(LIB_BUILD_DIR)/lib$(PROJECT).so -STATIC_LINK_COMMAND := -Wl,--whole-archive $(STATIC_NAME) -Wl,--no-whole-archive ############################## # Get all source files @@ -228,6 +227,7 @@ else ifeq ($(UNAME), Darwin) OSX := 1 endif +# Linux ifeq ($(LINUX), 1) CXX ?= /usr/bin/g++ GCCVERSION := $(shell $(CXX) -dumpversion | cut -f1,2 -d.) @@ -259,6 +259,15 @@ ifdef CUSTOM_CXX CXX := $(CUSTOM_CXX) endif +# Static linking +ifneq (,$(findstring clang++,$(CXX))) + STATIC_LINK_COMMAND := -Wl,-force_load $(STATIC_NAME) +else ifneq (,$(findstring g++,$(CXX))) + STATIC_LINK_COMMAND := -Wl,--whole-archive $(STATIC_NAME) -Wl,--no-whole-archive +else + $(error Cannot static link with the $(CXX) compiler.) +endif + # Debugging ifeq ($(DEBUG), 1) COMMON_FLAGS += -DDEBUG -g -O0 -- 2.7.4