//! ensure that they're always in place if needed.
use std::env;
+use std::ffi::OsString;
use std::fs::{self, File};
use std::io::{Read, Write};
use std::path::Path;
drop(fs::remove_dir_all(&out_dir));
}
+ let _folder = build.fold_output(|| "llvm");
println!("Building LLVM for {}", target);
let _time = util::timeit();
t!(fs::create_dir_all(&out_dir));
cfg.define("LLVM_USE_CRT_DEBUG", "MT");
cfg.define("LLVM_USE_CRT_RELEASE", "MT");
cfg.define("LLVM_USE_CRT_RELWITHDEBINFO", "MT");
+ cfg.static_crt(true);
}
if target.starts_with("i686") {
.define("LLVM_TABLEGEN", &host);
}
- // MSVC handles compiler business itself
- if !target.contains("msvc") {
- if let Some(ref ccache) = build.config.ccache {
+ let sanitize_cc = |cc: &Path| {
+ if target.contains("msvc") {
+ OsString::from(cc.to_str().unwrap().replace("\\", "/"))
+ } else {
+ cc.as_os_str().to_owned()
+ }
+ };
+
+ let configure_compilers = |cfg: &mut cmake::Config| {
+ // MSVC with CMake uses msbuild by default which doesn't respect these
+ // vars that we'd otherwise configure. In that case we just skip this
+ // entirely.
+ if target.contains("msvc") && !build.config.ninja {
+ return
+ }
+
+ let cc = build.cc(target);
+ let cxx = build.cxx(target);
+
+ // Handle msvc + ninja + ccache specially (this is what the bots use)
+ if target.contains("msvc") &&
+ build.config.ninja &&
+ build.config.ccache.is_some() {
+ let mut cc = env::current_exe().expect("failed to get cwd");
+ cc.set_file_name("sccache-plus-cl.exe");
+
+ cfg.define("CMAKE_C_COMPILER", sanitize_cc(&cc))
+ .define("CMAKE_CXX_COMPILER", sanitize_cc(&cc));
+ cfg.env("SCCACHE_PATH",
+ build.config.ccache.as_ref().unwrap())
+ .env("SCCACHE_TARGET", target);
+
+ // If ccache is configured we inform the build a little differently hwo
+ // to invoke ccache while also invoking our compilers.
+ } else if let Some(ref ccache) = build.config.ccache {
cfg.define("CMAKE_C_COMPILER", ccache)
- .define("CMAKE_C_COMPILER_ARG1", build.cc(target))
+ .define("CMAKE_C_COMPILER_ARG1", sanitize_cc(cc))
.define("CMAKE_CXX_COMPILER", ccache)
- .define("CMAKE_CXX_COMPILER_ARG1", build.cxx(target));
+ .define("CMAKE_CXX_COMPILER_ARG1", sanitize_cc(cxx));
} else {
- cfg.define("CMAKE_C_COMPILER", build.cc(target))
- .define("CMAKE_CXX_COMPILER", build.cxx(target));
+ cfg.define("CMAKE_C_COMPILER", sanitize_cc(cc))
+ .define("CMAKE_CXX_COMPILER", sanitize_cc(cxx));
}
- cfg.build_arg("-j").build_arg(build.jobs().to_string());
+ cfg.build_arg("-j").build_arg(build.jobs().to_string());
cfg.define("CMAKE_C_FLAGS", build.cflags(target).join(" "));
cfg.define("CMAKE_CXX_FLAGS", build.cflags(target).join(" "));
- }
+ };
+
+ configure_compilers(&mut cfg);
if env::var_os("SCCACHE_ERROR_LOG").is_some() {
- cfg.env("RUST_LOG", "sccache=info");
+ cfg.env("RUST_LOG", "sccache=warn");
}
// FIXME: we don't actually need to build all LLVM tools and all LLVM
return
}
+ let _folder = build.fold_output(|| "build_test_helpers");
println!("Building test helpers");
t!(fs::create_dir_all(&dst));
let mut cfg = gcc::Config::new();
configure.arg("no-ssl3");
let os = match target {
+ "aarch64-linux-android" => "linux-aarch64",
"aarch64-unknown-linux-gnu" => "linux-aarch64",
+ "arm-linux-androideabi" => "android",
"arm-unknown-linux-gnueabi" => "linux-armv4",
"arm-unknown-linux-gnueabihf" => "linux-armv4",
+ "armv7-linux-androideabi" => "android-armv7",
"armv7-unknown-linux-gnueabihf" => "linux-armv4",
"i686-apple-darwin" => "darwin-i386-cc",
+ "i686-linux-android" => "android-x86",
"i686-unknown-freebsd" => "BSD-x86-elf",
"i686-unknown-linux-gnu" => "linux-elf",
"i686-unknown-linux-musl" => "linux-elf",
"powerpc64le-unknown-linux-gnu" => "linux-ppc64le",
"s390x-unknown-linux-gnu" => "linux64-s390x",
"x86_64-apple-darwin" => "darwin64-x86_64-cc",
+ "x86_64-linux-android" => "linux-x86_64",
"x86_64-unknown-freebsd" => "BSD-x86_64",
"x86_64-unknown-linux-gnu" => "linux-x86_64",
"x86_64-unknown-linux-musl" => "linux-x86_64",
for flag in build.cflags(target) {
configure.arg(flag);
}
+ // There is no specific os target for android aarch64 or x86_64,
+ // so we need to pass some extra cflags
+ if target == "aarch64-linux-android" || target == "x86_64-linux-android" {
+ configure.arg("-mandroid");
+ configure.arg("-fomit-frame-pointer");
+ }
+ // Make PIE binaries
+ // Non-PIE linker support was removed in Lollipop
+ // https://source.android.com/security/enhancements/enhancements50
+ if target == "i686-linux-android" {
+ configure.arg("no-asm");
+ }
configure.current_dir(&obj);
println!("Configuring openssl for {}", target);
build.run_quiet(&mut configure);