github.com/bir3/gocompiler@v0.9.2202/src/cmd/link/internal/ld/execarchive.go (about) 1 // Copyright 2019 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build !wasm && !windows 6 7 package ld 8 9 import ( 10 "os" 11 "github.com/bir3/gocompiler/exec" 12 "path/filepath" 13 "syscall" 14 ) 15 16 const syscallExecSupported = true 17 18 // execArchive invokes the archiver tool with syscall.Exec(), with 19 // the expectation that this is the last thing that takes place 20 // in the linking operation. 21 func (ctxt *Link) execArchive(argv []string) { 22 var err error 23 argv0 := argv[0] 24 if filepath.Base(argv0) == argv0 { 25 argv0, err = exec.LookPath(argv0) 26 if err != nil { 27 Exitf("cannot find %s: %v", argv[0], err) 28 } 29 } 30 if ctxt.Debugvlog != 0 { 31 ctxt.Logf("invoking archiver with syscall.Exec()\n") 32 } 33 err = syscall.Exec(argv0, argv, os.Environ()) 34 if err != nil { 35 Exitf("running %s failed: %v", argv[0], err) 36 } 37 }