diff --git a/DEPS.bzl b/DEPS.bzl index 8d90901cc0a5..2ce5d455d508 100644 --- a/DEPS.bzl +++ b/DEPS.bzl @@ -5059,10 +5059,10 @@ def go_deps(): name = "com_github_jordanlewis_gcassert", build_file_proto_mode = "disable_global", importpath = "github.com/jordanlewis/gcassert", - sha256 = "4e6d2be78096ee4158d921af5d388f76bbf6d2638cee052ca628ba70da911704", - strip_prefix = "github.com/jordanlewis/gcassert@v0.0.0-20221027203946-81f097ad35a0", + sha256 = "3919384e0288d9ce93da816ef227aec2c61b978eb761bd45a7fded957f792dcf", + strip_prefix = "github.com/jordanlewis/gcassert@v0.0.0-20230505190637-fed79d91cd5f", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/jordanlewis/gcassert/com_github_jordanlewis_gcassert-v0.0.0-20221027203946-81f097ad35a0.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/jordanlewis/gcassert/com_github_jordanlewis_gcassert-v0.0.0-20230505190637-fed79d91cd5f.zip", ], ) go_repository( diff --git a/build/bazelutil/distdir_files.bzl b/build/bazelutil/distdir_files.bzl index be21e78ec216..83db5d868a20 100644 --- a/build/bazelutil/distdir_files.bzl +++ b/build/bazelutil/distdir_files.bzl @@ -655,7 +655,7 @@ DISTDIR_FILES = { "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/joho/godotenv/com_github_joho_godotenv-v1.3.0.zip": "acef5a394fbd1193f52d0d19690b0bfe82728d18dd3bf67730dc5031c22d563f", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/jonboulle/clockwork/com_github_jonboulle_clockwork-v0.1.0.zip": "930d355d1ced60a668bcbca6154bb5671120ba11a34119505d1c0677f7bbbf97", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/jordan-wright/email/com_github_jordan_wright_email-v4.0.1-0.20210109023952-943e75fe5223+incompatible.zip": "6d35fa83ea02cfacd0e1ba9c9061381b963215cef84c8bf83ad5944cb304c390", - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/jordanlewis/gcassert/com_github_jordanlewis_gcassert-v0.0.0-20221027203946-81f097ad35a0.zip": "4e6d2be78096ee4158d921af5d388f76bbf6d2638cee052ca628ba70da911704", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/jordanlewis/gcassert/com_github_jordanlewis_gcassert-v0.0.0-20230505190637-fed79d91cd5f.zip": "3919384e0288d9ce93da816ef227aec2c61b978eb761bd45a7fded957f792dcf", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/josharian/intern/com_github_josharian_intern-v1.0.0.zip": "5679bfd11c14adccdb45bd1a0f9cf4b445b95caeed6fb507ba96ecced11c248d", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/jpillora/backoff/com_github_jpillora_backoff-v1.0.0.zip": "f856692c725143c49b9cceabfbca8bc93d3dbde84a0aaa53fb26ed3774c220cc", "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/json-iterator/go/com_github_json_iterator_go-v1.1.12.zip": "d001ea57081afd0e378467c8f4a9b6a51259996bb8bb763f78107eaf12f99501", diff --git a/build/teamcity/cockroach/ci/tests/gcassert.sh b/build/teamcity/cockroach/ci/tests/gcassert.sh deleted file mode 100755 index 66589db130cf..000000000000 --- a/build/teamcity/cockroach/ci/tests/gcassert.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -dir="$(dirname $(dirname $(dirname $(dirname $(dirname "${0}")))))" - -source "$dir/teamcity-support.sh" # For $root -source "$dir/teamcity-bazel-support.sh" # For run_bazel - -tc_start_block "GcAssert" -run_bazel build/teamcity/cockroach/ci/tests/gcassert_impl.sh -tc_end_block "GcAssert" diff --git a/build/teamcity/cockroach/ci/tests/gcassert_impl.sh b/build/teamcity/cockroach/ci/tests/gcassert_impl.sh deleted file mode 100755 index 2834a2f77374..000000000000 --- a/build/teamcity/cockroach/ci/tests/gcassert_impl.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -set -xeuo pipefail - -bazel build @com_github_jordanlewis_gcassert//cmd/gcassert:gcassert --config=ci -bazel run //pkg/gen:code -GODIR=$(dirname $(bazel run @go_sdk//:bin/go --run_under=realpath)) -echo "##teamcity[testStarted name='GcAssert' captureStandardOutput='true']" -exit_status=0 -PATH=$GODIR:$PATH $(bazel info bazel-bin --config=ci)/external/com_github_jordanlewis_gcassert/cmd/gcassert/gcassert_/gcassert $(cat ./pkg/testutils/lint/gcassert_paths.txt | sed 's|^|./pkg/|') || exit_status=$? -if [ "$exit_status" -ne 0 ]; then - echo "##teamcity[testFailed name='GcAssert']" -fi -echo "##teamcity[testFinished name='GcAssert']" - diff --git a/build/teamcity/cockroach/ci/tests/lint_impl.sh b/build/teamcity/cockroach/ci/tests/lint_impl.sh index a07e659396cd..6356b38513c9 100755 --- a/build/teamcity/cockroach/ci/tests/lint_impl.sh +++ b/build/teamcity/cockroach/ci/tests/lint_impl.sh @@ -2,8 +2,14 @@ set -xeuo pipefail +# GCAssert requirements -- start +export PATH="$(dirname $(bazel run @go_sdk//:bin/go --run_under=realpath)):$PATH" +bazel run //pkg/gen:code +bazel run //pkg/cmd/generate-cgo:generate-cgo --run_under="cd $(bazel info workspace) && " +# GCAssert requirements -- end + bazel build //pkg/cmd/bazci --config=ci -XML_OUTPUT_FILE=/artifacts/test.xml GO_TEST_WRAP_TESTV=1 GO_TEST_WRAP=1 bazel \ +XML_OUTPUT_FILE=/artifacts/test.xml GO_TEST_WRAP_TESTV=1 GO_TEST_WRAP=1 CC=$(which gcc) CXX=$(which gcc) bazel \ run --config=ci --config=test //build/bazelutil:lint # The schema of the output test.xml will be slightly wrong -- ask `bazci` to fix # it up. diff --git a/go.mod b/go.mod index d8880bb89895..b6377c40f7e7 100644 --- a/go.mod +++ b/go.mod @@ -159,7 +159,7 @@ require ( github.com/jackc/pgx/v5 v5.3.1 github.com/jaegertracing/jaeger v1.18.1 github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible - github.com/jordanlewis/gcassert v0.0.0-20221027203946-81f097ad35a0 + github.com/jordanlewis/gcassert v0.0.0-20230505190637-fed79d91cd5f github.com/kevinburke/go-bindata v3.13.0+incompatible github.com/kisielk/errcheck v1.6.1-0.20210625163953-8ddee489636a github.com/kisielk/gotool v1.0.0 diff --git a/go.sum b/go.sum index 80710fcf57aa..d2cf6e95029c 100644 --- a/go.sum +++ b/go.sum @@ -1441,8 +1441,8 @@ github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqx github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible h1:jdpOPRN1zP63Td1hDQbZW73xKmzDvZHzVdNYxhnTMDA= github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible/go.mod h1:1c7szIrayyPPB/987hsnvNzLushdWf4o/79s3P08L8A= -github.com/jordanlewis/gcassert v0.0.0-20221027203946-81f097ad35a0 h1:y9VRjxb2hZlTElaaUH50QkZnPKrvQR5NhPza66vh+9w= -github.com/jordanlewis/gcassert v0.0.0-20221027203946-81f097ad35a0/go.mod h1:FsDIOYX6N9TFyHD602Yu/Zp04+KySTH00okDq+9IPqo= +github.com/jordanlewis/gcassert v0.0.0-20230505190637-fed79d91cd5f h1:GoV80Ggs5ZeF6uDv/lYDGJAv2Wz3Mp/brqRbjvEm6mI= +github.com/jordanlewis/gcassert v0.0.0-20230505190637-fed79d91cd5f/go.mod h1:FsDIOYX6N9TFyHD602Yu/Zp04+KySTH00okDq+9IPqo= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= diff --git a/pkg/cmd/generate-cgo/main.go b/pkg/cmd/generate-cgo/main.go index 35a40109cc4b..8c7aa7f43950 100644 --- a/pkg/cmd/generate-cgo/main.go +++ b/pkg/cmd/generate-cgo/main.go @@ -148,11 +148,19 @@ import "C" krbDir = filepath.Join(bazelBin, "c-deps/libkrb5_foreign") } } - cppFlags := fmt.Sprintf("-I%s", filepath.Join(jemallocDir, "include")) - ldFlags := fmt.Sprintf("-L%s -L%s", filepath.Join(jemallocDir, "lib"), filepath.Join(projDir, "lib")) + + srcToPersistentDirs := make(map[string]string, 3) + srcToPersistentDirs[jemallocDir] = filepath.Join(workspace, "bin", "c-deps", filepath.Base(jemallocDir)) + srcToPersistentDirs[projDir] = filepath.Join(workspace, "bin", "c-deps", filepath.Base(projDir)) + if krbDir != "" { + srcToPersistentDirs[krbDir] = filepath.Join(workspace, "bin", "c-deps", filepath.Base(krbDir)) + } + + cppFlags := fmt.Sprintf("-I%s", filepath.Join(srcToPersistentDirs[jemallocDir], "include")) + ldFlags := fmt.Sprintf("-L%s -L%s", filepath.Join(srcToPersistentDirs[jemallocDir], "lib"), filepath.Join(srcToPersistentDirs[projDir], "lib")) if krbDir != "" { - cppFlags += fmt.Sprintf(" -I%s", filepath.Join(krbDir, "include")) - ldFlags += fmt.Sprintf(" -L%s", filepath.Join(krbDir, "lib")) + cppFlags += fmt.Sprintf(" -I%s", filepath.Join(srcToPersistentDirs[krbDir], "include")) + ldFlags += fmt.Sprintf(" -L%s", filepath.Join(srcToPersistentDirs[krbDir], "lib")) } cgoPkgs := []string{ @@ -177,6 +185,33 @@ import "C" return err } } + + // Copy jemallocDir, projDir, and krbDir to a persistent location (//bin/c-deps). + if err := os.MkdirAll(filepath.Join(workspace, "bin", "c-deps"), 0755); err != nil { + return err + } + // Ensure that overwriting existing ones is possible to prevent permissions errors. + chmodCmd := exec.Command("chmod", "-R", "755", filepath.Join(workspace, "bin", "c-deps")) + var chmodOutBuf, chmodErrBuf strings.Builder + chmodCmd.Stderr = &chmodErrBuf + chmodCmd.Stdout = &chmodOutBuf + if err := chmodCmd.Run(); err != nil { + return errors.Wrapf(err, "Output: %s - %s", chmodOutBuf.String(), chmodErrBuf.String()) + } + for dirToCopy := range srcToPersistentDirs { + if dirToCopy != "" { + copyCmdArgs := []string{"-r", dirToCopy, filepath.Dir(srcToPersistentDirs[dirToCopy])} + logCommand("cp", copyCmdArgs...) + cmd := exec.Command("cp", copyCmdArgs...) + var outBuf, errBuf strings.Builder + cmd.Stdout = &outBuf + cmd.Stderr = &errBuf + cmd.Dir = workspace + if err := cmd.Run(); err != nil { + return errors.Wrapf(err, "Output: %s - %s", outBuf.String(), errBuf.String()) + } + } + } return nil } diff --git a/pkg/testutils/lint/lint_test.go b/pkg/testutils/lint/lint_test.go index 0706e4c8d003..03cf9227bb94 100644 --- a/pkg/testutils/lint/lint_test.go +++ b/pkg/testutils/lint/lint_test.go @@ -1430,7 +1430,7 @@ func TestLint(t *testing.T) { if pkgSpecified { skip.IgnoreLint(t, "PKG specified") } - ignore := `\.(pb(\.gw)?)|(\.[eo]g)\.go|/testdata/|^sql/parser/sql\.go$|(_)?generated(_test)?\.go$` + ignore := `zcgo*|\.(pb(\.gw)?)|(\.[eo]g)\.go|/testdata/|^sql/parser/sql\.go$|(_)?generated(_test)?\.go$` cmd, stderr, filter, err := dirCmd(pkgDir, "crlfmt", "-fast", "-ignore", ignore, "-tab", "2", ".") if err != nil { t.Fatal(err) @@ -2110,15 +2110,13 @@ func TestLint(t *testing.T) { } }) - if !bazel.BuiltWithBazel() { - var buf strings.Builder - if err := gcassert.GCAssert(&buf, gcassertPaths...); err != nil { - t.Fatal(err) - } - output := buf.String() - if len(output) > 0 { - t.Fatalf("failed gcassert:\n%s", output) - } + var buf strings.Builder + if err := gcassert.GCAssert(&buf, gcassertPaths...); err != nil { + t.Fatal(err) + } + output := buf.String() + if len(output) > 0 { + t.Fatalf("failed gcassert:\n%s", output) } })