mirror of
https://github.com/rust-lang/rust
synced 2024-10-14 12:33:57 +00:00
Replace libbacktrace with a submodule
While we're at it update the `backtrace` crate from crates.io. It turns out that the submodule's configure script has gotten a lot more finnicky as of late so also switch over to using the `cc` crate manually which allows to avoid some hacks around the configure script as well
This commit is contained in:
parent
1402a106bd
commit
7c14a54bc8
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -53,3 +53,6 @@
|
|||
[submodule "src/tools/lld"]
|
||||
path = src/tools/lld
|
||||
url = https://github.com/rust-lang/lld.git
|
||||
[submodule "src/libbacktrace"]
|
||||
path = src/libbacktrace
|
||||
url = https://github.com/rust-lang-nursery/libbacktrace
|
||||
|
|
|
@ -105,7 +105,7 @@ name = "backtrace"
|
|||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"backtrace-sys 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -114,11 +114,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "backtrace-sys"
|
||||
version = "0.1.16"
|
||||
version = "0.1.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2513,6 +2514,7 @@ dependencies = [
|
|||
"alloc_jemalloc 0.0.0",
|
||||
"alloc_system 0.0.0",
|
||||
"build_helper 0.1.0",
|
||||
"cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"compiler_builtins 0.0.0",
|
||||
"core 0.0.0",
|
||||
"libc 0.0.0",
|
||||
|
@ -3051,7 +3053,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum assert_cli 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5da59dbd8df54562665b925b427221ceda9b771408cb8a6cbd2125d3b001330b"
|
||||
"checksum atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "af80143d6f7608d746df1520709e5d141c96f240b0e62b0aa41bdfb53374d9d4"
|
||||
"checksum backtrace 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe525f66f42d207968308ee86bc2dd60aa5fab535b22e616323a173d097d8e"
|
||||
"checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661"
|
||||
"checksum backtrace-sys 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5fd343a2466c4603f76f38de264bc0526cffc7fa38ba52fb9f13237eccc1ced2"
|
||||
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
|
||||
"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
|
||||
"checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf"
|
||||
|
|
1
src/libbacktrace
Submodule
1
src/libbacktrace
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit f4d02bbdbf8a2c5a31f0801dfef597a86caad9e3
|
|
@ -39,6 +39,7 @@ rustc_msan = { path = "../librustc_msan" }
|
|||
rustc_tsan = { path = "../librustc_tsan" }
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
||||
build_helper = { path = "../build_helper" }
|
||||
|
||||
[features]
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
#![deny(warnings)]
|
||||
|
||||
extern crate build_helper;
|
||||
extern crate cc;
|
||||
|
||||
use build_helper::native_lib_boilerplate;
|
||||
use std::env;
|
||||
use std::process::Command;
|
||||
use build_helper::{run, native_lib_boilerplate};
|
||||
use std::fs::File;
|
||||
|
||||
fn main() {
|
||||
let target = env::var("TARGET").expect("TARGET was not set");
|
||||
let host = env::var("HOST").expect("HOST was not set");
|
||||
if cfg!(feature = "backtrace") &&
|
||||
!target.contains("cloudabi") &&
|
||||
!target.contains("emscripten") &&
|
||||
|
@ -26,7 +26,7 @@ fn main() {
|
|||
!target.contains("msvc") &&
|
||||
!target.contains("wasm32")
|
||||
{
|
||||
let _ = build_libbacktrace(&host, &target);
|
||||
let _ = build_libbacktrace(&target);
|
||||
}
|
||||
|
||||
if target.contains("linux") {
|
||||
|
@ -84,26 +84,55 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
fn build_libbacktrace(host: &str, target: &str) -> Result<(), ()> {
|
||||
let native = native_lib_boilerplate("libbacktrace", "libbacktrace", "backtrace", ".libs")?;
|
||||
let cflags = env::var("CFLAGS").unwrap_or_default() + " -fvisibility=hidden -O2";
|
||||
fn build_libbacktrace(target: &str) -> Result<(), ()> {
|
||||
let native = native_lib_boilerplate("libbacktrace", "libbacktrace", "backtrace", "")?;
|
||||
|
||||
run(Command::new("sh")
|
||||
.current_dir(&native.out_dir)
|
||||
.arg(native.src_dir.join("configure").to_str().unwrap()
|
||||
.replace("C:\\", "/c/")
|
||||
.replace("\\", "/"))
|
||||
.arg("--with-pic")
|
||||
.arg("--disable-multilib")
|
||||
.arg("--disable-shared")
|
||||
.arg("--disable-host-shared")
|
||||
.arg(format!("--host={}", build_helper::gnu_target(target)))
|
||||
.arg(format!("--build={}", build_helper::gnu_target(host)))
|
||||
.env("CFLAGS", cflags));
|
||||
let mut build = cc::Build::new();
|
||||
build
|
||||
.flag("-fvisibility=hidden")
|
||||
.include("../libbacktrace")
|
||||
.include(&native.out_dir)
|
||||
.out_dir(&native.out_dir)
|
||||
.warnings(false)
|
||||
.file("../libbacktrace/alloc.c")
|
||||
.file("../libbacktrace/backtrace.c")
|
||||
.file("../libbacktrace/dwarf.c")
|
||||
.file("../libbacktrace/fileline.c")
|
||||
.file("../libbacktrace/posix.c")
|
||||
.file("../libbacktrace/read.c")
|
||||
.file("../libbacktrace/sort.c")
|
||||
.file("../libbacktrace/state.c");
|
||||
|
||||
run(Command::new(build_helper::make(host))
|
||||
.current_dir(&native.out_dir)
|
||||
.arg(format!("INCDIR={}", native.src_dir.display()))
|
||||
.arg("-j").arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")));
|
||||
if target.contains("darwin") {
|
||||
build.file("../libbacktrace/macho.c");
|
||||
} else if target.contains("windows") {
|
||||
build.file("../libbacktrace/pecoff.c");
|
||||
} else {
|
||||
build.file("../libbacktrace/elf.c");
|
||||
|
||||
if target.contains("64") {
|
||||
build.define("BACKTRACE_ELF_SIZE", "64");
|
||||
} else {
|
||||
build.define("BACKTRACE_ELF_SIZE", "32");
|
||||
}
|
||||
}
|
||||
|
||||
File::create(native.out_dir.join("backtrace-supported.h")).unwrap();
|
||||
build.define("BACKTRACE_SUPPORTED", "1");
|
||||
build.define("BACKTRACE_USES_MALLOC", "1");
|
||||
build.define("BACKTRACE_SUPPORTS_THREADS", "0");
|
||||
build.define("BACKTRACE_SUPPORTS_DATA", "0");
|
||||
|
||||
File::create(native.out_dir.join("config.h")).unwrap();
|
||||
if !target.contains("apple-ios") &&
|
||||
!target.contains("solaris") &&
|
||||
!target.contains("redox") &&
|
||||
!target.contains("android") {
|
||||
build.define("HAVE_DL_ITERATE_PHDR", "1");
|
||||
}
|
||||
build.define("_GNU_SOURCE", "1");
|
||||
build.define("_LARGE_FILES", "1");
|
||||
|
||||
build.compile("backtrace");
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@
|
|||
Crate("parking_lot"),
|
||||
Crate("parking_lot_core"),
|
||||
Crate("polonius-engine"),
|
||||
Crate("pkg-config"),
|
||||
Crate("quick-error"),
|
||||
Crate("rand"),
|
||||
Crate("redox_syscall"),
|
||||
|
|
Loading…
Reference in a new issue