Closed sqwishy closed 6 years ago
It seems to me that the included files, const.s
, macro.s
, are treated as asm sources (rather than headers?) due to their file extension. So then I think go.asm
/emit_asm
isn't invoked with all the files necessary for bazel to compile the target.
This diff produces behaviour that allows the build to succeed; although I'm sure it's being gratuitous.
diff --git a/go/private/actions/archive.bzl b/go/private/actions/archive.bzl
index 6721c93..c9306ea 100644
--- a/go/private/actions/archive.bzl
+++ b/go/private/actions/archive.bzl
@@ -45,7 +45,8 @@ def emit_archive(go, source=None):
extra_objects = []
for src in split.asm:
- extra_objects.append(go.asm(go, source=src, hdrs=split.headers))
+ headers = split.headers + split.asm
+ extra_objects.append(go.asm(go, source=src, hdrs=headers))
direct = [get_archive(dep) for dep in source.deps]
runfiles = source.runfiles
Perhaps this is an issue with the generated BUILD file? As I understand, that is produced by gazelle, which is a separate program?
Looked into this a bit. I think a fix will have two parts:
-I
flags) for all assembly files.For the record, I think including .s files is a bad idea. rules_go should support this because go build supports it, but I'm pretty sure the resulting binaries will end up with multiple copies of symbols defined in the included files.
The diff you posted earlier actually fixes this (no extra munging include directories; that's already done for headers).
I'm unable to build a project that uses https://github.com/o1egl/paseto because bazel fails to build one of that project's dependencies. Below is the build output and a diagnosis concerning the sandbox that bazel creates. Later there is a WORKSPACE and source file that might make a minimal reproducible example.
The build output (right after bazel clean):
The chacha20 project has a go asm file, chacha_amd64.s that includes a sibling file, that include fails, but only when run in the bazel sandbox.
If I run the command that bazel build shows me, the compilation is successful -- because it says to cd into a directory that is not the sandbox. But bazel runs the compilation inside of the sandbox directory. The build is successful when run under
BAZEL_CACHE/3da33cce868be8ce123b5a603f89d38e/execroot/__main__
but notBAZEL_CACHE/3da33cce868be8ce123b5a603f89d38e/bazel-sandbox/8310765647797671785/execroot/__main__
When the build does work, the include is found at
external/com_github_aead_chacha20/chacha/const.s
.From outside the sandbox, at
BAZEL_CACHE/3da33cce868be8ce123b5a603f89d38e/execroot/__main__
From inside the sandbox at
BAZEL_CACHE/3da33cce868be8ce123b5a603f89d38e/bazel-sandbox/8310765647797671785/execroot/__main__
After adding symlinks in the sandbox for the two includes,
const.s
andmacro.s
, the build is successful.The following is the WORKSPACE and a go source file that imports a package that depends on the one that can't be built.
~/go/src/meme/WORKSPACE
:~/go/src/meme/main.go
: