mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 05:29:10 +02:00

This commit allows building YJIT and ZJIT simultaneously, a "combo build". Previously, `./configure --enable-yjit --enable-zjit` failed. At runtime, though, only one of the two can be enabled at a time. Add a root Cargo workspace that contains both the yjit and zjit crate. The common Rust build integration mechanisms are factored out into defs/jit.mk. Combo YJIT+ZJIT dev builds are supported; if either JIT uses `--enable-*=dev`, both of them are built in dev mode. The combo build requires Cargo, but building one JIT at a time with only rustc in release build remains supported.
25 lines
963 B
Rust
25 lines
963 B
Rust
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
|
|
println!("cargo:rustc-link-search=native={ruby_build_dir}");
|
|
println!("cargo:rustc-link-lib=static:-bundle=miniruby");
|
|
|
|
// 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}");
|
|
}
|
|
}
|
|
}
|
|
}
|