Skip to content

Commit cf432e9

Browse files
Remove asm -compiling-runtime flag for go 1.22+ compatible versions (Cherry-pick of #20554) (#20563)
When using go 1.22, trying to compile a go package using pants fails with: ``` 13:07:42.25 [INFO] Initialization options changed: reinitializing scheduler... 13:07:46.62 [INFO] Scheduler initialized. 13:07:51.89 [ERROR] Completed: Compile with Go - runtime/internal/syscall - runtime/internal/syscall failed (exit code 1). flag provided but not defined: -compiling-runtime usage: asm [options] file.s ... Flags: -D value predefined symbol with optional simple value -D=identifier=value; can be set multiple times -I value include directory; can be set multiple times -S print assembly and machine code -V print version and exit -d value enable debugging settings; try -d help -debug dump instructions as they are parsed -dynlink support references to Go symbols defined in other shared libraries -e no limit on number of errors reported -gensymabis write symbol ABI information to output file, don't assemble -linkshared generate code that will be linked against Go shared libraries -o string output file; default foo.o for /a/b/c/foo.s as first argument -p string set expected package import to path (default "<unlinkable>") -shared generate code that can be linked into a shared library -spectre list enable spectre mitigations in list (all, ret) -trimpath string remove prefix from recorded source file paths -v print debug output ``` This flag has been removed from version 1.22 - asm can now make the determination itself regarding whether or not we're compiling a `runtime` package, so there's no need to pass that flag anymore. See: https://cs.opensource.google/go/go/+/72946ae8674a295e7485982fe57c65c7142b2c14 Co-authored-by: Filip Nikolovski <[email protected]>
1 parent 795598e commit cf432e9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/python/pants/backend/go/util_rules/assembly.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,17 @@ def _asm_args(
8686
# See:
8787
# - https://github.com/golang/go/blob/245e95dfabd77f337373bf2d6bb47cd353ad8d74/src/cmd/go/internal/work/gc.go#L370-L372
8888
# - https://github.com/golang/go/blob/245e95dfabd77f337373bf2d6bb47cd353ad8d74/src/cmd/internal/objabi/path.go#L43-L67
89+
# From Go 1.22+ this flag has been removed, since we're already passing the package path, asm can make that determination,
90+
# and there's no need to pass the flag anymore.
91+
# See:
92+
# - https://cs.opensource.google/go/go/+/72946ae8674a295e7485982fe57c65c7142b2c14
8993
maybe_assembling_stdlib_runtime_args = (
9094
["-compiling-runtime"]
91-
if import_path in ("runtime", "reflect", "syscall", "internal/bytealg")
92-
or import_path.startswith("runtime/internal")
95+
if not goroot.is_compatible_version("1.22")
96+
and (
97+
import_path in ("runtime", "reflect", "syscall", "internal/bytealg")
98+
or import_path.startswith("runtime/internal")
99+
)
93100
else []
94101
)
95102

0 commit comments

Comments
 (0)