From feb4a7e4aefe0b20489a8c5c1abfc09556814503 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 19 Sep 2018 14:45:52 -0700 Subject: [PATCH] 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 --- core/binary.mk | 19 ++++++++++++------- core/definitions.mk | 5 ----- core/host_executable.mk | 12 ------------ 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/core/binary.mk b/core/binary.mk index a594149f53..37f35bca66 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -281,13 +281,18 @@ endif # 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 diff --git a/core/definitions.mk b/core/definitions.mk index 82447c9470..2dff9cfe7f 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1881,11 +1881,6 @@ endef ########################################################### ## Commands for running gcc to link a host executable ########################################################### -ifdef BUILD_HOST_static -HOST_FPIE_FLAGS := -else -HOST_FPIE_FLAGS := -pie -endif ifneq ($(HOST_CUSTOM_LD_COMMAND),true) define transform-host-o-to-executable-inner diff --git a/core/host_executable.mk b/core/host_executable.mk index 1480c2c0c6..e4b5bc82cb 100644 --- a/core/host_executable.mk +++ b/core/host_executable.mk @@ -11,10 +11,6 @@ my_module_multilib := first endif endif -ifeq ($(LOCAL_NO_FPIE),) -LOCAL_LDFLAGS += $(HOST_FPIE_FLAGS) -endif - ifeq ($(my_module_multilib),both) ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS) ifeq ($(LOCAL_MODULE_PATH_32)$(LOCAL_MODULE_STEM_32),) @@ -65,10 +61,6 @@ LOCAL_BUILT_MODULE := LOCAL_INSTALLED_MODULE := LOCAL_INTERMEDIATE_TARGETS := -ifeq ($(LOCAL_NO_FPIE),) -LOCAL_LDFLAGS += $(HOST_CROSS_FPIE_FLAGS) -endif - include $(BUILD_SYSTEM)/host_executable_internal.mk LOCAL_LDFLAGS := $(saved_LOCAL_LDFLAGS) LOCAL_BUILT_MODULE := $(saved_LOCAL_BUILT_MODULE) @@ -88,10 +80,6 @@ LOCAL_BUILT_MODULE := LOCAL_INSTALLED_MODULE := LOCAL_INTERMEDIATE_TARGETS := -ifeq ($(LOCAL_NO_FPIE),) -LOCAL_LDFLAGS += $(HOST_CROSS_FPIE_FLAGS) -endif - include $(BUILD_SYSTEM)/host_executable_internal.mk LOCAL_LDFLAGS := $(saved_LOCAL_LDFLAGS) LOCAL_BUILT_MODULE := $(saved_LOCAL_BUILT_MODULE)