-
Notifications
You must be signed in to change notification settings - Fork 215
/
build.rs
67 lines (52 loc) · 1.91 KB
/
build.rs
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
// SPDX-License-Identifier: Apache-2.0
use std::process::Command;
fn main() {
#[cfg(feature = "llvm")]
{
Command::new("make")
.args(["-C", "stdlib"])
.output()
.expect("Could not build stdlib");
// compile our linker
let cxxflags = Command::new("llvm-config")
.args(["--cxxflags"])
.output()
.expect("could not execute llvm-config");
let cxxflags = String::from_utf8(cxxflags.stdout).unwrap();
let mut build = cc::Build::new();
build.file("src/linker/linker.cpp").cpp(true);
if !cfg!(target_os = "windows") {
build.flag("-Wno-unused-parameter");
}
for flag in cxxflags.split_whitespace() {
build.flag(flag);
}
build.compile("liblinker.a");
// add the llvm linker
let libdir = Command::new("llvm-config")
.args(["--libdir"])
.output()
.unwrap();
let libdir = String::from_utf8(libdir.stdout).unwrap();
println!("cargo:libdir={libdir}");
for lib in &["lldELF", "lldCommon", "lldWasm"] {
println!("cargo:rustc-link-lib=static={lib}");
}
// And all the symbols we're not using, needed by Windows and debug builds
println!("cargo:rustc-link-lib=static=lldMachO");
}
let output = Command::new("git")
.args(["describe", "--tags", "--always"])
.output()
.unwrap();
let solang_version = if output.stdout.is_empty() {
format!("v{}", env!("CARGO_PKG_VERSION"))
} else {
String::from_utf8(output.stdout).unwrap()
};
println!("cargo:rustc-env=SOLANG_VERSION={solang_version}");
// Make sure we have an 8MiB stack on Windows. Windows defaults to a 1MB
// stack, which is not big enough for debug builds
#[cfg(windows)]
println!("cargo:rustc-link-arg=/STACK:8388608");
}