mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-28 16:21:04 -05:00
musl
This commit is contained in:
parent
0fc46338c0
commit
14f218a60b
3 changed files with 94 additions and 3 deletions
39
build.rs
39
build.rs
|
@ -231,6 +231,40 @@ fn build_v8(is_asan: bool) {
|
|||
}
|
||||
}
|
||||
|
||||
if std::env::var("CARGO_CFG_TARGET_ENV").map_or(false, |e| e == "musl") {
|
||||
let toolchain = build_musl_cross_make();
|
||||
|
||||
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
let manifest_dir = Path::new(&manifest_dir).join("toolchain");
|
||||
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||
|
||||
gn_args.push("use_custom_libcxx=false".to_string());
|
||||
gn_args.push("is_clang=false".to_string());
|
||||
gn_args.push("treat_warnings_as_errors=false".to_string());
|
||||
gn_args.push("line_tables_only=false".to_string());
|
||||
gn_args.push(format!("use_gold=false"));
|
||||
gn_args.push(format!("use_sysroot=false"));
|
||||
gn_args.push(format!("use_lld=false"));
|
||||
gn_args.push("v8_static_library=true".to_string());
|
||||
gn_args.push("clang_use_chrome_plugins=false".to_string());
|
||||
gn_args.push(format!(
|
||||
"custom_toolchain=\"{}:{}\"",
|
||||
manifest_dir.display(),
|
||||
arch
|
||||
));
|
||||
|
||||
let target = std::env::var("TARGET").unwrap();
|
||||
env::set_var("TOOLCHAIN", toolchain.join("bin").display().to_string());
|
||||
env::set_var(
|
||||
format!("CC_{}", target.replace("-", "_")),
|
||||
format!(
|
||||
"{}/bin/{}-cc",
|
||||
toolchain.display(),
|
||||
target.replace("-unknown-", "-")
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(p) = env::var_os("SCCACHE") {
|
||||
cc_wrapper(&mut gn_args, Path::new(&p));
|
||||
} else if let Ok(p) = which("sccache") {
|
||||
|
@ -417,10 +451,11 @@ fn static_lib_name(suffix: &str) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
fn build_musl_cross_make() {
|
||||
fn build_musl_cross_make() -> PathBuf {
|
||||
let toolchain_dir = build_dir().join("musl-cross-make");
|
||||
if toolchain_dir.exists() {
|
||||
println!("musl-cross-make toolchain already exists, skipping build");
|
||||
return toolchain_dir;
|
||||
}
|
||||
|
||||
std::fs::copy("config.mak", "musl-cross-make/config.mak").unwrap();
|
||||
|
@ -439,6 +474,8 @@ fn build_musl_cross_make() {
|
|||
.arg(format!("OUTPUT={}", toolchain_dir.display()))
|
||||
.status()
|
||||
.unwrap();
|
||||
|
||||
toolchain_dir
|
||||
}
|
||||
|
||||
fn static_lib_url() -> String {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
MUSL_VER = 1.1.24
|
||||
GCC_VER = 9.2.0
|
||||
MUSL_VER = 1.2.4
|
||||
GCC_VER = 11.2.0
|
||||
|
||||
GCC_CONFIG += --enable-default-pie
|
||||
|
||||
|
|
54
toolchain/BUILD.gn
Normal file
54
toolchain/BUILD.gn
Normal file
|
@ -0,0 +1,54 @@
|
|||
import("//build/config/sysroot.gni")
|
||||
import("//build/toolchain/gcc_toolchain.gni")
|
||||
|
||||
template("cross_toolchain") {
|
||||
gcc_toolchain(target_name) {
|
||||
assert(defined(invoker.toolprefix), "missing toolprefix")
|
||||
|
||||
toolchain = getenv("TOOLCHAIN")
|
||||
toolprefix = "${toolchain}/${invoker.toolprefix}"
|
||||
|
||||
cc = "${toolprefix}-gcc"
|
||||
cxx = "${toolprefix}-g++"
|
||||
ld = cxx
|
||||
|
||||
ar = "${toolprefix}-ar"
|
||||
readelf = "${toolprefix}-readelf"
|
||||
nm = "${toolprefix}-nm"
|
||||
|
||||
extra_ldflags = "-static"
|
||||
|
||||
toolchain_args = {
|
||||
forward_variables_from(invoker.toolchain_args, "*")
|
||||
use_remoteexec = false
|
||||
is_clang = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cross_toolchain("aarch64") {
|
||||
toolprefix = "aarch64-linux-musl"
|
||||
|
||||
toolchain_args = {
|
||||
current_cpu = "arm64"
|
||||
current_os = "linux"
|
||||
}
|
||||
}
|
||||
|
||||
cross_toolchain("armv7") {
|
||||
toolprefix = "armv7-linux-musleabihf"
|
||||
|
||||
toolchain_args = {
|
||||
current_cpu = "arm"
|
||||
current_os = "linux"
|
||||
}
|
||||
}
|
||||
|
||||
cross_toolchain("x86_64") {
|
||||
toolprefix = "x86_64-linux-musl"
|
||||
|
||||
toolchain_args = {
|
||||
current_cpu = "x64"
|
||||
current_os = "linux"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue