From: Ximin Luo Date: Mon, 20 May 2019 03:09:27 +0000 (-0700) Subject: Use system compiler-rt from libclang-common-*-dev X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=cc46dafa33c994b7ea631a7992fcc65e516e2f88;p=rustc.git Use system compiler-rt from libclang-common-*-dev --- diff --git a/debian/README.source b/debian/README.source index e0e6dc6fc2..63a8d33ded 100644 --- a/debian/README.source +++ b/debian/README.source @@ -17,13 +17,6 @@ The upstream source package embeds many external libraries. We make a great effort to remove them and use system versions where possible, but there are a few more remaining: - * compiler-rt from https://github.com/rust-lang/compiler-rt - -> system-wide compiler-rt fails during linkage - - Bug reported upstream, still to be fixed, see: - - https://github.com/rust-lang/rust/issues/15054 - - https://github.com/rust-lang/rust/issues/15708 - * vendor/backtrace-sys, vendor/dlmalloc, vendor/walkdir These are small C libraries designed to be statically linked; their upstream diff --git a/debian/changelog b/debian/changelog index ce2147cecc..07afd64a7d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ rustc (1.34.2+dfsg1-1~exp2) UNRELEASED; urgency=medium * Fix doc build, add version 1 compat mode hack for mdBook 2. + * Use system compiler-rt from libclang-common-*-dev. -- Ximin Luo Sun, 19 May 2019 11:53:46 -0700 diff --git a/debian/control b/debian/control index 6d8338e786..35eb5c00a5 100644 --- a/debian/control +++ b/debian/control @@ -15,6 +15,7 @@ Build-Depends: debhelper (>= 9), llvm-8-dev:native, llvm-8-tools:native, libllvm8, + libclang-common-8-dev, autotools-dev, cmake (>= 3.0) | cmake3, # needed by some vendor crates diff --git a/debian/copyright b/debian/copyright index 9a93d00b69..bb196c92a6 100644 --- a/debian/copyright +++ b/debian/copyright @@ -24,21 +24,8 @@ Files-Excluded: src/tools/remote-test-server src/tools/rustfmt src/tools/miri -# Extraneous stuff from compiler-rt that's not needed by Rust - vendor/compiler_builtins/compiler-rt/cmake - vendor/compiler_builtins/compiler-rt/docs - vendor/compiler_builtins/compiler-rt/include - vendor/compiler_builtins/compiler-rt/lib/*san - vendor/compiler_builtins/compiler-rt/lib/fuzzer - vendor/compiler_builtins/compiler-rt/lib/interception - vendor/compiler_builtins/compiler-rt/lib/profile - vendor/compiler_builtins/compiler-rt/lib/sanitizer_common - vendor/compiler_builtins/compiler-rt/lib/scudo - vendor/compiler_builtins/compiler-rt/lib/xray - vendor/compiler_builtins/compiler-rt/test - vendor/compiler_builtins/compiler-rt/unittests - vendor/compiler_builtins/compiler-rt/www # Embedded C libraries + vendor/compiler_builtins/compiler-rt vendor/libz-sys/src/zlib* vendor/lzma-sys*/xz-* # Embedded binary blobs @@ -224,6 +211,8 @@ Copyright: 2016-2019 Jorge Aparicio License: MIT or Apache-2.0 Comment: see https://github.com/rust-lang-nursery/compiler-builtins +# TODO: below entries for compiler-rt can be removed on next source re-pack + Files: vendor/compiler_builtins/compiler-rt/* Copyright: 2009-2015 Howard Hinnant 2009-2015 The CompileRT Developers (see src/compiler-rt/CREDITS.TXT) diff --git a/debian/patches/d-fix-mips64el-bootstrap.patch b/debian/patches/d-fix-mips64el-bootstrap.patch index 3239d1a8ec..3b6347ee4e 100644 --- a/debian/patches/d-fix-mips64el-bootstrap.patch +++ b/debian/patches/d-fix-mips64el-bootstrap.patch @@ -1,7 +1,7 @@ Bug: https://github.com/rust-lang/rust/issues/52108 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py -@@ -620,6 +620,8 @@ +@@ -617,6 +617,8 @@ (os.pathsep + env["LIBRARY_PATH"]) \ if "LIBRARY_PATH" in env else "" env["RUSTFLAGS"] = "-Cdebuginfo=2 " diff --git a/debian/patches/d-use-system-compiler-rt.patch b/debian/patches/d-use-system-compiler-rt.patch new file mode 100644 index 0000000000..9cc0348d76 --- /dev/null +++ b/debian/patches/d-use-system-compiler-rt.patch @@ -0,0 +1,154 @@ +commit 484e4a2e83ca6cbfb96957996d57262792da0a30 +Author: Ximin Luo +Date: Sun May 19 19:15:20 2019 -0700 + + Use system compiler-rt from clang + +--- a/vendor/compiler_builtins/build.rs ++++ b/vendor/compiler_builtins/build.rs +@@ -68,6 +68,8 @@ + use std::collections::BTreeMap; + use std::env; + use std::path::Path; ++ use std::process::Command; ++ use std::str; + + struct Sources { + // SYMBOL -> PATH TO SOURCE +@@ -113,33 +115,6 @@ + let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap(); + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); + let target_vendor = env::var("CARGO_CFG_TARGET_VENDOR").unwrap(); +- let cfg = &mut cc::Build::new(); +- +- cfg.warnings(false); +- +- if target_env == "msvc" { +- // Don't pull in extra libraries on MSVC +- cfg.flag("/Zl"); +- +- // Emulate C99 and C++11's __func__ for MSVC prior to 2013 CTP +- cfg.define("__func__", Some("__FUNCTION__")); +- } else { +- // Turn off various features of gcc and such, mostly copying +- // compiler-rt's build system already +- cfg.flag("-fno-builtin"); +- cfg.flag("-fvisibility=hidden"); +- cfg.flag("-ffreestanding"); +- // Avoid the following warning appearing once **per file**: +- // clang: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7' [-Wignored-optimization-argument] +- // +- // Note that compiler-rt's build system also checks +- // +- // `check_cxx_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG)` +- // +- // in https://github.com/rust-lang/compiler-rt/blob/c8fbcb3/cmake/config-ix.cmake#L19. +- cfg.flag_if_supported("-fomit-frame-pointer"); +- cfg.define("VISIBILITY_HIDDEN", None); +- } + + let mut sources = Sources::new(); + sources.extend( +@@ -438,10 +413,23 @@ + let src_dir = root.join("compiler-rt/lib/builtins"); + for src in sources.map.values() { + let src = src_dir.join(src); +- cfg.file(&src); +- println!("cargo:rerun-if-changed={}", src.display()); + } + +- cfg.compile("libcompiler-rt.a"); ++ // rustc sets this during the build ++ let llvm_config = env::var("LLVM_CONFIG").expect("LLVM_CONFIG not set"); ++ let cmd = format!("ls -1d $({} --libdir)/clang/*/lib/linux", llvm_config); ++ let output = Command::new("sh") ++ .args(&["-ec", &cmd]) ++ .output() ++ .expect("failed to find clang lib dir"); ++ let status = output.status; ++ if !status.success() { ++ panic!(format!("failed to find clang lib dir: {:?}", status.code())); ++ } ++ for search_dir in str::from_utf8(&output.stdout).unwrap().lines() { ++ println!("cargo:rustc-link-search=native={}", search_dir); ++ } ++ let arch = llvm_target[0]; ++ println!("cargo:rustc-link-lib=static=clang_rt.builtins-{}", arch); + } + } +--- a/src/bootstrap/compile.rs ++++ b/src/bootstrap/compile.rs +@@ -164,6 +164,12 @@ + } else { + let features = builder.std_features(); + ++ // In Debian this is always available ++ let llvm_config = builder.ensure(native::Llvm { ++ target: builder.config.build, ++ emscripten: false, ++ }); ++ cargo.env("LLVM_CONFIG", llvm_config); + if compiler.stage != 0 && builder.config.sanitizers { + // This variable is used by the sanitizer runtime crates, e.g. + // rustc_lsan, to build the sanitizer runtime from C code +@@ -172,11 +178,7 @@ + // missing + // We also only build the runtimes when --enable-sanitizers (or its + // config.toml equivalent) is used +- let llvm_config = builder.ensure(native::Llvm { +- target: builder.config.build, +- emscripten: false, +- }); +- cargo.env("LLVM_CONFIG", llvm_config); ++ cargo.env("RUSTC_BUILD_SANITIZERS", "1"); + } + + cargo.arg("--features").arg(features) +--- a/src/librustc_asan/build.rs ++++ b/src/librustc_asan/build.rs +@@ -4,6 +4,9 @@ + use cmake::Config; + + fn main() { ++ if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) { ++ return; ++ } + if let Some(llvm_config) = env::var_os("LLVM_CONFIG") { + build_helper::restore_library_path(); + +--- a/src/librustc_lsan/build.rs ++++ b/src/librustc_lsan/build.rs +@@ -4,6 +4,9 @@ + use cmake::Config; + + fn main() { ++ if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) { ++ return; ++ } + if let Some(llvm_config) = env::var_os("LLVM_CONFIG") { + build_helper::restore_library_path(); + +--- a/src/librustc_msan/build.rs ++++ b/src/librustc_msan/build.rs +@@ -4,6 +4,9 @@ + use cmake::Config; + + fn main() { ++ if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) { ++ return; ++ } + if let Some(llvm_config) = env::var_os("LLVM_CONFIG") { + build_helper::restore_library_path(); + +--- a/src/librustc_tsan/build.rs ++++ b/src/librustc_tsan/build.rs +@@ -4,6 +4,9 @@ + use cmake::Config; + + fn main() { ++ if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) { ++ return; ++ } + if let Some(llvm_config) = env::var_os("LLVM_CONFIG") { + build_helper::restore_library_path(); + diff --git a/debian/patches/gcc-4.8-aarch64-ice.diff b/debian/patches/gcc-4.8-aarch64-ice.diff deleted file mode 100644 index aaa4d7b11f..0000000000 --- a/debian/patches/gcc-4.8-aarch64-ice.diff +++ /dev/null @@ -1,25 +0,0 @@ -Index: rustc/vendor/compiler_builtins/compiler-rt/lib/builtins/trunctfdf2.c -=================================================================== ---- rustc.orig/vendor/compiler_builtins/compiler-rt/lib/builtins/trunctfdf2.c -+++ rustc/vendor/compiler_builtins/compiler-rt/lib/builtins/trunctfdf2.c -@@ -7,6 +7,12 @@ - // - //===----------------------------------------------------------------------===// - -+#if defined(__aarch64__) && (__GNUC__ <= 4) && (__GNUC_MINOR__ <= 8) -+// work around https://launchpad.net/bugs/1667761 -+#pragma GCC push_options -+#pragma GCC optimize "O1" -+#endif -+ - #define QUAD_PRECISION - #include "fp_lib.h" - -@@ -20,3 +26,7 @@ COMPILER_RT_ABI double __trunctfdf2(long - } - - #endif -+#if defined(__aarch64__) && (__GNUC__ <= 4) && (__GNUC_MINOR__ <= 8) -+#pragma GCC pop_options -+#endif -+ diff --git a/debian/patches/series b/debian/patches/series index f0ae927aa9..f0ebf9895c 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -12,8 +12,6 @@ u-mips-fixes.diff # not forwarded, or forwarded but unlikely to be merged u-reproducible-dl-stage0.patch -gcc-4.8-aarch64-ice.diff - # Debian-specific patches, not suitable for upstream # Patches needed by debian/prune-unused-deps d-0000-ignore-removed-submodules.patch @@ -22,6 +20,7 @@ d-0002-pkg-config-no-special-snowflake.patch d-0003-mdbook-strip-embedded-libs.patch d-0004-mdbook-2-1-compat.patch # Other patches needed by the full Debian build +d-use-system-compiler-rt.patch d-ignore-error-detail-diff.patch d-disable-cargo-vendor.patch d-rust-gdb-paths diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides index 732a73a881..dda0650ff5 100644 --- a/debian/source/lintian-overrides +++ b/debian/source/lintian-overrides @@ -1 +1,3 @@ rustc source: source-is-missing src/stdsimd/crates/stdsimd-verify/arm-intrinsics.html line length is * characters (>*) +# TODO: can be removed on next source repack +rustc source: source-includes-file-in-files-excluded vendor/compiler_builtins/compiler-rt/*