diff --git a/Makefile b/Makefile index dc885e75ad..3122dceb47 100644 --- a/Makefile +++ b/Makefile @@ -139,14 +139,14 @@ setup-envtest: $(ENVTEST) all: generate generate: generate-bpf-go - CGO_ENABLED=0 go generate ./... + go generate ./... for dir in $(GENERATE_TARGET_DIRS); do \ make -C $$dir $@; \ done generate-bpf-go: ## generate ebpf wrappers for plugins for all archs for arch in $(ALL_ARCH.linux); do \ - CGO_ENABLED=0 GOARCH=$$arch go generate ./pkg/plugin/...; \ + GOARCH=$$arch go generate ./pkg/plugin/...; \ done .PHONY: all generate generate-bpf-go @@ -174,12 +174,11 @@ retina: ## builds retina binary $(MAKE) retina-binary retina-binary: ## build the Retina binary - export CGO_ENABLED=0 && \ go generate ./... && \ go build -v -o $(RETINA_BUILD_DIR)/retina$(EXE_EXT) -gcflags="-dwarflocationlists=true" -ldflags "-X github.com/microsoft/retina/internal/buildinfo.Version=$(TAG) -X github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID=$(APP_INSIGHTS_ID)" $(RETINA_DIR)/main.go retina-capture-workload: ## build the Retina capture workload - cd $(CAPTURE_WORKLOAD_DIR) && CGO_ENABLED=0 go build -v -o $(RETINA_BUILD_DIR)/captureworkload$(EXE_EXT) -gcflags="-dwarflocationlists=true" -ldflags "-X main.version=$(TAG)" + cd $(CAPTURE_WORKLOAD_DIR) && go build -v -o $(RETINA_BUILD_DIR)/captureworkload$(EXE_EXT) -gcflags="-dwarflocationlists=true" -ldflags "-X main.version=$(TAG)" ##@ Containers @@ -410,7 +409,7 @@ COVER_PKG ?= . test: $(ENVTEST) # Run unit tests. go build -o test-summary ./test/utsummary/main.go - CGO_ENABLED=0 KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use -p path)" go test -tags=unit,dashboard -skip=TestE2E* -coverprofile=coverage.out -v -json ./... | ./test-summary --progress --verbose + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use -p path)" go test -tags=unit,dashboard -skip=TestE2E* -coverprofile=coverage.out -v -json ./... | ./test-summary --progress --verbose coverage: # Code coverage. # go generate ./... && go test -tags=unit -coverprofile=coverage.out.tmp ./... diff --git a/controller/Dockerfile b/controller/Dockerfile index 4090d1b391..73016c6855 100644 --- a/controller/Dockerfile +++ b/controller/Dockerfile @@ -25,7 +25,6 @@ FROM golang AS intermediate ARG APP_INSIGHTS_ID # set to enable AI telemetry ARG GOARCH=amd64 # default to amd64 ARG GOOS=linux # default to linux -ENV CGO_ENABLED=0 ENV GOARCH=${GOARCH} ENV GOOS=${GOOS} RUN if [ "$GOOS" = "linux" ] ; then \ @@ -52,7 +51,6 @@ ARG APP_INSIGHTS_ID # set to enable AI telemetry ARG GOARCH=amd64 # default to amd64 ARG GOOS=linux # default to linux ARG VERSION -ENV CGO_ENABLED=0 ENV GOARCH=${GOARCH} ENV GOOS=${GOOS} RUN --mount=type=cache,target="/root/.cache/go-build" go build -v -o /go/bin/retina/captureworkload -ldflags "-X github.com/microsoft/retina/internal/buildinfo.Version="$VERSION" -X github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID="$APP_INSIGHTS_ID"" captureworkload/main.go @@ -64,7 +62,6 @@ ARG APP_INSIGHTS_ID # set to enable AI telemetry ARG GOARCH=amd64 # default to amd64 ARG GOOS=linux # default to linux ARG VERSION -ENV CGO_ENABLED=0 ENV GOARCH=${GOARCH} ENV GOOS=${GOOS} RUN --mount=type=cache,target="/root/.cache/go-build" go build -v -o /go/bin/retina/controller -ldflags "-X github.com/microsoft/retina/internal/buildinfo.Version="$VERSION" -X github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID="$APP_INSIGHTS_ID"" controller/main.go @@ -76,7 +73,6 @@ ARG APP_INSIGHTS_ID # set to enable AI telemetry ARG GOARCH=amd64 # default to amd64 ARG GOOS=linux # default to linux ARG VERSION -ENV CGO_ENABLED=0 ENV GOARCH=${GOARCH} ENV GOOS=${GOOS} RUN --mount=type=cache,target="/root/.cache/go-build" go build -v -o /go/bin/retina/initretina -ldflags "-X github.com/microsoft/retina/internal/buildinfo.Version="$VERSION" -X github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID="$APP_INSIGHTS_ID"" init/retina/main_linux.go diff --git a/controller/Dockerfile.windows-native b/controller/Dockerfile.windows-native index 8224ed91d4..6c6c47d1ce 100644 --- a/controller/Dockerfile.windows-native +++ b/controller/Dockerfile.windows-native @@ -8,7 +8,6 @@ FROM --platform=windows/amd64 mcr.microsoft.com/oss/go/microsoft/golang@sha256:e WORKDIR C:\\retina COPY go.mod . COPY go.sum . -ENV CGO_ENABLED=0 RUN go mod download ADD . . ARG VERSION diff --git a/operator/Dockerfile b/operator/Dockerfile index 0b28e13430..23f5e877e5 100644 --- a/operator/Dockerfile +++ b/operator/Dockerfile @@ -17,7 +17,7 @@ ENV GOARCH=${GOARCH} RUN make manifests RUN --mount=type=cache,target="/root/.cache/go-build" \ - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ + GOOS=linux GOARCH=amd64 go build \ -ldflags "-X github.com/microsoft/retina/internal/buildinfo.Version="$VERSION" \ -X "github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID"="$APP_INSIGHTS_ID"" \ -a -o retina-operator operator/main.go @@ -26,6 +26,8 @@ RUN --mount=type=cache,target="/root/.cache/go-build" \ # mcr.microsoft.com/cbl-mariner/distroless/minimal:2.0 FROM --platform=$BUILDPLATFORM mcr.microsoft.com/cbl-mariner/distroless/minimal@sha256:db87903c5d4d9d6760e86a274914efd6a3bb5914c0b5a6c6b35350ec297fea4f WORKDIR / +COPY --from=builder /lib /lib +COPY --from=builder /usr/lib/ /usr/lib COPY --from=builder /workspace/retina-operator . USER 65532:65532 diff --git a/pkg/plugin/conntrack/_cprog/conntrack.c b/pkg/plugin/conntrack/_cprog/conntrack.c index 1b71099ac7..23154b1fae 100644 --- a/pkg/plugin/conntrack/_cprog/conntrack.c +++ b/pkg/plugin/conntrack/_cprog/conntrack.c @@ -1,3 +1,5 @@ +//go:build ignore + // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. diff --git a/pkg/plugin/dropreason/_cprog/drop_reason.c b/pkg/plugin/dropreason/_cprog/drop_reason.c index 00b28e42c9..ed31658c8a 100644 --- a/pkg/plugin/dropreason/_cprog/drop_reason.c +++ b/pkg/plugin/dropreason/_cprog/drop_reason.c @@ -1,3 +1,5 @@ +//go:build ignore + // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. diff --git a/pkg/plugin/filter/_cprog/retina_filter.c b/pkg/plugin/filter/_cprog/retina_filter.c index b03d7b2564..6cf7793546 100644 --- a/pkg/plugin/filter/_cprog/retina_filter.c +++ b/pkg/plugin/filter/_cprog/retina_filter.c @@ -1,3 +1,5 @@ +//go:build ignore + // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. diff --git a/pkg/plugin/lib/common/libbpf/_src/bpf.c b/pkg/plugin/lib/common/libbpf/_src/bpf.c index 2a4c71501a..d467c113a4 100644 --- a/pkg/plugin/lib/common/libbpf/_src/bpf.c +++ b/pkg/plugin/lib/common/libbpf/_src/bpf.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* diff --git a/pkg/plugin/lib/common/libbpf/_src/bpf_prog_linfo.c b/pkg/plugin/lib/common/libbpf/_src/bpf_prog_linfo.c index 5c503096ef..18252d9aa6 100644 --- a/pkg/plugin/lib/common/libbpf/_src/bpf_prog_linfo.c +++ b/pkg/plugin/lib/common/libbpf/_src/bpf_prog_linfo.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* Copyright (c) 2018 Facebook */ diff --git a/pkg/plugin/lib/common/libbpf/_src/btf.c b/pkg/plugin/lib/common/libbpf/_src/btf.c index 32c00db3b9..6325ae8087 100644 --- a/pkg/plugin/lib/common/libbpf/_src/btf.c +++ b/pkg/plugin/lib/common/libbpf/_src/btf.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* Copyright (c) 2018 Facebook */ diff --git a/pkg/plugin/lib/common/libbpf/_src/btf_dump.c b/pkg/plugin/lib/common/libbpf/_src/btf_dump.c index 5dbca76b95..6ecc71b735 100644 --- a/pkg/plugin/lib/common/libbpf/_src/btf_dump.c +++ b/pkg/plugin/lib/common/libbpf/_src/btf_dump.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* diff --git a/pkg/plugin/lib/common/libbpf/_src/btf_iter.c b/pkg/plugin/lib/common/libbpf/_src/btf_iter.c index 9a6c822c22..70df7dff77 100644 --- a/pkg/plugin/lib/common/libbpf/_src/btf_iter.c +++ b/pkg/plugin/lib/common/libbpf/_src/btf_iter.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* Copyright (c) 2021 Facebook */ /* Copyright (c) 2024, Oracle and/or its affiliates. */ diff --git a/pkg/plugin/lib/common/libbpf/_src/btf_relocate.c b/pkg/plugin/lib/common/libbpf/_src/btf_relocate.c index 17f8b32f94..ab5c8d3cfe 100644 --- a/pkg/plugin/lib/common/libbpf/_src/btf_relocate.c +++ b/pkg/plugin/lib/common/libbpf/_src/btf_relocate.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2024, Oracle and/or its affiliates. */ diff --git a/pkg/plugin/lib/common/libbpf/_src/elf.c b/pkg/plugin/lib/common/libbpf/_src/elf.c index c92e023941..179283010e 100644 --- a/pkg/plugin/lib/common/libbpf/_src/elf.c +++ b/pkg/plugin/lib/common/libbpf/_src/elf.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) #ifndef _GNU_SOURCE diff --git a/pkg/plugin/lib/common/libbpf/_src/features.c b/pkg/plugin/lib/common/libbpf/_src/features.c index 50befe125d..9d5607365d 100644 --- a/pkg/plugin/lib/common/libbpf/_src/features.c +++ b/pkg/plugin/lib/common/libbpf/_src/features.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* Copyright (c) 2023 Meta Platforms, Inc. and affiliates. */ #include diff --git a/pkg/plugin/lib/common/libbpf/_src/gen_loader.c b/pkg/plugin/lib/common/libbpf/_src/gen_loader.c index cf3323fd47..55365506b1 100644 --- a/pkg/plugin/lib/common/libbpf/_src/gen_loader.c +++ b/pkg/plugin/lib/common/libbpf/_src/gen_loader.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* Copyright (c) 2021 Facebook */ #include diff --git a/pkg/plugin/lib/common/libbpf/_src/hashmap.c b/pkg/plugin/lib/common/libbpf/_src/hashmap.c index 140ee40556..60436a051b 100644 --- a/pkg/plugin/lib/common/libbpf/_src/hashmap.c +++ b/pkg/plugin/lib/common/libbpf/_src/hashmap.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* diff --git a/pkg/plugin/lib/common/libbpf/_src/libbpf.c b/pkg/plugin/lib/common/libbpf/_src/libbpf.c index a3be6f8fac..298cf2a066 100644 --- a/pkg/plugin/lib/common/libbpf/_src/libbpf.c +++ b/pkg/plugin/lib/common/libbpf/_src/libbpf.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* diff --git a/pkg/plugin/lib/common/libbpf/_src/libbpf_errno.c b/pkg/plugin/lib/common/libbpf/_src/libbpf_errno.c index 6b180172ec..fa6b266a7f 100644 --- a/pkg/plugin/lib/common/libbpf/_src/libbpf_errno.c +++ b/pkg/plugin/lib/common/libbpf/_src/libbpf_errno.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* diff --git a/pkg/plugin/lib/common/libbpf/_src/libbpf_probes.c b/pkg/plugin/lib/common/libbpf/_src/libbpf_probes.c index 9dfbe7750f..c3c4ec5b0f 100644 --- a/pkg/plugin/lib/common/libbpf/_src/libbpf_probes.c +++ b/pkg/plugin/lib/common/libbpf/_src/libbpf_probes.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* Copyright (c) 2019 Netronome Systems, Inc. */ diff --git a/pkg/plugin/lib/common/libbpf/_src/linker.c b/pkg/plugin/lib/common/libbpf/_src/linker.c index 9cd3d41097..2cb16846db 100644 --- a/pkg/plugin/lib/common/libbpf/_src/linker.c +++ b/pkg/plugin/lib/common/libbpf/_src/linker.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* * BPF static linker diff --git a/pkg/plugin/lib/common/libbpf/_src/netlink.c b/pkg/plugin/lib/common/libbpf/_src/netlink.c index 68a2def171..e836631b95 100644 --- a/pkg/plugin/lib/common/libbpf/_src/netlink.c +++ b/pkg/plugin/lib/common/libbpf/_src/netlink.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* Copyright (c) 2018 Facebook */ diff --git a/pkg/plugin/lib/common/libbpf/_src/nlattr.c b/pkg/plugin/lib/common/libbpf/_src/nlattr.c index 975e265eab..53df5de434 100644 --- a/pkg/plugin/lib/common/libbpf/_src/nlattr.c +++ b/pkg/plugin/lib/common/libbpf/_src/nlattr.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* diff --git a/pkg/plugin/lib/common/libbpf/_src/relo_core.c b/pkg/plugin/lib/common/libbpf/_src/relo_core.c index 63a4d5ad12..be4c9f9bd7 100644 --- a/pkg/plugin/lib/common/libbpf/_src/relo_core.c +++ b/pkg/plugin/lib/common/libbpf/_src/relo_core.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* Copyright (c) 2019 Facebook */ diff --git a/pkg/plugin/lib/common/libbpf/_src/ringbuf.c b/pkg/plugin/lib/common/libbpf/_src/ringbuf.c index bfd8dac4c0..9c4871f65c 100644 --- a/pkg/plugin/lib/common/libbpf/_src/ringbuf.c +++ b/pkg/plugin/lib/common/libbpf/_src/ringbuf.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* * Ring buffer operations. diff --git a/pkg/plugin/lib/common/libbpf/_src/str_error.c b/pkg/plugin/lib/common/libbpf/_src/str_error.c index 5e6a1e27dd..1857ab57b2 100644 --- a/pkg/plugin/lib/common/libbpf/_src/str_error.c +++ b/pkg/plugin/lib/common/libbpf/_src/str_error.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) #undef _GNU_SOURCE #include diff --git a/pkg/plugin/lib/common/libbpf/_src/strset.c b/pkg/plugin/lib/common/libbpf/_src/strset.c index 2464bcbd04..598ad3ea86 100644 --- a/pkg/plugin/lib/common/libbpf/_src/strset.c +++ b/pkg/plugin/lib/common/libbpf/_src/strset.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* Copyright (c) 2021 Facebook */ #include diff --git a/pkg/plugin/lib/common/libbpf/_src/usdt.c b/pkg/plugin/lib/common/libbpf/_src/usdt.c index 93794f01bb..1b881df34b 100644 --- a/pkg/plugin/lib/common/libbpf/_src/usdt.c +++ b/pkg/plugin/lib/common/libbpf/_src/usdt.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */ #include diff --git a/pkg/plugin/lib/common/libbpf/_src/xsk.c b/pkg/plugin/lib/common/libbpf/_src/xsk.c index af136f73b0..353f93cd22 100644 --- a/pkg/plugin/lib/common/libbpf/_src/xsk.c +++ b/pkg/plugin/lib/common/libbpf/_src/xsk.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* diff --git a/pkg/plugin/lib/common/libbpf/_src/zip.c b/pkg/plugin/lib/common/libbpf/_src/zip.c index 3f26d629b2..fcb4ecf62d 100644 --- a/pkg/plugin/lib/common/libbpf/_src/zip.c +++ b/pkg/plugin/lib/common/libbpf/_src/zip.c @@ -1,3 +1,5 @@ +//go:build ignore + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) /* * Routines for dealing with .zip archives. diff --git a/pkg/plugin/packetforward/_cprog/packetforward.c b/pkg/plugin/packetforward/_cprog/packetforward.c index d9d9104f43..19b00e2c69 100644 --- a/pkg/plugin/packetforward/_cprog/packetforward.c +++ b/pkg/plugin/packetforward/_cprog/packetforward.c @@ -1,3 +1,5 @@ +//go:build ignore + // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. diff --git a/pkg/plugin/packetparser/_cprog/packetparser.c b/pkg/plugin/packetparser/_cprog/packetparser.c index 18e1270ae0..0243ffadcb 100644 --- a/pkg/plugin/packetparser/_cprog/packetparser.c +++ b/pkg/plugin/packetparser/_cprog/packetparser.c @@ -1,3 +1,5 @@ +//go:build ignore + // Copyright (c) Microsoft Corporation. // Licensed under the MIT license.