Closed jaideepr97 closed 2 years ago
/lgtm
I was wondering tho, if we could just not set CGO_ENABLED=0
for the build?
@jannfis Would that be a problem if we are using any packages that absolutely require cgo
? My understanding is the net
package that is pulled in by one of kam's dependencies maybe one such package but I don't have an in-depth understanding of this
I was thinking we could just try to build a new RPM with these extdflags in place, supply the buildmode=pie
flag and then find a way to run the RPMDiff test again just on this newly built RPM to see if that addresses all the concerns
Would that be a problem if we are using any packages that absolutely require cgo
Yes, probably
My understanding is the net package that is pulled in by one of kam's dependencies maybe one such package
I think it used to be due to the resolver, but meanwhile, Go also provides a Go-native resolver to be used with CGO_ENABLED=0 (https://pkg.go.dev/net#hdr-Name_Resolution)
kam compiles, links and runs fine when built with CGO_ENABLED=0
. However, it produces a static binary. What's funny is, that it's even a little smaller than the dynamically one, which was built using cgo:
-rwxr-xr-x 1 foo foo 45056000 Mar 3 21:54 dist/kam_linux_amd64
-rwxr-xr-x 1 foo foo 45109248 Mar 3 21:53 dist/kam_linux_amd64-cgo
Anyway, I think for now, we should go for the linker flags.
/retest
/approve
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: wtam2018
The full list of commands accepted by this bot can be found here.
The pull request process is described here
What type of PR is this?
What does this PR do / why we need it: it seems like kam pulls in the
net
package as a dependency which I suspect is causingcgo
to be used for compilation indirectly and maybe causing kam to be dynamically linked. (This might also be putting the KAM binary in a position to benefit from supplying the-buildmode=pie
flag) The RPMDiff test in cpaas currently throws an error because we don't add the-Wl,-z,now
flags for external linker while building the kam binary This PR fixes thatHave you updated the necessary documentation?
Which issue(s) this PR fixes:
Fixes https://issues.redhat.com/browse/GITOPS-1714 partially
How to test changes / Special notes to the reviewer: