aboutsummaryrefslogtreecommitdiffhomepage
path: root/linker-external.go
blob: 48e4d2ecd9d7265b056573aad35eae101469b0fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// +build !byollvm

package main

// This file provides a Link() function that always runs an external command. It
// is provided for when tinygo is built without linking to liblld.

import (
	"os"
	"os/exec"
)

// Link invokes a linker with the given name and arguments.
//
// This version always runs the linker as an external command.
func Link(linker string, flags ...string) error {
	if cmdNames, ok := commands[linker]; ok {
		return execCommand(cmdNames, flags...)
	}
	cmd := exec.Command(linker, flags...)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	return cmd.Run()
}