Message ID | 20221101003419.754757-1-christian@paral.in |
---|---|
State | Rejected, archived |
Headers | show |
Series | [1/1] package/go: disable stack protector for cgo | expand |
On 01/11/2022 01:34, Christian Stewart via buildroot wrote: > Enabling the C stack protector for Cgo causes a build failure on i386: > > runtime/cgo(.text): unknown symbol __stack_chk_fail_local in pcrel > runtime/cgo(.text): unknown symbol __stack_chk_fail_local in pcrel > runtime/cgo(.text): unknown symbol __stack_chk_fail_local in pcrel > runtime/cgo(.text): unknown symbol __stack_chk_fail_local in pcrel > runtime/cgo(.text): unknown symbol __stack_chk_fail_local in pcrel > runtime/cgo(.text): relocation target __stack_chk_fail_local not defined > runtime/cgo(.text): relocation target __stack_chk_fail_local not defined > > Add: CGO_CFLAGS=-fno-stack-protector > > https://github.com/golang/go/issues/52919 Based on the comments in this issue, I could determine that this was in fact already fixed in 1.19.1, which we applied in Buildroot on September 7. I could reproduce the issue after reverting to 1.19, but not with 1.19.1. Therefore, I marked the patch as Rejected in patchwork. BTW, in the future, please make sure that a patch that fixes something includes the Fixes: tag - this marks it in patchwork and makes it easier to pick up. Regards, Arnout > > Set CGO_CFLAGS and other flags while building Go with make.bash as well. > > Signed-off-by: Christian Stewart <christian@paral.in> > --- > package/go/go.mk | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/package/go/go.mk b/package/go/go.mk > index fe4d3a29a9..d6c15c4ac9 100644 > --- a/package/go/go.mk > +++ b/package/go/go.mk > @@ -49,6 +49,8 @@ else ifeq ($(BR2_aarch64),y) > GO_GOARCH = arm64 > else ifeq ($(BR2_i386),y) > GO_GOARCH = 386 > +# stack-protector causes a build failure on i386. > +HOST_GO_CGO_CFLAGS += -fno-stack-protector > # i386: use softfloat if no SSE2: https://golang.org/doc/go1.16#386 > ifneq ($(BR2_X86_CPU_HAS_SSE2),y) > GO_GO386 = softfloat > @@ -78,7 +80,7 @@ HOST_GO_TARGET_ENV = \ > GOCACHE="$(HOST_GO_TARGET_CACHE)" \ > CC="$(TARGET_CC)" \ > CXX="$(TARGET_CXX)" \ > - CGO_CFLAGS="$(TARGET_CFLAGS)" \ > + CGO_CFLAGS="$(TARGET_CFLAGS) $(HOST_GO_CGO_CFLAGS)" \ > CGO_CXXFLAGS="$(TARGET_CXXFLAGS)" \ > CGO_LDFLAGS="$(TARGET_LDFLAGS)" \ > GOTOOLDIR="$(HOST_GO_TOOLDIR)" > @@ -109,6 +111,7 @@ HOST_GO_CGO_ENABLED = 1 > endif # BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS > > # For the convenience of host golang packages > +# stack-protector causes a build failure on some architectures. > HOST_GO_HOST_ENV = \ > $(HOST_GO_COMMON_ENV) \ > GOOS="" \ > @@ -116,7 +119,7 @@ HOST_GO_HOST_ENV = \ > GOCACHE="$(HOST_GO_HOST_CACHE)" \ > CC="$(HOSTCC_NOCCACHE)" \ > CXX="$(HOSTCXX_NOCCACHE)" \ > - CGO_CFLAGS="$(HOST_CFLAGS)" \ > + CGO_CFLAGS="$(HOST_CFLAGS) $(HOST_GO_CGO_CFLAGS)" \ > CGO_CXXFLAGS="$(HOST_CXXFLAGS)" \ > CGO_LDFLAGS="$(HOST_LDFLAGS)" > > @@ -133,6 +136,9 @@ HOST_GO_MAKE_ENV = \ > CC=$(HOSTCC_NOCCACHE) \ > CXX=$(HOSTCXX_NOCCACHE) \ > CGO_ENABLED=$(HOST_GO_CGO_ENABLED) \ > + CGO_CFLAGS="$(HOST_CFLAGS) $(HOST_GO_CGO_CFLAGS)" \ > + CGO_CXXFLAGS="$(HOST_CXXFLAGS)" \ > + CGO_LDFLAGS="$(HOST_LDFLAGS)" \ > $(HOST_GO_CROSS_ENV) > > define HOST_GO_BUILD_CMDS
diff --git a/package/go/go.mk b/package/go/go.mk index fe4d3a29a9..d6c15c4ac9 100644 --- a/package/go/go.mk +++ b/package/go/go.mk @@ -49,6 +49,8 @@ else ifeq ($(BR2_aarch64),y) GO_GOARCH = arm64 else ifeq ($(BR2_i386),y) GO_GOARCH = 386 +# stack-protector causes a build failure on i386. +HOST_GO_CGO_CFLAGS += -fno-stack-protector # i386: use softfloat if no SSE2: https://golang.org/doc/go1.16#386 ifneq ($(BR2_X86_CPU_HAS_SSE2),y) GO_GO386 = softfloat @@ -78,7 +80,7 @@ HOST_GO_TARGET_ENV = \ GOCACHE="$(HOST_GO_TARGET_CACHE)" \ CC="$(TARGET_CC)" \ CXX="$(TARGET_CXX)" \ - CGO_CFLAGS="$(TARGET_CFLAGS)" \ + CGO_CFLAGS="$(TARGET_CFLAGS) $(HOST_GO_CGO_CFLAGS)" \ CGO_CXXFLAGS="$(TARGET_CXXFLAGS)" \ CGO_LDFLAGS="$(TARGET_LDFLAGS)" \ GOTOOLDIR="$(HOST_GO_TOOLDIR)" @@ -109,6 +111,7 @@ HOST_GO_CGO_ENABLED = 1 endif # BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS # For the convenience of host golang packages +# stack-protector causes a build failure on some architectures. HOST_GO_HOST_ENV = \ $(HOST_GO_COMMON_ENV) \ GOOS="" \ @@ -116,7 +119,7 @@ HOST_GO_HOST_ENV = \ GOCACHE="$(HOST_GO_HOST_CACHE)" \ CC="$(HOSTCC_NOCCACHE)" \ CXX="$(HOSTCXX_NOCCACHE)" \ - CGO_CFLAGS="$(HOST_CFLAGS)" \ + CGO_CFLAGS="$(HOST_CFLAGS) $(HOST_GO_CGO_CFLAGS)" \ CGO_CXXFLAGS="$(HOST_CXXFLAGS)" \ CGO_LDFLAGS="$(HOST_LDFLAGS)" @@ -133,6 +136,9 @@ HOST_GO_MAKE_ENV = \ CC=$(HOSTCC_NOCCACHE) \ CXX=$(HOSTCXX_NOCCACHE) \ CGO_ENABLED=$(HOST_GO_CGO_ENABLED) \ + CGO_CFLAGS="$(HOST_CFLAGS) $(HOST_GO_CGO_CFLAGS)" \ + CGO_CXXFLAGS="$(HOST_CXXFLAGS)" \ + CGO_LDFLAGS="$(HOST_LDFLAGS)" \ $(HOST_GO_CROSS_ENV) define HOST_GO_BUILD_CMDS
Enabling the C stack protector for Cgo causes a build failure on i386: runtime/cgo(.text): unknown symbol __stack_chk_fail_local in pcrel runtime/cgo(.text): unknown symbol __stack_chk_fail_local in pcrel runtime/cgo(.text): unknown symbol __stack_chk_fail_local in pcrel runtime/cgo(.text): unknown symbol __stack_chk_fail_local in pcrel runtime/cgo(.text): unknown symbol __stack_chk_fail_local in pcrel runtime/cgo(.text): relocation target __stack_chk_fail_local not defined runtime/cgo(.text): relocation target __stack_chk_fail_local not defined Add: CGO_CFLAGS=-fno-stack-protector https://github.com/golang/go/issues/52919 Set CGO_CFLAGS and other flags while building Go with make.bash as well. Signed-off-by: Christian Stewart <christian@paral.in> --- package/go/go.mk | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)