Don't set -pie for windows modules
Adding -pie to LOCAL_LDFLAGS for host linking leaves it around
when doing the host cross Windows linking, resulting in a warning:
clang-7: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
Add it later in binary.mk after the flags have been copied to the
single-use my_ldflags.
Bug: 115776263
Test: m checkbuild
Change-Id: I70d71fa1ec6445631dc7e89ef61927a3304375e2
diff --git a/core/binary.mk b/core/binary.mk
index a594149..37f35bc 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -281,13 +281,18 @@
# all code is position independent, and then those warnings get promoted to
# errors.
ifneq ($(LOCAL_NO_PIC),true)
-ifneq ($($(my_prefix)OS),windows)
-ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
-my_cflags += -fPIE
-else
-my_cflags += -fPIC
-endif
-endif
+ ifneq ($($(my_prefix)OS),windows)
+ ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
+ my_cflags += -fPIE
+ ifndef BUILD_HOST_static
+ ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
+ my_ldflags += -pie
+ endif
+ endif
+ else
+ my_cflags += -fPIC
+ endif
+ endif
endif
ifdef LOCAL_IS_HOST_MODULE