2015-11-19 17:20:12 -06:00
|
|
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2016-05-02 17:16:15 -05:00
|
|
|
//! Compilation of native dependencies like LLVM.
|
|
|
|
//!
|
|
|
|
//! Native projects like LLVM unfortunately aren't suited just yet for
|
2017-08-15 14:45:21 -05:00
|
|
|
//! compilation in build scripts that Cargo has. This is because the
|
2016-05-02 17:16:15 -05:00
|
|
|
//! compilation takes a *very* long time but also because we don't want to
|
|
|
|
//! compile LLVM 3 times as part of a normal bootstrap (we want it cached).
|
|
|
|
//!
|
|
|
|
//! LLVM and compiler-rt are essentially just wired up to everything else to
|
|
|
|
//! ensure that they're always in place if needed.
|
|
|
|
|
2017-03-20 16:29:14 -05:00
|
|
|
use std::env;
|
2017-02-25 11:53:46 -06:00
|
|
|
use std::ffi::OsString;
|
2016-10-07 11:43:26 -05:00
|
|
|
use std::fs::{self, File};
|
|
|
|
use std::io::{Read, Write};
|
2015-11-19 17:20:12 -06:00
|
|
|
use std::path::Path;
|
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
use build_helper::output;
|
|
|
|
use cmake;
|
2016-04-05 13:34:23 -05:00
|
|
|
use gcc;
|
2015-11-19 17:20:12 -06:00
|
|
|
|
2016-07-05 23:58:20 -05:00
|
|
|
use Build;
|
2017-01-31 15:27:51 -06:00
|
|
|
use util;
|
|
|
|
use build_helper::up_to_date;
|
2017-07-20 18:51:07 -05:00
|
|
|
use builder::{Builder, RunConfig, ShouldRun, Step};
|
2017-07-13 19:48:44 -05:00
|
|
|
use cache::Interned;
|
2015-11-19 17:20:12 -06:00
|
|
|
|
2017-07-13 19:48:44 -05:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
|
|
|
pub struct Llvm {
|
|
|
|
pub target: Interned<String>,
|
2017-07-04 20:41:43 -05:00
|
|
|
}
|
|
|
|
|
2017-07-13 19:48:44 -05:00
|
|
|
impl Step for Llvm {
|
2017-07-04 20:41:43 -05:00
|
|
|
type Output = ();
|
2017-07-05 07:41:27 -05:00
|
|
|
const ONLY_HOSTS: bool = true;
|
2017-07-04 20:41:43 -05:00
|
|
|
|
2017-07-18 19:03:38 -05:00
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
run.path("src/llvm")
|
2017-07-14 07:30:16 -05:00
|
|
|
}
|
|
|
|
|
2017-07-29 15:39:43 -05:00
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
run.builder.ensure(Llvm { target: run.target })
|
|
|
|
}
|
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
/// Compile LLVM for `target`.
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
let build = builder.build;
|
|
|
|
let target = self.target;
|
2017-06-18 09:00:10 -05:00
|
|
|
|
|
|
|
// If we're not compiling for LLVM bail out here.
|
|
|
|
if !build.config.llvm_enabled {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
// If we're using a custom LLVM bail out here, but we can only use a
|
|
|
|
// custom LLVM for the build triple.
|
2017-07-13 19:48:44 -05:00
|
|
|
if let Some(config) = build.config.target_config.get(&target) {
|
2017-07-04 20:41:43 -05:00
|
|
|
if let Some(ref s) = config.llvm_config {
|
|
|
|
return check_llvm_version(build, s);
|
|
|
|
}
|
2015-11-19 17:20:12 -06:00
|
|
|
}
|
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
let rebuild_trigger = build.src.join("src/rustllvm/llvm-rebuild-trigger");
|
|
|
|
let mut rebuild_trigger_contents = String::new();
|
|
|
|
t!(t!(File::open(&rebuild_trigger)).read_to_string(&mut rebuild_trigger_contents));
|
2017-03-03 08:18:44 -06:00
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
let out_dir = build.llvm_out(target);
|
|
|
|
let done_stamp = out_dir.join("llvm-finished-building");
|
|
|
|
if done_stamp.exists() {
|
|
|
|
let mut done_contents = String::new();
|
|
|
|
t!(t!(File::open(&done_stamp)).read_to_string(&mut done_contents));
|
2017-03-03 08:18:44 -06:00
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
// If LLVM was already built previously and contents of the rebuild-trigger file
|
|
|
|
// didn't change from the previous build, then no action is required.
|
|
|
|
if done_contents == rebuild_trigger_contents {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2015-11-19 17:20:12 -06:00
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
let _folder = build.fold_output(|| "llvm");
|
|
|
|
println!("Building LLVM for {}", target);
|
|
|
|
let _time = util::timeit();
|
|
|
|
t!(fs::create_dir_all(&out_dir));
|
2015-11-19 17:20:12 -06:00
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
// http://llvm.org/docs/CMake.html
|
|
|
|
let mut cfg = cmake::Config::new(build.src.join("src/llvm"));
|
|
|
|
if build.config.ninja {
|
|
|
|
cfg.generator("Ninja");
|
|
|
|
}
|
2016-11-10 10:30:06 -06:00
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
let profile = match (build.config.llvm_optimize, build.config.llvm_release_debuginfo) {
|
|
|
|
(false, _) => "Debug",
|
|
|
|
(true, false) => "Release",
|
|
|
|
(true, true) => "RelWithDebInfo",
|
|
|
|
};
|
2017-02-14 16:30:39 -06:00
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
// NOTE: remember to also update `config.toml.example` when changing the defaults!
|
|
|
|
let llvm_targets = match build.config.llvm_targets {
|
|
|
|
Some(ref s) => s,
|
|
|
|
None => "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc;NVPTX;Hexagon",
|
|
|
|
};
|
2015-11-19 17:20:12 -06:00
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
let llvm_exp_targets = match build.config.llvm_experimental_targets {
|
|
|
|
Some(ref s) => s,
|
|
|
|
None => "",
|
|
|
|
};
|
2017-03-05 09:11:11 -06:00
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
let assertions = if build.config.llvm_assertions {"ON"} else {"OFF"};
|
|
|
|
|
2017-07-13 19:48:44 -05:00
|
|
|
cfg.target(&target)
|
2017-07-04 20:41:43 -05:00
|
|
|
.host(&build.build)
|
|
|
|
.out_dir(&out_dir)
|
|
|
|
.profile(profile)
|
|
|
|
.define("LLVM_ENABLE_ASSERTIONS", assertions)
|
|
|
|
.define("LLVM_TARGETS_TO_BUILD", llvm_targets)
|
|
|
|
.define("LLVM_EXPERIMENTAL_TARGETS_TO_BUILD", llvm_exp_targets)
|
|
|
|
.define("LLVM_INCLUDE_EXAMPLES", "OFF")
|
|
|
|
.define("LLVM_INCLUDE_TESTS", "OFF")
|
|
|
|
.define("LLVM_INCLUDE_DOCS", "OFF")
|
|
|
|
.define("LLVM_ENABLE_ZLIB", "OFF")
|
|
|
|
.define("WITH_POLLY", "OFF")
|
|
|
|
.define("LLVM_ENABLE_TERMINFO", "OFF")
|
|
|
|
.define("LLVM_ENABLE_LIBEDIT", "OFF")
|
|
|
|
.define("LLVM_PARALLEL_COMPILE_JOBS", build.jobs().to_string())
|
|
|
|
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
|
|
|
|
.define("LLVM_DEFAULT_TARGET_TRIPLE", target);
|
2015-11-19 17:20:12 -06:00
|
|
|
|
2017-08-03 17:42:05 -05:00
|
|
|
|
|
|
|
// This setting makes the LLVM tools link to the dynamic LLVM library,
|
|
|
|
// which saves both memory during parallel links and overall disk space
|
|
|
|
// for the tools. We don't distribute any of those tools, so this is
|
2017-08-04 02:13:11 -05:00
|
|
|
// just a local concern. However, it doesn't work well everywhere.
|
|
|
|
if target.contains("linux-gnu") || target.contains("apple-darwin") {
|
2017-08-03 17:42:05 -05:00
|
|
|
cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
|
|
|
|
}
|
|
|
|
|
2017-02-25 11:53:46 -06:00
|
|
|
if target.contains("msvc") {
|
2017-07-04 20:41:43 -05:00
|
|
|
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);
|
2017-02-25 11:53:46 -06:00
|
|
|
}
|
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
if target.starts_with("i686") {
|
|
|
|
cfg.define("LLVM_BUILD_32_BITS", "ON");
|
2017-02-25 11:53:46 -06:00
|
|
|
}
|
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
if let Some(num_linkers) = build.config.llvm_link_jobs {
|
|
|
|
if num_linkers > 0 {
|
|
|
|
cfg.define("LLVM_PARALLEL_LINK_JOBS", num_linkers.to_string());
|
|
|
|
}
|
2015-11-19 17:20:12 -06:00
|
|
|
}
|
2016-03-29 23:51:00 -05:00
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
// http://llvm.org/docs/HowToCrossCompileLLVM.html
|
|
|
|
if target != build.build {
|
2017-07-13 19:48:44 -05:00
|
|
|
builder.ensure(Llvm { target: build.build });
|
2017-07-04 20:41:43 -05:00
|
|
|
// FIXME: if the llvm root for the build triple is overridden then we
|
|
|
|
// should use llvm-tblgen from there, also should verify that it
|
|
|
|
// actually exists most of the time in normal installs of LLVM.
|
2017-07-13 19:48:44 -05:00
|
|
|
let host = build.llvm_out(build.build).join("bin/llvm-tblgen");
|
2017-07-04 20:41:43 -05:00
|
|
|
cfg.define("CMAKE_CROSSCOMPILING", "True")
|
|
|
|
.define("LLVM_TABLEGEN", &host);
|
2017-07-28 14:17:52 -05:00
|
|
|
|
|
|
|
if target.contains("netbsd") {
|
|
|
|
cfg.define("CMAKE_SYSTEM_NAME", "NetBSD");
|
|
|
|
} else if target.contains("freebsd") {
|
|
|
|
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg.define("LLVM_NATIVE_BUILD", build.llvm_out(build.build).join("build"));
|
2017-07-04 20:41:43 -05:00
|
|
|
}
|
2017-02-25 11:53:46 -06:00
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
let sanitize_cc = |cc: &Path| {
|
|
|
|
if target.contains("msvc") {
|
|
|
|
OsString::from(cc.to_str().unwrap().replace("\\", "/"))
|
|
|
|
} else {
|
|
|
|
cc.as_os_str().to_owned()
|
|
|
|
}
|
|
|
|
};
|
2015-11-19 17:20:12 -06:00
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
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).unwrap();
|
|
|
|
|
|
|
|
// 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", sanitize_cc(cc))
|
|
|
|
.define("CMAKE_CXX_COMPILER", ccache)
|
|
|
|
.define("CMAKE_CXX_COMPILER_ARG1", sanitize_cc(cxx));
|
|
|
|
} else {
|
|
|
|
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.define("CMAKE_C_FLAGS", build.cflags(target).join(" "));
|
|
|
|
cfg.define("CMAKE_CXX_FLAGS", build.cflags(target).join(" "));
|
|
|
|
};
|
2017-03-20 16:29:14 -05:00
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
configure_compilers(&mut cfg);
|
2016-06-29 15:45:18 -05:00
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
if env::var_os("SCCACHE_ERROR_LOG").is_some() {
|
|
|
|
cfg.env("RUST_LOG", "sccache=warn");
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: we don't actually need to build all LLVM tools and all LLVM
|
|
|
|
// libraries here, e.g. we just want a few components and a few
|
|
|
|
// tools. Figure out how to filter them down and only build the right
|
|
|
|
// tools and libs on all platforms.
|
|
|
|
cfg.build();
|
|
|
|
|
|
|
|
t!(t!(File::create(&done_stamp)).write_all(rebuild_trigger_contents.as_bytes()));
|
|
|
|
}
|
2015-11-19 17:20:12 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn check_llvm_version(build: &Build, llvm_config: &Path) {
|
|
|
|
if !build.config.llvm_version_check {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut cmd = Command::new(llvm_config);
|
|
|
|
let version = output(cmd.arg("--version"));
|
|
|
|
if version.starts_with("3.5") || version.starts_with("3.6") ||
|
|
|
|
version.starts_with("3.7") {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
panic!("\n\nbad LLVM version: {}, need >=3.5\n\n", version)
|
|
|
|
}
|
|
|
|
|
2017-07-13 19:48:44 -05:00
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
|
|
pub struct TestHelpers {
|
|
|
|
pub target: Interned<String>,
|
2017-07-04 20:41:43 -05:00
|
|
|
}
|
|
|
|
|
2017-07-13 19:48:44 -05:00
|
|
|
impl Step for TestHelpers {
|
2017-07-04 20:41:43 -05:00
|
|
|
type Output = ();
|
|
|
|
|
2017-07-18 19:03:38 -05:00
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
run.path("src/rt/rust_test_helpers.c")
|
2017-07-05 07:41:27 -05:00
|
|
|
}
|
|
|
|
|
2017-07-20 18:51:07 -05:00
|
|
|
fn make_run(run: RunConfig) {
|
|
|
|
run.builder.ensure(TestHelpers { target: run.target })
|
2017-07-05 07:41:27 -05:00
|
|
|
}
|
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
/// Compiles the `rust_test_helpers.c` library which we used in various
|
|
|
|
/// `run-pass` test suites for ABI testing.
|
|
|
|
fn run(self, builder: &Builder) {
|
|
|
|
let build = builder.build;
|
|
|
|
let target = self.target;
|
|
|
|
let dst = build.test_helpers_out(target);
|
|
|
|
let src = build.src.join("src/rt/rust_test_helpers.c");
|
|
|
|
if up_to_date(&src, &dst.join("librust_test_helpers.a")) {
|
|
|
|
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();
|
|
|
|
|
|
|
|
// We may have found various cross-compilers a little differently due to our
|
|
|
|
// extra configuration, so inform gcc of these compilers. Note, though, that
|
|
|
|
// on MSVC we still need gcc's detection of env vars (ugh).
|
|
|
|
if !target.contains("msvc") {
|
|
|
|
if let Some(ar) = build.ar(target) {
|
|
|
|
cfg.archiver(ar);
|
|
|
|
}
|
|
|
|
cfg.compiler(build.cc(target));
|
2016-11-16 14:31:19 -06:00
|
|
|
}
|
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
cfg.cargo_metadata(false)
|
|
|
|
.out_dir(&dst)
|
2017-07-13 19:48:44 -05:00
|
|
|
.target(&target)
|
2017-07-04 20:41:43 -05:00
|
|
|
.host(&build.build)
|
|
|
|
.opt_level(0)
|
|
|
|
.debug(false)
|
|
|
|
.file(build.src.join("src/rt/rust_test_helpers.c"))
|
|
|
|
.compile("librust_test_helpers.a");
|
|
|
|
}
|
2016-04-05 13:34:23 -05:00
|
|
|
}
|
2017-07-04 20:41:43 -05:00
|
|
|
|
2017-02-15 17:57:06 -06:00
|
|
|
const OPENSSL_VERS: &'static str = "1.0.2k";
|
|
|
|
const OPENSSL_SHA256: &'static str =
|
|
|
|
"6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0";
|
|
|
|
|
2017-07-20 17:41:26 -05:00
|
|
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
2017-07-13 19:48:44 -05:00
|
|
|
pub struct Openssl {
|
|
|
|
pub target: Interned<String>,
|
2017-07-04 20:41:43 -05:00
|
|
|
}
|
2017-02-15 17:57:06 -06:00
|
|
|
|
2017-07-13 19:48:44 -05:00
|
|
|
impl Step for Openssl {
|
2017-07-04 20:41:43 -05:00
|
|
|
type Output = ();
|
|
|
|
|
2017-07-18 19:03:38 -05:00
|
|
|
fn should_run(run: ShouldRun) -> ShouldRun {
|
|
|
|
run.never()
|
2017-07-05 07:41:27 -05:00
|
|
|
}
|
|
|
|
|
2017-07-04 20:41:43 -05:00
|
|
|
fn run(self, builder: &Builder) {
|
2017-07-05 11:46:41 -05:00
|
|
|
let build = builder.build;
|
2017-07-04 20:41:43 -05:00
|
|
|
let target = self.target;
|
|
|
|
let out = match build.openssl_dir(target) {
|
|
|
|
Some(dir) => dir,
|
|
|
|
None => return,
|
|
|
|
};
|
|
|
|
|
|
|
|
let stamp = out.join(".stamp");
|
|
|
|
let mut contents = String::new();
|
|
|
|
drop(File::open(&stamp).and_then(|mut f| f.read_to_string(&mut contents)));
|
|
|
|
if contents == OPENSSL_VERS {
|
|
|
|
return
|
2017-03-15 09:13:59 -05:00
|
|
|
}
|
2017-07-04 20:41:43 -05:00
|
|
|
t!(fs::create_dir_all(&out));
|
|
|
|
|
|
|
|
let name = format!("openssl-{}.tar.gz", OPENSSL_VERS);
|
|
|
|
let tarball = out.join(&name);
|
|
|
|
if !tarball.exists() {
|
|
|
|
let tmp = tarball.with_extension("tmp");
|
|
|
|
// originally from https://www.openssl.org/source/...
|
|
|
|
let url = format!("https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/{}",
|
|
|
|
name);
|
|
|
|
let mut ok = false;
|
|
|
|
for _ in 0..3 {
|
|
|
|
let status = Command::new("curl")
|
|
|
|
.arg("-o").arg(&tmp)
|
|
|
|
.arg(&url)
|
|
|
|
.status()
|
|
|
|
.expect("failed to spawn curl");
|
|
|
|
if status.success() {
|
|
|
|
ok = true;
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !ok {
|
|
|
|
panic!("failed to download openssl source")
|
|
|
|
}
|
|
|
|
let mut shasum = if target.contains("apple") {
|
|
|
|
let mut cmd = Command::new("shasum");
|
|
|
|
cmd.arg("-a").arg("256");
|
|
|
|
cmd
|
|
|
|
} else {
|
|
|
|
Command::new("sha256sum")
|
|
|
|
};
|
|
|
|
let output = output(&mut shasum.arg(&tmp));
|
|
|
|
let found = output.split_whitespace().next().unwrap();
|
|
|
|
if found != OPENSSL_SHA256 {
|
|
|
|
panic!("downloaded openssl sha256 different\n\
|
|
|
|
expected: {}\n\
|
|
|
|
found: {}\n", OPENSSL_SHA256, found);
|
|
|
|
}
|
|
|
|
t!(fs::rename(&tmp, &tarball));
|
2017-03-15 09:13:59 -05:00
|
|
|
}
|
2017-07-04 20:41:43 -05:00
|
|
|
let obj = out.join(format!("openssl-{}", OPENSSL_VERS));
|
|
|
|
let dst = build.openssl_install_dir(target).unwrap();
|
|
|
|
drop(fs::remove_dir_all(&obj));
|
|
|
|
drop(fs::remove_dir_all(&dst));
|
|
|
|
build.run(Command::new("tar").arg("xf").arg(&tarball).current_dir(&out));
|
|
|
|
|
|
|
|
let mut configure = Command::new(obj.join("Configure"));
|
|
|
|
configure.arg(format!("--prefix={}", dst.display()));
|
|
|
|
configure.arg("no-dso");
|
|
|
|
configure.arg("no-ssl2");
|
|
|
|
configure.arg("no-ssl3");
|
|
|
|
|
2017-07-13 19:48:44 -05:00
|
|
|
let os = match &*target {
|
2017-07-04 20:41:43 -05:00
|
|
|
"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",
|
|
|
|
"mips-unknown-linux-gnu" => "linux-mips32",
|
|
|
|
"mips64-unknown-linux-gnuabi64" => "linux64-mips64",
|
|
|
|
"mips64el-unknown-linux-gnuabi64" => "linux64-mips64",
|
|
|
|
"mipsel-unknown-linux-gnu" => "linux-mips32",
|
|
|
|
"powerpc-unknown-linux-gnu" => "linux-ppc",
|
|
|
|
"powerpc64-unknown-linux-gnu" => "linux-ppc64",
|
|
|
|
"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",
|
|
|
|
"x86_64-unknown-netbsd" => "BSD-x86_64",
|
|
|
|
_ => panic!("don't know how to configure OpenSSL for {}", target),
|
2017-02-15 17:57:06 -06:00
|
|
|
};
|
2017-07-04 20:41:43 -05:00
|
|
|
configure.arg(os);
|
|
|
|
configure.env("CC", build.cc(target));
|
|
|
|
for flag in build.cflags(target) {
|
|
|
|
configure.arg(flag);
|
2017-02-15 17:57:06 -06:00
|
|
|
}
|
2017-07-04 20:41:43 -05:00
|
|
|
// 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);
|
|
|
|
println!("Building openssl for {}", target);
|
|
|
|
build.run_quiet(Command::new("make").arg("-j1").current_dir(&obj));
|
|
|
|
println!("Installing openssl for {}", target);
|
|
|
|
build.run_quiet(Command::new("make").arg("install").current_dir(&obj));
|
|
|
|
|
|
|
|
let mut f = t!(File::create(&stamp));
|
|
|
|
t!(f.write_all(OPENSSL_VERS.as_bytes()));
|
2017-05-05 15:12:05 -05:00
|
|
|
}
|
2017-02-15 17:57:06 -06:00
|
|
|
}
|