Skip to content

Commit

Permalink
cmd/cgo: add -fno-stack-protector to CFLAGS (again)
Browse files Browse the repository at this point in the history
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 golang#52919.
Updates golang#54313.
Updates golang#57261.
Updates golang#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
thanm authored and johanbrandhorst committed Feb 12, 2023
1 parent cee497e commit 7ebafcf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/runtime/cgo/cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ package cgo
#cgo solaris LDFLAGS: -lxnet
#cgo solaris LDFLAGS: -lsocket
#cgo CFLAGS: -Wall -Werror
// Use -fno-stack-protector to avoid problems locating the
// proper support functions. See issues #52919, #54313, #58385.
#cgo CFLAGS: -Wall -Werror -fno-stack-protector
#cgo solaris CPPFLAGS: -D_POSIX_PTHREAD_SEMANTICS
Expand Down

3 comments on commit 7ebafcf

@nmeum
Copy link

@nmeum nmeum commented on 7ebafcf Feb 13, 2023

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.

@johanbrandhorst
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fork of the Go compiler. This is not the right place to ask this question, I think.

@nmeum
Copy link

@nmeum nmeum commented on 7ebafcf Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opps, indeed 🤦

Please sign in to comment.