Skip to content

Commit

Permalink
tools/maptool: correctly build with CGO_ENABLED=0 if not in RACE mode
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
tklauser authored and borkmann committed Mar 3, 2023
1 parent 576561f commit ef9d6da
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions tools/maptool/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ all: $(TARGET)

$(TARGET):
@$(ECHO_GO)
ifneq ($(RACE),"")
$(QUIET)$(GO_BUILD_WITH_CGO) -o $@
else
$(QUIET)$(GO_BUILD) -o $@
endif

clean:
@$(ECHO_CLEAN)
Expand Down

0 comments on commit ef9d6da

Please sign in to comment.