sluongng / nogo-analyzer

A collection of common static analyzers (linters) that can be used with Bazel's rules_go
Apache License 2.0
31 stars 10 forks source link

staticcheck: Support for Go 1.22 #43

Closed ewhauser closed 6 months ago

ewhauser commented 6 months ago

When switching to Go 1.22, I get the following errors compiling nogo on MacOS:

ERROR: /Users/ewhauser/working/cadencerpm/monorepo/go/BUILD.bazel:8:5: GoLink go/nogo_actual_/nogo_actual [for tool] failed: (Exit 1): sandbox-exec failed: error execut11:42:38 [727/1906]
  (cd /private/var/tmp/_bazel_ewhauser/c1fee43d9f70be2c9377b78115996411/sandbox/darwin-sandbox/11292/execroot/__main__ && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=14.2 \
    CGO_ENABLED=1 \
    DEVELOPER_DIR=/Applications/XCode.app/Contents/Developer \
    GOARCH=arm64 \
    GOEXPERIMENT=nocoverageredesign \
    GOOS=darwin \
    GOPATH='' \
    GOROOT=bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/external/io_bazel_rules_go/stdlib_ \
    GOROOT_FINAL=GOROOT \
    GOTOOLCHAIN=local \
    PATH=external/local_config_apple_cc:/bin:/usr/bin \
    RELATIVE_AST_PATH=true \
    SDKROOT=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk \
    TMPDIR=/var/folders/rl/v9dqv4mx1jsgwx81qjy74scc0000gn/T/ \
    XCODE_VERSION_OVERRIDE=15.2.0.15C500b \
    ZERO_AR_DATE=1 \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_ewhauser/c1fee43d9f70be2c9377b78115996411/sandbox/darwin-sandbox/11292/sandbox.sb /var/tmp/_bazel_ewhauser/install/c235141d88c168b049a19
1acefbb1f54/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_ewhauser/c1fee43d9f70be2c9377b78115996411/sandbox/darwin-sandbox/11292/stats.out' bazel-out/da
rwin_arm64-opt-exec-ST-1a88b5d644a4/bin/external/go_sdk/builder_reset/builder '-param=bazel-out/darwin_arm64-opt-exec-ST-1a88b5d644a4/bin/go/nogo_actual_/nogo_actual-0.params' -- -extld e
xternal/local_config_apple_cc/cc_wrapper.sh '-buildid=redacted' -s -w -extldflags '-Wl,-oso_prefix,__BAZEL_EXECUTION_ROOT__/ -headerpad_max_install_names -no-canonical-prefixes -target ar
m64-apple-macosx14.2 -fobjc-link-runtime -dead_strip -framework Foundation -Wl,-no_warn_duplicate_libraries')
runtime/cgo(__TEXT/__text): relocation target pthread_sigmask not defined
runtime/cgo(__TEXT/__text): relocation target pthread_self not defined
runtime/cgo(__TEXT/__text): relocation target pthread_get_stacksize_np not defined
runtime/cgo(__TEXT/__text): relocation target pthread_attr_init not defined
runtime/cgo(__TEXT/__text): relocation target pthread_attr_setstacksize not defined
runtime/cgo(__TEXT/__text): relocation target free not defined
runtime/cgo(__TEXT/__text): relocation target __stderrp not defined
runtime/cgo(__TEXT/__text): relocation target strerror not defined
runtime/cgo(__TEXT/__text): relocation target fprintf not defined
runtime/cgo(__TEXT/__text): relocation target abort not defined
runtime/cgo(__TEXT/__text): relocation target pthread_create not defined
runtime/cgo(__TEXT/__text): relocation target nanosleep not defined
runtime/cgo(__TEXT/__text): relocation target pthread_detach not defined
runtime/cgo(__TEXT/__text): relocation target pthread_mutex_lock not defined
runtime/cgo(__TEXT/__text): relocation target pthread_cond_wait not defined
runtime/cgo(__TEXT/__text): relocation target pthread_key_create not defined
runtime/cgo(__TEXT/__text): relocation target pthread_mutex_unlock not defined
runtime/cgo(__TEXT/__text): relocation target __stderrp not defined
runtime/cgo(__TEXT/__text): relocation target fprintf not defined

Removing staticcheck(ANALYZERS) from my nogo dependencies solves the issue.

ewhauser commented 6 months ago

This also appears to be affecting Gazelle: https://github.com/bazelbuild/bazel-gazelle/issues/1793

sluongng commented 6 months ago

This is not a problem with staticcheck afaik. It's a problem with Uber Zig toolchain. https://github.com/uber/hermetic_cc_toolchain/issues/171

In https://github.com/buildbuddy-io/buildbuddy we are using staticcheck with nogo and 1.22 without any issue.