Skip to content

Commit

Permalink
asm: Pass package path with -p
Browse files Browse the repository at this point in the history
This is required to produce linkable objects as of Go 1.19.
  • Loading branch information
fmeum committed Jul 7, 2022
1 parent df02d01 commit 2b5152a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions go/tools/builders/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ func asm(args []string) error {
}

// Build source with the assembler.
return asmFile(goenv, source, asmFlags, outPath)
// Note: As of Go 1.19, this would require a valid package path to work.
// But since this functionality is only used by the deprecated action API,
// we won't fix this.
return asmFile(goenv, source, "", asmFlags, outPath)
}

// buildSymabisFile generates a file from assembly files that is consumed
Expand Down Expand Up @@ -137,9 +140,12 @@ func buildSymabisFile(goenv *env, sFiles, hFiles []fileInfo, asmhdr string) (str
return symabisName, err
}

func asmFile(goenv *env, srcPath string, asmFlags []string, outPath string) error {
func asmFile(goenv *env, srcPath, packagePath string, asmFlags []string, outPath string) error {
args := goenv.goTool("asm")
args = append(args, asmFlags...)
if packagePath != "" {
args = append(args, "-p", packagePath)
}
args = append(args, "-trimpath", ".")
args = append(args, "-o", outPath)
args = append(args, "--", srcPath)
Expand Down
2 changes: 1 addition & 1 deletion go/tools/builders/compilepkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ func compileArchive(
}
for i, sSrc := range srcs.sSrcs {
obj := filepath.Join(workDir, fmt.Sprintf("s%d.o", i))
if err := asmFile(goenv, sSrc.filename, asmFlags, obj); err != nil {
if err := asmFile(goenv, sSrc.filename, packagePath, asmFlags, obj); err != nil {
return err
}
objFiles = append(objFiles, obj)
Expand Down

0 comments on commit 2b5152a

Please sign in to comment.