Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/cgo: add -fno-stack-protector to CFLAGS (again)
Add -fno-stack-protector back to the default set of CFLAGS for cgo, so as to avoid problems with internal linking locating the library containing the "__stack_chk_fail_local" support function that some compilers emit (the specific archive can vary based on GOOS). Updates #52919. Updates #54313. Updates #57261. Updates #58385. Change-Id: I4591bfb15501f04b7afe1fcd50c4fb93c86db63d Reviewed-on: https://go-review.googlesource.com/c/go/+/466935 Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Than McIntosh <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
- Loading branch information
48f4728
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this was re-added. Just compiling the cgo runtime with
-fno-stack-protector
is not sufficient as all cgo code (i.e. not just the run-time) will need to be compiled with-fno-stack-protector
if you don't want to link against the library providing__stack_chk_fail_local
. Or am I missing something here?48f4728
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI, few people read comments on github commits, probably best to comment on Gerrit instead.
Regular user programs that use CGO will default to external linking, meaning that it's the external linker that has to resolve
__stack_chk_fail_local
(this is the normal case).For the case where someone builds a vanilla Go program (no CGO) with -race, we'll be using internal linking (no external linker involved). In this case the Go linker has to resolve
__stack_chk_fail_local
, and as is clear from this sequence of bugs, it can come from different places depending on the OS. Better to go back to turning off stack protector for the Go CGO-related code than to have to fix other issues down the line as people use "go build -race" on future linux distributions that put things in different places.