diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-11-17 11:20:17 -0800 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-11-17 11:42:22 -0800 |
| commit | d1a88510856c352db84d1b8ffa252c0a9ce30dec (patch) | |
| tree | b76c193cb11f94d1ae7532409e12d2255b43ee41 /sys | |
| parent | 7d395878aa6d662c1880c5b2a7ab76378cc96b7f (diff) | |
sys/targest: introduce target.BuildOS
We can't cross-compile native binaries from just any OS to any other.
For most OSes we can do only native compilation.
Some can only be compiled from linux.
To date we avoided this problem completely (mostly assumed linux build OS).
Make this notion of what can build what explicit.
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/targets/targets.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/targets/targets.go b/sys/targets/targets.go index 54b2b36fc..88d2c7277 100644 --- a/sys/targets/targets.go +++ b/sys/targets/targets.go @@ -4,6 +4,7 @@ package targets import ( + "fmt" "os" "os/exec" "runtime" @@ -32,6 +33,10 @@ type Target struct { } type osCommon struct { + // What OS can build native binaries for this OS. + // If not set, defaults to itself (i.e. native build). + // Later we can extend this to be a list, but so far we don't have more than one OS. + BuildOS string // Does the OS use syscall numbers (e.g. Linux) or has interface based on functions (e.g. fuchsia). SyscallNumbers bool // E.g. "__NR_" or "SYS_". @@ -288,6 +293,7 @@ var oses = map[string]osCommon{ CPP: "ecpp", }, "fuchsia": { + BuildOS: "linux", SyscallNumbers: false, ExecutorUsesShmem: false, ExecutorUsesForkServer: false, @@ -303,6 +309,7 @@ var oses = map[string]osCommon{ CPP: "cpp", }, "akaros": { + BuildOS: "linux", SyscallNumbers: true, SyscallPrefix: "SYS_", ExecutorUsesShmem: false, @@ -354,6 +361,17 @@ func initTarget(target *Target, OS, arch string) { if target.CCompiler == "" { target.CCompiler = target.CCompilerPrefix + "gcc" } + if target.BuildOS == "" { + target.BuildOS = OS + } + if OS == "test" { + target.BuildOS = "linux" + } + if runtime.GOOS != target.BuildOS { + // Spoil native binaries if they are not usable, so that nobody tries to use them later. + target.CCompiler = fmt.Sprintf("cant-build-%v-on-%v", target.OS, runtime.GOOS) + target.CPP = target.CCompiler + } } func checkStaticBuild(target *Target) { |
