Source file src/cmd/link/internal/ld/execarchive.go

     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  // +build !wasm,!windows
     7  
     8  package ld
     9  
    10  import (
    11  	exec "internal/execabs"
    12  	"os"
    13  	"path/filepath"
    14  	"syscall"
    15  )
    16  
    17  const syscallExecSupported = true
    18  
    19  // execArchive invokes the archiver tool with syscall.Exec(), with
    20  // the expectation that this is the last thing that takes place
    21  // in the linking operation.
    22  func (ctxt *Link) execArchive(argv []string) {
    23  	var err error
    24  	argv0 := argv[0]
    25  	if filepath.Base(argv0) == argv0 {
    26  		argv0, err = exec.LookPath(argv0)
    27  		if err != nil {
    28  			Exitf("cannot find %s: %v", argv[0], err)
    29  		}
    30  	}
    31  	if ctxt.Debugvlog != 0 {
    32  		ctxt.Logf("invoking archiver with syscall.Exec()\n")
    33  	}
    34  	err = syscall.Exec(argv0, argv, os.Environ())
    35  	if err != nil {
    36  		Exitf("running %s failed: %v", argv[0], err)
    37  	}
    38  }
    39  

View as plain text