diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aef210c87f..eaab1f2dca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,8 @@ env: GOFUMPT_VERSION: v0.4.0 # renovate: datasource=go depName=github.com/golangci/golangci-lint GOLANGCI_LINT_VERSION: v1.51.2 + # renovate: datasource=go depName=github.com/florianl/bluebox + BLUEBOX_VERSION: v0.0.1 jobs: skip-check: @@ -38,10 +40,10 @@ jobs: ".go-version", "3rdparty", "Makefile", - "bpf/", - "kerneltest/", + "bpf/**", "go.mod", - "go.sum" + "go.sum", + "kerneltest/**" ] skip_after_successful_duplicate: false @@ -126,7 +128,7 @@ jobs: - name: Build initramfs run: | - go install github.com/florianl/bluebox@v0.0.1 + go install "github.com/florianl/bluebox@${BLUEBOX_VERSION}" make initramfs - name: Upload initramfs diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 6711533bf7..5725fb93c1 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -40,7 +40,7 @@ jobs: "3rdparty", "Dockerfile*", "Makefile", - "bpf/Makefile", + "bpf/**", "deploy/**", "e2e/**", "go.mod", diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 26f2301734..74483b5ef7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,15 +1,4 @@ repos: - - repo: local - hooks: - # We use custom step instead of https://github.com/golangci/golangci-lint, - # because we need to pass additional parameters to for CGO builds. - - id: go-lint - name: go-lint - entry: make go/lint - language: system - types: [go] - pass_filenames: false - - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: @@ -38,6 +27,11 @@ repos: - --fuzzy-match-generates-todo types: [shell] exclude: ^internal/(?:go|pprof)/ + - repo: https://github.com/golangci/golangci-lint + rev: v1.51.2 + hooks: + - id: golangci-lint + entry: make go/lint-fix - repo: https://github.com/hadolint/hadolint rev: v2.12.1-beta hooks: diff --git a/3rdparty/include/stdarg.h b/3rdparty/include/stdarg.h deleted file mode 100644 index a57e183648..0000000000 --- a/3rdparty/include/stdarg.h +++ /dev/null @@ -1,52 +0,0 @@ -/*===---- stdarg.h - Variable argument handling ----------------------------=== - * - * Copyright (c) 2008 Eli Friedman - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - *===-----------------------------------------------------------------------=== - */ - -#ifndef __STDARG_H -#define __STDARG_H - -#ifndef _VA_LIST -typedef __builtin_va_list va_list; -#define _VA_LIST -#endif -#define va_start(ap, param) __builtin_va_start(ap, param) -#define va_end(ap) __builtin_va_end(ap) -#define va_arg(ap, type) __builtin_va_arg(ap, type) - -/* GCC always defines __va_copy, but does not define va_copy unless in c99 mode - * or -ansi is not specified, since it was not part of C90. - */ -#define __va_copy(d,s) __builtin_va_copy(d,s) - -#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L || !defined(__STRICT_ANSI__) -#define va_copy(dest, src) __builtin_va_copy(dest, src) -#endif - -/* Hack required to make standard headers work, at least on Ubuntu */ -#ifndef __GNUC_VA_LIST -#define __GNUC_VA_LIST 1 -#endif -typedef __builtin_va_list __gnuc_va_list; - -#endif /* __STDARG_H */ diff --git a/Makefile b/Makefile index 81f939e175..f1086b43d5 100644 --- a/Makefile +++ b/Makefile @@ -188,10 +188,12 @@ check-license: .PHONY: go/lint go/lint: + touch $(OUT_BPF) $(GO_ENV) $(CGO_ENV) golangci-lint run .PHONY: go/lint-fix go/lint-fix: + touch $(OUT_BPF) $(GO_ENV) $(CGO_ENV) golangci-lint run --fix .PHONY: bpf/lint-fix diff --git a/bpf/Makefile b/bpf/Makefile index 1c36353418..fadcaeddfc 100644 --- a/bpf/Makefile +++ b/bpf/Makefile @@ -43,9 +43,7 @@ OUT_BPF := $(OUT_BPF_DIR)/cpu.bpf.o BPF_BUNDLE := $(OUT_DIR)/parca-agent.bpf.tar.gz # input: -BPF_HEADERS := ../3rdparty/include LIBBPF_HEADERS := $(OUT_DIR)/libbpf/$(ARCH)/usr/include -LIBBPF_OBJ := $(OUT_DIR)/libbpf/$(ARCH)/libbpf.a VMLINUX := cpu/vmlinux.h BPF_SRC := cpu/cpu.bpf.c @@ -60,7 +58,7 @@ $(BPF_BUNDLE): $(BPF_SRC) $(LIBBPF_HEADERS)/bpf $(BPF_HEADERS) mkdir -p $(bpf_bundle_dir) cp $$(find $^ -type f) $(bpf_bundle_dir) -$(OUT_BPF): $(BPF_SRC) $(LIBBPF_HEADERS) $(LIBBPF_OBJ) $(BPF_HEADERS) | $(OUT_DIR) +$(OUT_BPF): $(BPF_SRC) $(LIBBPF_HEADERS) $(BPF_HEADERS) | $(OUT_DIR) mkdir -p $(OUT_BPF_DIR) $(CMD_CC) -S \ -D__BPF_TRACING__ \ diff --git a/pkg/profiler/cpu/bpf_metrics.go b/pkg/profiler/cpu/bpf_metrics.go index 02afebecd7..b6c3ed67ab 100644 --- a/pkg/profiler/cpu/bpf_metrics.go +++ b/pkg/profiler/cpu/bpf_metrics.go @@ -17,7 +17,6 @@ package cpu import ( "bufio" "bytes" - _ "embed" "fmt" "io" "os"