Commit 165de83
Update go_library build rule to compile assembly files individually (#330)
Currently, when compiling a Go package with Assembly files, the
`go_library` build rule invokes `go tool asm` once on all Assembly files
in the package. However, this caused errors that look like the below
when multiple files declare symbols with the same name.
```
asm: pkg/linux_amd64/github.com/apache/arrow-go/v18/internal/utils/min_max_sse4_amd64.s:8: symbol LCDATA1 redeclared
asm: pkg/linux_amd64/github.com/apache/arrow-go/v18/internal/utils/min_max_sse4_amd64.s:242: symbol LCDATA2 redeclared
asm: pkg/linux_amd64/github.com/apache/arrow-go/v18/internal/utils/min_max_sse4_amd64.s:460: symbol LCDATA3 redeclared
asm: pkg/linux_amd64/github.com/apache/arrow-go/v18/internal/utils/min_max_sse4_amd64.s:691: symbol LCDATA4 redeclared
asm: pkg/linux_amd64/github.com/apache/arrow-go/v18/internal/utils/min_max_sse4_amd64.s:847: symbol LCDATA5 redeclared
asm: assembly failed
```
This is despite the `<>` suffix [1] after the offending symbol name,
which should've been enough to make the symbol visible in that file
only [2] from the perspective of `go tool asm`.
When building this same package without Please (i.e. just with
`go build`), we don't run into these errors - it looks like this is
because the Go tool invokes `go tool asm` on each Assembly
individually [3, 4]. So this PR updates the `go_library` build def's
behaviour to more closely match the behaviour in the Go tool.
I was able to reproduce these errors by adding the new unit tests in
this PR. The errors were fixed by my updates to the `go_library` build
def.
[1] https://github.com/apache/arrow-go/blob/main/internal/utils/min_max_sse4_amd64.s#L8
[2] https://go.dev/doc/asm#:~:text=Adding%20%3C%3E%20to%20the%20name%2C%20as%20in%20foo%3C%3E(SB)%2C%20makes%20the%20name%20visible%20only%20in%20the%20current%20source%20file%2C%20like%20a%20top%2Dlevel%20static%20declaration%20in%20a%20C%20file
[3] https://cs.opensource.google/go/go/+/master:src/cmd/go/internal/work/gccgo.go;l=212
[4] https://cs.opensource.google/go/go/+/master:src/cmd/go/internal/work/gc.go;l=397
Co-authored-by: Chris Novakovic <chris@chrisn.me.uk>1 parent f6d219e commit 165de83
File tree
7 files changed
+45
-6
lines changed- build_defs
- test/asm/lib
- golib
7 files changed
+45
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | | - | |
| 427 | + | |
428 | 428 | | |
429 | | - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
430 | 443 | | |
431 | 444 | | |
432 | 445 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments