bazel-contrib / bazel-contrib/rules_go
Cross-package asm #include error
- Dominant language
- Go
- Stars
- 1.5k
- Forks
- 762
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 12
Description
### What version of rules_go are you using?
We are using `v0.40.1`. (cf. [MRE](https://github.com/eliottness/bzl-asm-cross-package-include-mre))
### What version of gazelle are you using?
We are using `v0.30.0`. (cf. [MRE](https://github.com/eliottness/bzl-asm-cross-package-include-mre))
### What version of Bazel are you using?
```
$ bazel version
Bazelisk version: development
Build label: 6.3.0
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Jul 24 17:26:34 2023 (1690219594)
Build timestamp: 1690219594
Build timestamp as int: 1690219594
```
### Does this issue reproduce with the latest releases of all the above?
Yes it does.
### What operating system and processor architecture are you using?
OSX 13 latest on arm64 and some GNU/Linux on x64.
### What did you do?
Here is the [MRE](https://github.com/eliottness/bzl-asm-cross-package-include-mre) that we have done. To create this I only used the README from rules_go.
The only command needed to run after cloning the repo is `bazel build //:main`.
### What did you expect to see?
I would expect the project to compile when running `bazel build //:main` because running `env CGO_ENABLED=0 go build -a` works.
### What did you see instead?
Full errors logs here:
```
❯ bazel build //:main
INFO: Analyzed target //:main (25 packages loaded, 285 targets configured).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_eliott.bouhana/102698d60e14ef29c8a302f064528c7e/external/com_github_ebitengine_purego/internal/fakecgo/BUILD.bazel:3:11: GoCompilePkg external/com_github_ebitengine_purego/internal/fakecgo/fakecgo.a failed: (Exit 1): builder failed: error executing command (from target @com_github_ebitengine_purego//internal/fakecgo:fakecgo) bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/go_sdk/builder_reset/builder compilepkg -sdk external/go_sdk -installsuffix darwin_arm64 -src ... (remaining 59 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/com_github_ebitengine_purego/internal/fakecgo/asm_arm64.s:7: #include: open /var/folders/fn/j3_08pb94p9_hyz4myff84br0000gq/T/abi/abi_arm64.h: no such file or directory
compilepkg: error running subcommand external/go_sdk/pkg/tool/darwin_arm64/asm: exit status 1
Target //:main failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.580s, Critical Path: 0.21s
INFO: 3 processes: 3 internal.
FAILED: Build did NOT complete successfully
ERROR: Build failed. Not running target
```
### Preliminary diagnostic
The error happens when compiling [this file](https://github.com/ebitengine/purego/blob/main/internal/fakecgo/asm_arm64.s) or its [amd64 counter-part](https://github.com/ebitengine/purego/blob/main/internal/fakecgo/asm_amd64.s) which has the following line:
```asm
#include "../abi/abi_arm64.h"
```
This line references a file from another package in the same module but because the sandbox is building things package by package, other packages of the same module are not in the same place when compilation takes place. Note for the debugging that the package is only built when cgo is disabled.
Don't hesitate to ask me for more logs or some tests. Thanks for you help 🙇
cc @Hellzy , ebitengine/purego#144
Contributor guide
Research direction
Start with the linked minimal reproduction and run `bazel build //:main` using the reported rules_go, Gazelle, and Bazel versions. Inspect `internal/fakecgo/asm_arm64.s` and `asm_amd64.s`, especially their cross-package header includes, and compare the cgo-disabled build path. Done means the reproduction builds successfully under Bazel on the affected platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100