golang: Use GO_LDFLAGS to set buildmode=pie for host Go
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
This commit is contained in:
parent
66eabf18f5
commit
03a1f87549
1 changed files with 3 additions and 20 deletions
|
@ -189,9 +189,8 @@ ifeq ($(GO_HOST_PIE_SUPPORTED),1)
|
||||||
HOST_GO_ENABLE_PIE:=1
|
HOST_GO_ENABLE_PIE:=1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HOST_GO_ENABLE_PIE),1)
|
# when using GO_LDFLAGS to set buildmode=pie, the PIE install suffix
|
||||||
HOST_GO_INSTALL_SUFFIX:=$(GO_HOST_PIE_INSTALL_SUFFIX)
|
# does not apply (we also delete the std lib during Host/Install)
|
||||||
endif
|
|
||||||
|
|
||||||
$(eval $(call GoCompiler/AddProfile,Host,$(HOST_BUILD_DIR),$(HOST_GO_PREFIX),$(HOST_GO_VERSION_ID),$(GO_HOST_OS_ARCH),$(HOST_GO_INSTALL_SUFFIX)))
|
$(eval $(call GoCompiler/AddProfile,Host,$(HOST_BUILD_DIR),$(HOST_GO_PREFIX),$(HOST_GO_VERSION_ID),$(GO_HOST_OS_ARCH),$(HOST_GO_INSTALL_SUFFIX)))
|
||||||
|
|
||||||
|
@ -201,9 +200,6 @@ HOST_GO_VARS= \
|
||||||
CC=$(HOSTCC_NOCACHE) \
|
CC=$(HOSTCC_NOCACHE) \
|
||||||
CXX=$(HOSTCXX_NOCACHE)
|
CXX=$(HOSTCXX_NOCACHE)
|
||||||
|
|
||||||
# when https://github.com/golang/go/issues/31544 is fixed,
|
|
||||||
# we should be able to set GO_LDFLAGS=-buildmode=pie for host make
|
|
||||||
# instead of doing a rebuild for pie
|
|
||||||
define Host/Compile
|
define Host/Compile
|
||||||
$(call GoCompiler/Bootstrap/CheckHost,$(BOOTSTRAP_GO_VALID_OS_ARCH))
|
$(call GoCompiler/Bootstrap/CheckHost,$(BOOTSTRAP_GO_VALID_OS_ARCH))
|
||||||
$(call GoCompiler/Host/CheckHost,$(HOST_GO_VALID_OS_ARCH))
|
$(call GoCompiler/Host/CheckHost,$(HOST_GO_VALID_OS_ARCH))
|
||||||
|
@ -216,22 +212,9 @@ define Host/Compile
|
||||||
|
|
||||||
$(call GoCompiler/Host/Make, \
|
$(call GoCompiler/Host/Make, \
|
||||||
GOROOT_BOOTSTRAP=$(BOOTSTRAP_ROOT_DIR) \
|
GOROOT_BOOTSTRAP=$(BOOTSTRAP_ROOT_DIR) \
|
||||||
|
$(if $(HOST_GO_ENABLE_PIE),GO_LDFLAGS="-buildmode pie") \
|
||||||
$(HOST_GO_VARS) \
|
$(HOST_GO_VARS) \
|
||||||
)
|
)
|
||||||
|
|
||||||
ifneq ($(HOST_GO_ENABLE_PIE),)
|
|
||||||
@echo "Rebuilding host Go with PIE"
|
|
||||||
|
|
||||||
( \
|
|
||||||
cd $(HOST_BUILD_DIR)/bin ; \
|
|
||||||
$(CP) go go-nopie ; \
|
|
||||||
$(HOST_GO_VARS) \
|
|
||||||
./go-nopie install -a -buildmode pie std cmd ; \
|
|
||||||
retval=$$$$? ; \
|
|
||||||
rm -f go-nopie ; \
|
|
||||||
exit $$$$retval ; \
|
|
||||||
)
|
|
||||||
endif
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# if host and target os/arch are the same,
|
# if host and target os/arch are the same,
|
||||||
|
|
Loading…
Reference in a new issue