From ede3a17daa48f5a93998bed225afc73a28805505 Mon Sep 17 00:00:00 2001 From: Peter Ebden Date: Fri, 9 Feb 2024 14:35:46 +0000 Subject: [PATCH] Support assembly correctly for Go 1.22 (#227) * Specify package path for gensymabis * Support Go 1.22 in go_module * Version --- ChangeLog | 4 ++++ VERSION | 2 +- build_defs/go.build_defs | 2 +- tools/please_go/install/install.go | 2 +- tools/please_go/install/toolchain/toolchain.go | 5 ++++- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c7f6d52f..4bd31021 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Version 1.16.4 +-------------- + * Support Go 1.22 for third-party packages containing assembly + Version 1.16.3 -------------- * Use version 1.10.2 of please_go tool diff --git a/VERSION b/VERSION index c807441c..a2320736 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.3 +1.16.4 diff --git a/build_defs/go.build_defs b/build_defs/go.build_defs index a47131ba..6827ee3b 100644 --- a/build_defs/go.build_defs +++ b/build_defs/go.build_defs @@ -364,7 +364,7 @@ def go_library(name:str, srcs:list, resources:list=[], asm_srcs:list=None, hdrs: }, outs = [name + '.abi'], building_description = 'Creating ABI...', - cmd = f'eval `"$TOOL" env` && mkdir include && touch include/go_asm.h && "$TOOL" tool asm -trimpath "$TMP_DIR" -I include -I $GOROOT/pkg/include -D GOOS_{CONFIG.OS} -D GOARCH_{CONFIG.ARCH} -gensymabis -o "$OUT" $SRCS_ASM', + cmd = f'eval `"$TOOL" env` && mkdir include && touch include/go_asm.h && "$TOOL" tool asm -trimpath "$TMP_DIR" -I include -I $GOROOT/pkg/include -D GOOS_{CONFIG.OS} -D GOARCH_{CONFIG.ARCH} -gensymabis -p {package_path} -o "$OUT" $SRCS_ASM', env= { "GOOS": CONFIG.OS, "GOARCH": CONFIG.ARCH, diff --git a/tools/please_go/install/install.go b/tools/please_go/install/install.go index c1a767ef..ac6cd862 100644 --- a/tools/please_go/install/install.go +++ b/tools/please_go/install/install.go @@ -397,7 +397,7 @@ func (install *PleaseGoInstall) compilePackage(target string, pkg *build.Package asmFiles := prefixPaths(pkg.SFiles, pkg.Dir) if len(asmFiles) > 0 { - asmH, symabis, err := install.tc.Symabis(pkg.Dir, workDir, asmFiles) + asmH, symabis, err := install.tc.Symabis(importPath, pkg.Dir, workDir, asmFiles) if err != nil { return err } diff --git a/tools/please_go/install/toolchain/toolchain.go b/tools/please_go/install/toolchain/toolchain.go index f0d4413d..d109585a 100644 --- a/tools/please_go/install/toolchain/toolchain.go +++ b/tools/please_go/install/toolchain/toolchain.go @@ -130,10 +130,13 @@ func (tc *Toolchain) Link(archive, out, importcfg string, ldFlags []string) erro } // Symabis will generate the asm header as well as the abi symbol file for the provided asm files. -func (tc *Toolchain) Symabis(sourceDir, objectDir string, asmFiles []string) (string, string, error) { +func (tc *Toolchain) Symabis(importpath, sourceDir, objectDir string, asmFiles []string) (string, string, error) { asmH := fmt.Sprintf("%s/go_asm.h", objectDir) symabis := fmt.Sprintf("%s/symabis", objectDir) + if importpath != "" { + importpath = fmt.Sprintf("-p %s", importpath) + } // the gc Toolchain does this if err := tc.Exec.Run("touch %s", asmH); err != nil { return "", "", err