blob: 4ee3d65b33062e8bedc16739e202a2f1e63101fe (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// This build script is only used for `make zjit-test` for building
// the test binary; ruby builds don't use this.
fn main() {
use std::env;
// option_env! automatically registers a rerun-if-env-changed
if let Some(ruby_build_dir) = option_env!("RUBY_BUILD_DIR") {
// Link against libminiruby.a
println!("cargo:rustc-link-search=native={ruby_build_dir}");
println!("cargo:rustc-link-lib=static:-bundle=miniruby");
// Re-link when libminiruby.a changes
println!("cargo:rerun-if-changed={ruby_build_dir}/libminiruby.a");
// System libraries that libminiruby needs. Has to be
// ordered after -lminiruby above.
let link_flags = env::var("RUBY_LD_FLAGS").unwrap();
let mut split_iter = link_flags.split(" ");
while let Some(token) = split_iter.next() {
if token == "-framework" {
if let Some(framework) = split_iter.next() {
println!("cargo:rustc-link-lib=framework={framework}");
}
} else if let Some(lib_name) = token.strip_prefix("-l") {
println!("cargo:rustc-link-lib={lib_name}");
}
}
// When doing a combo build, there is a copy of ZJIT symbols in libruby.a
// and Cargo builds another copy for the test binary. Tell the linker to
// not complaint about duplicate symbols. For some reason, darwin doesn't
// suffer the same issue.
if env::var("TARGET").unwrap().contains("linux") {
println!("cargo:rustc-link-arg=-Wl,--allow-multiple-definition");
}
}
}
|