Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 1 | From c537b87782293fe222f2ef5eb1ae818092118e97 Mon Sep 17 00:00:00 2001 |
| 2 | From: Ian Lance Taylor <iant@golang.org> |
| 3 | Date: Sun, 07 Aug 2022 19:21:15 -0700 |
| 4 | Subject: [PATCH] runtime/cgo: add -fno-stack-protector to CFLAGS |
| 5 | |
| 6 | Some compilers default to having -fstack-protector on, which breaks |
| 7 | when using internal linking because the linker doesn't know how to |
| 8 | find the support functions. |
| 9 | |
| 10 | Fixes #52919 |
| 11 | Fixes #54313 |
| 12 | |
| 13 | Change-Id: I6f51d5e906503f61fc768ad8e30c163bad135087 |
| 14 | Upstream-Status: Submitted [https://github.com/golang/go/issues/54313] |
| 15 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> |
| 16 | --- |
| 17 | |
| 18 | diff --git a/src/runtime/cgo/cgo.go b/src/runtime/cgo/cgo.go |
| 19 | index 298aa63..4b7046e 100644 |
| 20 | --- a/src/runtime/cgo/cgo.go |
| 21 | +++ b/src/runtime/cgo/cgo.go |
| 22 | @@ -23,7 +23,9 @@ |
| 23 | #cgo solaris LDFLAGS: -lxnet |
| 24 | #cgo solaris LDFLAGS: -lsocket |
| 25 | |
| 26 | -#cgo CFLAGS: -Wall -Werror |
| 27 | +// We use -fno-stack-protector because internal linking won't find |
| 28 | +// the support functions. See issues #52919 and #54313. |
| 29 | +#cgo CFLAGS: -Wall -Werror -fno-stack-protector |
| 30 | |
| 31 | #cgo solaris CPPFLAGS: -D_POSIX_PTHREAD_SEMANTICS |
| 32 | |