#1014 Golang uses gcc to compile binaries but doesn't inherit CFLAGS.
Closed by james. Opened by jnovy.
jnovy/packaging-committee golang  into  master

Download 1014.patch

The CGO_CFLAGS variable needs to be used in order to do so. Not
specifying CGO_CFLAGS would lead to not using %optflags and hence
in unoptimized/unhardened code.

Signed-off-by: Jindrich Novy jnovy@redhat.com

@deparker ping, is this something that could be added to the %gobuild macro?

@deparker re-ping :)

I'm reviewing old tickets and after reading this I'm not entirely sure whether we were waiting on one of the Go maintainers to make some change or if we need to do something else.

Not sure who maintains the Go macros right now, but it would be good to have this in %gobuild, so packagers don't need to do this manually (or continue forgetting to do so). Maybe @eclipseo knows? He's who maintains most Go packages right now, I think.

BTW: I tried applying this to one of my Go packages (setting CGO_CFLAGS to what CFLAGS gets set to by %set_build_flags), and it immediately crashed the go compiler. :broken_heart:

Currently we use this for the toolbox RPM, and it seems to have held up for almost a year:

CGO_CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64"

Pull-Request has been closed by james

Metadata