-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform_linux.go
executable file
·72 lines (65 loc) · 1.38 KB
/
platform_linux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// dcc - dependency-driven C/C++ compiler front end
//
// Copyright © A.Newman 2015.
//
// This source code is released under version 2 of the GNU Public License.
// See the file LICENSE for details.
//
package main
import (
"fmt"
"runtime"
)
var lib32 = []string{
"/usr/local/lib",
"/usr/lib32",
"/usr/lib/gcc/x86_64-linux-gnu/8",
"/usr/lib",
"/lib",
}
var lib64 = []string{
"/usr/local/lib64",
"/usr/lib64",
"/lib64",
"/usr/lib/x86_64-linux-gnu",
"/lib/x86_64-linux-gnu",
"/usr/local/lib",
"/usr/lib",
"/lib",
}
func linuxDefaultLibraryPaths() []string {
if runtime.GOARCH == "amd64" {
return lib64
}
return lib32
}
func linuxSelectTarget(p *Platform, target string) error {
switch target {
case "-m32":
p.LibraryPaths = lib32
return nil
case "-m64":
p.LibraryPaths = lib64
return nil
default:
return fmt.Errorf("%s: unhandled target", target)
}
}
var platform = Platform{
DefaultCC: "cc",
DefaultCXX: "c++",
ObjectFileSuffix: ".o",
DynamicLibPrefix: "lib",
DynamicLibSuffix: ".so",
PluginPrefix: "lib",
PluginSuffix: ".so",
StaticLibPrefix: "lib",
StaticLibSuffix: ".a",
DefaultExecutable: "a.out",
LibraryPaths: linuxDefaultLibraryPaths(),
CreateLibrary: ElfCreateLibrary,
CreateDLL: ElfCreateDLL,
CreatePlugin: ElfCreateDLL,
SelectTarget: linuxSelectTarget,
IsRoot: UnixIsRoot,
}