Skip to content

Commit

Permalink
Delete more code
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Dec 16, 2023
1 parent 9a39793 commit 2942895
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
8 changes: 7 additions & 1 deletion go/tools/builders/compilepkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,13 @@ func compileArchive(
// Pack .o files into the archive. These may come from cgo generated code,
// cgo dependencies (cdeps), or assembly.
if len(objFiles) > 0 {
if err := appendFiles(goenv, outPath, objFiles...); err != nil {
// Append files to the archive, using abs to work around long path
// issues on Windows.
// TODO(jayconrod): copy cmd/internal/archive and use that instead of
// shelling out to cmd/pack.
args := goenv.goTool("pack", "r", abs(outPath))
args = append(args, objFiles...)
if err := goenv.runCommand(args); err != nil {
return err
}
}
Expand Down
25 changes: 0 additions & 25 deletions go/tools/builders/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,3 @@ const (
)

var zeroBytes = []byte("0 ")

func appendFiles(goenv *env, archive string, files ...string) error {
archive = abs(archive) // required for long filenames on Windows.

// Create an empty archive if one doesn't already exist.
// In Go 1.16, 'go tool pack r' reports an error if the archive doesn't exist.
// 'go tool pack c' copies export data in addition to creating the archive,
// so we don't want to use that directly.
_, err := os.Stat(archive)
if err != nil && !os.IsNotExist(err) {
return err
}
if os.IsNotExist(err) {
if err := os.WriteFile(archive, []byte(arHeader), 0666); err != nil {
return err
}
}

// Append files to the archive.
// TODO(jayconrod): copy cmd/internal/archive and use that instead of
// shelling out to cmd/pack.
args := goenv.goTool("pack", "r", archive)
args = append(args, files...)
return goenv.runCommand(args)
}

0 comments on commit 2942895

Please sign in to comment.