Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/maptool: correctly build with CGO_ENABLED=0 if not in RACE mode #24142

Merged
merged 1 commit into from Mar 3, 2023

Conversation

tklauser
Copy link
Member

@tklauser tklauser commented Mar 2, 2023

Makefile.defs already defines $GO_BUILD depending on $RACE, no need to duplicate the logic. Also, the detection of $RACE being set is not working correctly, note that CGO_ENABLED=1 despite $RACE being empty:

% RACE= make
CGO_ENABLED=1  go build -mod=vendor -ldflags '-X "github.com/cilium/cilium/pkg/version.ciliumVersion=1.13.90 666d6991d9d0 2023-02-28T10:58:01+00:00" -s -w -X "github.com/cilium/cilium/pkg/envoy.RequiredEnvoyVersionSHA=505865fff55aa3e7e3e490044c428651e0fe339c" -X "github.com/cilium/cilium/pkg/datapath/loader.DatapathSHA256=920256b880238047f84e8dd31a10b24c3606c0e071f53fdc6445526b1db81d22" ' -tags=osusergo  -o maptool

After this patch:

% RACE= make
CGO_ENABLED=0 go build -mod=vendor -ldflags '-X "github.com/cilium/cilium/pkg/version.ciliumVersion=1.13.90 283254dff59e 2023-03-02T16:55:57+01:00" -s -w -X "github.com/cilium/cilium/pkg/envoy.RequiredEnvoyVersionSHA=505865fff55aa3e7e3e490044c428651e0fe339c" -X "github.com/cilium/cilium/pkg/datapath/loader.DatapathSHA256=920256b880238047f84e8dd31a10b24c3606c0e071f53fdc6445526b1db81d22" ' -tags=osusergo  -o maptool

And setting RACE=1 correctly build with CGO_ENABLED=1:

% RACE=1 make
CGO_ENABLED=1  go build -mod=vendor -race -ldflags '-X "github.com/cilium/cilium/pkg/version.ciliumVersion=1.13.90 283254dff59e 2023-03-02T16:55:57+01:00" -s -w -X "github.com/cilium/cilium/pkg/envoy.RequiredEnvoyVersionSHA=505865fff55aa3e7e3e490044c428651e0fe339c" -X "github.com/cilium/cilium/pkg/datapath/loader.DatapathSHA256=920256b880238047f84e8dd31a10b24c3606c0e071f53fdc6445526b1db81d22" ' -tags=osusergo,lockdebug  -mod=vendor -race -ldflags '-X "github.com/cilium/cilium/pkg/version.ciliumVersion=1.13.90 283254dff59e 2023-03-02T16:55:57+01:00" -s -w -X "github.com/cilium/cilium/pkg/envoy.RequiredEnvoyVersionSHA=505865fff55aa3e7e3e490044c428651e0fe339c" -X "github.com/cilium/cilium/pkg/datapath/loader.DatapathSHA256=920256b880238047f84e8dd31a10b24c3606c0e071f53fdc6445526b1db81d22" ' -tags=osusergo,lockdebug  -o maptool

Fixes: c6d373c ("Makefile: Build maptool with CGO enabled if RACE")

Makefile.defs already defines $GO_BUILD depending on $RACE, no need to
duplicate the logic. Also, the detection of $RACE being set is not
working correctly, note that CGO_ENABLED=1 despite $RACE being empty:

    % RACE= make
    CGO_ENABLED=1  go build -mod=vendor -ldflags '-X "github.com/cilium/cilium/pkg/version.ciliumVersion=1.13.90 666d699 2023-02-28T10:58:01+00:00" -s -w -X "github.com/cilium/cilium/pkg/envoy.RequiredEnvoyVersionSHA=505865fff55aa3e7e3e490044c428651e0fe339c" -X "github.com/cilium/cilium/pkg/datapath/loader.DatapathSHA256=920256b880238047f84e8dd31a10b24c3606c0e071f53fdc6445526b1db81d22" ' -tags=osusergo  -o maptool

After this patch:

    % RACE= make
    CGO_ENABLED=0 go build -mod=vendor -ldflags '-X "github.com/cilium/cilium/pkg/version.ciliumVersion=1.13.90 283254dff59e 2023-03-02T16:55:57+01:00" -s -w -X "github.com/cilium/cilium/pkg/envoy.RequiredEnvoyVersionSHA=505865fff55aa3e7e3e490044c428651e0fe339c" -X "github.com/cilium/cilium/pkg/datapath/loader.DatapathSHA256=920256b880238047f84e8dd31a10b24c3606c0e071f53fdc6445526b1db81d22" ' -tags=osusergo  -o maptool

And setting RACE=1 correctly build with CGO_ENABLED=1:

    % RACE=1 make
    CGO_ENABLED=1  go build -mod=vendor -race -ldflags '-X "github.com/cilium/cilium/pkg/version.ciliumVersion=1.13.90 283254dff59e 2023-03-02T16:55:57+01:00" -s -w -X "github.com/cilium/cilium/pkg/envoy.RequiredEnvoyVersionSHA=505865fff55aa3e7e3e490044c428651e0fe339c" -X "github.com/cilium/cilium/pkg/datapath/loader.DatapathSHA256=920256b880238047f84e8dd31a10b24c3606c0e071f53fdc6445526b1db81d22" ' -tags=osusergo,lockdebug  -mod=vendor -race -ldflags '-X "github.com/cilium/cilium/pkg/version.ciliumVersion=1.13.90 283254dff59e 2023-03-02T16:55:57+01:00" -s -w -X "github.com/cilium/cilium/pkg/envoy.RequiredEnvoyVersionSHA=505865fff55aa3e7e3e490044c428651e0fe339c" -X "github.com/cilium/cilium/pkg/datapath/loader.DatapathSHA256=920256b880238047f84e8dd31a10b24c3606c0e071f53fdc6445526b1db81d22" ' -tags=osusergo,lockdebug  -o maptool

Fixes: c6d373c ("Makefile: Build maptool with CGO enabled if RACE")
Signed-off-by: Tobias Klauser <tobias@cilium.io>
@tklauser tklauser added the release-note/misc This PR makes changes that have no direct user impact. label Mar 2, 2023
@tklauser tklauser requested a review from a team as a code owner March 2, 2023 16:01
@tklauser tklauser requested a review from nebril March 2, 2023 16:01
@tklauser tklauser added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Mar 3, 2023
@borkmann borkmann merged commit ef9d6da into master Mar 3, 2023
@borkmann borkmann deleted the pr/tklauser/maptool-build branch March 3, 2023 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants