From 69b1fe6d1ca4a23ca26c052e52332048c53b37e0 Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Tue, 20 Jan 2015 11:00:20 -0800 Subject: [PATCH] Add -static to static link command, for clang. Clang driver needs -static flag, not -Bstatic, to produce statically linked modules. However, -static is not added if LDFLAGS contains -shared, which is used in bionic/linker to create a shared object with static libraries. BUG: 18008984 Change-Id: I75c3e24973ee77170285ec4c8e7aacc345722685 --- core/definitions.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/definitions.mk b/core/definitions.mk index 02781501e5..98fb7d1144 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1425,11 +1425,16 @@ endef ## Commands for linking a static executable. In practice, ## we only use this on arm, so the other platforms don't ## have transform-o-to-static-executable defined. +## Clang driver needs -static to create static executable. +## However, bionic/linker uses -shared to overwrite. +## Linker for x86 targets does not allow coexistance of -static and -shared, +## so we add -static only if -shared is not used. ########################################################### define transform-o-to-static-executable-inner $(hide) $(PRIVATE_CXX) \ -nostdlib -Bstatic \ + $(if $(filter $(PRIVATE_LDFLAGS),-shared),,-static) \ -Wl,--gc-sections \ -o $@ \ $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \