Skip to content

Commit 554b787

Browse files
committed
Auto merge of #54919 - alexcrichton:update-cargo, r=Mark-Simulacrum
Update Cargo, build curl/OpenSSL statically via features In addition to to updating Cargo's submodule and Cargo's dependencies, this also updates Cargo's build to build OpenSSL statically into Cargo as well as libcurl unconditionally. This removes OpenSSL build logic from the bootstrap code, and otherwise requests that even on OSX we build curl statically.
2 parents d541876 + 4f661c0 commit 554b787

File tree

19 files changed

+285
-435
lines changed

19 files changed

+285
-435
lines changed

config.toml.example

+3-4
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,9 @@
182182
# Build the profiler runtime
183183
#profiler = false
184184

185-
# Indicates whether the OpenSSL linked into Cargo will be statically linked or
186-
# not. If static linkage is specified then the build system will download a
187-
# known-good version of OpenSSL, compile it, and link it to Cargo.
188-
#openssl-static = false
185+
# Indicates whether the native libraries linked into Cargo will be statically
186+
# linked or not.
187+
#cargo-native-static = false
189188

190189
# Run the build with low priority, by setting the process group's "nice" value
191190
# to +10 on Unix platforms, and by using a "low priority" job object on Windows.

src/Cargo.lock

+193-187
Large diffs are not rendered by default.

src/bootstrap/check.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ impl Step for Rustdoc {
224224
target,
225225
"check",
226226
"src/tools/rustdoc",
227-
SourceType::InTree);
227+
SourceType::InTree,
228+
&[]);
228229

229230
let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage));
230231
println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);

src/bootstrap/config.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub struct Config {
149149
pub nodejs: Option<PathBuf>,
150150
pub gdb: Option<PathBuf>,
151151
pub python: Option<PathBuf>,
152-
pub openssl_static: bool,
152+
pub cargo_native_static: bool,
153153
pub configure_args: Vec<String>,
154154

155155
// These are either the stage0 downloaded binaries or the locally installed ones.
@@ -221,7 +221,7 @@ struct Build {
221221
verbose: Option<usize>,
222222
sanitizers: Option<bool>,
223223
profiler: Option<bool>,
224-
openssl_static: Option<bool>,
224+
cargo_native_static: Option<bool>,
225225
configure_args: Option<Vec<String>>,
226226
local_rebuild: Option<bool>,
227227
print_step_timings: Option<bool>,
@@ -474,7 +474,7 @@ impl Config {
474474
set(&mut config.verbose, build.verbose);
475475
set(&mut config.sanitizers, build.sanitizers);
476476
set(&mut config.profiler, build.profiler);
477-
set(&mut config.openssl_static, build.openssl_static);
477+
set(&mut config.cargo_native_static, build.cargo_native_static);
478478
set(&mut config.configure_args, build.configure_args);
479479
set(&mut config.local_rebuild, build.local_rebuild);
480480
set(&mut config.print_step_timings, build.print_step_timings);

src/bootstrap/configure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def v(*args):
6464
o("vendor", "build.vendor", "enable usage of vendored Rust crates")
6565
o("sanitizers", "build.sanitizers", "build the sanitizer runtimes (asan, lsan, msan, tsan)")
6666
o("dist-src", "rust.dist-src", "when building tarballs enables building a source tarball")
67-
o("cargo-openssl-static", "build.openssl-static", "static openssl in cargo")
67+
o("cargo-native-static", "build.cargo-native-static", "static native libraries in cargo")
6868
o("profiler", "build.profiler", "build the profiler runtime")
6969
o("emscripten", None, "compile the emscripten backend as well as LLVM")
7070
o("full-tools", None, "enable all tools")

src/bootstrap/dist.rs

-7
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use channel;
3131
use util::{libdir, is_dylib, exe};
3232
use builder::{Builder, RunConfig, ShouldRun, Step};
3333
use compile;
34-
use native;
3534
use tool::{self, Tool};
3635
use cache::{INTERNER, Interned};
3736
use time;
@@ -990,12 +989,6 @@ impl Step for PlainSourceTarball {
990989
.arg("--debug")
991990
.arg("--vers").arg(CARGO_VENDOR_VERSION)
992991
.arg("cargo-vendor");
993-
if let Some(dir) = builder.openssl_install_dir(builder.config.build) {
994-
builder.ensure(native::Openssl {
995-
target: builder.config.build,
996-
});
997-
cmd.env("OPENSSL_DIR", dir);
998-
}
999992
builder.run(&mut cmd);
1000993
}
1001994

src/bootstrap/doc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ impl Step for Rustdoc {
805805
"doc",
806806
"src/tools/rustdoc",
807807
SourceType::InTree,
808+
&[]
808809
);
809810

810811
cargo.env("RUSTDOCFLAGS", "--document-private-items");

src/bootstrap/lib.rs

-19
Original file line numberDiff line numberDiff line change
@@ -926,25 +926,6 @@ impl Build {
926926
(self.hosts.iter().any(|h| *h == target) || target == self.build)
927927
}
928928

929-
/// Returns the directory that OpenSSL artifacts are compiled into if
930-
/// configured to do so.
931-
fn openssl_dir(&self, target: Interned<String>) -> Option<PathBuf> {
932-
// OpenSSL not used on Windows
933-
if target.contains("windows") {
934-
None
935-
} else if self.config.openssl_static {
936-
Some(self.out.join(&*target).join("openssl"))
937-
} else {
938-
None
939-
}
940-
}
941-
942-
/// Returns the directory that OpenSSL artifacts are installed into if
943-
/// configured as such.
944-
fn openssl_install_dir(&self, target: Interned<String>) -> Option<PathBuf> {
945-
self.openssl_dir(target).map(|p| p.join("install"))
946-
}
947-
948929
/// Given `num` in the form "a.b.c" return a "release string" which
949930
/// describes the release version number.
950931
///

src/bootstrap/native.rs

-186
Original file line numberDiff line numberDiff line change
@@ -531,189 +531,3 @@ impl Step for TestHelpers {
531531
.compile("rust_test_helpers");
532532
}
533533
}
534-
535-
const OPENSSL_VERS: &'static str = "1.0.2n";
536-
const OPENSSL_SHA256: &'static str =
537-
"370babb75f278c39e0c50e8c4e7493bc0f18db6867478341a832a982fd15a8fe";
538-
539-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
540-
pub struct Openssl {
541-
pub target: Interned<String>,
542-
}
543-
544-
impl Step for Openssl {
545-
type Output = ();
546-
547-
fn should_run(run: ShouldRun) -> ShouldRun {
548-
run.never()
549-
}
550-
551-
fn run(self, builder: &Builder) {
552-
if builder.config.dry_run {
553-
return;
554-
}
555-
let target = self.target;
556-
let out = match builder.openssl_dir(target) {
557-
Some(dir) => dir,
558-
None => return,
559-
};
560-
561-
let stamp = out.join(".stamp");
562-
let mut contents = String::new();
563-
drop(File::open(&stamp).and_then(|mut f| f.read_to_string(&mut contents)));
564-
if contents == OPENSSL_VERS {
565-
return
566-
}
567-
t!(fs::create_dir_all(&out));
568-
569-
let name = format!("openssl-{}.tar.gz", OPENSSL_VERS);
570-
let tarball = out.join(&name);
571-
if !tarball.exists() {
572-
let tmp = tarball.with_extension("tmp");
573-
// originally from https://www.openssl.org/source/...
574-
let url = format!("https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/{}",
575-
name);
576-
let mut last_error = None;
577-
for _ in 0..3 {
578-
let status = Command::new("curl")
579-
.arg("-o").arg(&tmp)
580-
.arg("-f") // make curl fail if the URL does not return HTTP 200
581-
.arg(&url)
582-
.status()
583-
.expect("failed to spawn curl");
584-
585-
// Retry if download failed.
586-
if !status.success() {
587-
last_error = Some(status.to_string());
588-
continue;
589-
}
590-
591-
// Ensure the hash is correct.
592-
let mut shasum = if target.contains("apple") ||
593-
builder.config.build.contains("netbsd") {
594-
let mut cmd = Command::new("shasum");
595-
cmd.arg("-a").arg("256");
596-
cmd
597-
} else {
598-
Command::new("sha256sum")
599-
};
600-
let output = output(&mut shasum.arg(&tmp));
601-
let found = output.split_whitespace().next().unwrap();
602-
603-
// If the hash is wrong, probably the download is incomplete or S3 served an error
604-
// page. In any case, retry.
605-
if found != OPENSSL_SHA256 {
606-
last_error = Some(format!(
607-
"downloaded openssl sha256 different\n\
608-
expected: {}\n\
609-
found: {}\n",
610-
OPENSSL_SHA256,
611-
found
612-
));
613-
continue;
614-
}
615-
616-
// Everything is fine, so exit the retry loop.
617-
last_error = None;
618-
break;
619-
}
620-
if let Some(error) = last_error {
621-
panic!("failed to download openssl source: {}", error);
622-
}
623-
t!(fs::rename(&tmp, &tarball));
624-
}
625-
let obj = out.join(format!("openssl-{}", OPENSSL_VERS));
626-
let dst = builder.openssl_install_dir(target).unwrap();
627-
drop(fs::remove_dir_all(&obj));
628-
drop(fs::remove_dir_all(&dst));
629-
builder.run(Command::new("tar").arg("zxf").arg(&tarball).current_dir(&out));
630-
631-
let mut configure = Command::new("perl");
632-
configure.arg(obj.join("Configure"));
633-
configure.arg(format!("--prefix={}", dst.display()));
634-
configure.arg("no-dso");
635-
configure.arg("no-ssl2");
636-
configure.arg("no-ssl3");
637-
638-
let os = match &*target {
639-
"aarch64-linux-android" => "linux-aarch64",
640-
"aarch64-unknown-linux-gnu" => "linux-aarch64",
641-
"aarch64-unknown-linux-musl" => "linux-aarch64",
642-
"aarch64-unknown-netbsd" => "BSD-generic64",
643-
"arm-linux-androideabi" => "android",
644-
"arm-unknown-linux-gnueabi" => "linux-armv4",
645-
"arm-unknown-linux-gnueabihf" => "linux-armv4",
646-
"armv6-unknown-netbsd-eabihf" => "BSD-generic32",
647-
"armv7-linux-androideabi" => "android-armv7",
648-
"armv7-unknown-linux-gnueabihf" => "linux-armv4",
649-
"armv7-unknown-netbsd-eabihf" => "BSD-generic32",
650-
"i586-unknown-linux-gnu" => "linux-elf",
651-
"i586-unknown-linux-musl" => "linux-elf",
652-
"i686-apple-darwin" => "darwin-i386-cc",
653-
"i686-linux-android" => "android-x86",
654-
"i686-unknown-freebsd" => "BSD-x86-elf",
655-
"i686-unknown-linux-gnu" => "linux-elf",
656-
"i686-unknown-linux-musl" => "linux-elf",
657-
"i686-unknown-netbsd" => "BSD-x86-elf",
658-
"mips-unknown-linux-gnu" => "linux-mips32",
659-
"mips64-unknown-linux-gnuabi64" => "linux64-mips64",
660-
"mips64el-unknown-linux-gnuabi64" => "linux64-mips64",
661-
"mipsel-unknown-linux-gnu" => "linux-mips32",
662-
"powerpc-unknown-linux-gnu" => "linux-ppc",
663-
"powerpc-unknown-linux-gnuspe" => "linux-ppc",
664-
"powerpc-unknown-netbsd" => "BSD-generic32",
665-
"powerpc64-unknown-linux-gnu" => "linux-ppc64",
666-
"powerpc64le-unknown-linux-gnu" => "linux-ppc64le",
667-
"powerpc64le-unknown-linux-musl" => "linux-ppc64le",
668-
"s390x-unknown-linux-gnu" => "linux64-s390x",
669-
"sparc-unknown-linux-gnu" => "linux-sparcv9",
670-
"sparc64-unknown-linux-gnu" => "linux64-sparcv9",
671-
"sparc64-unknown-netbsd" => "BSD-sparc64",
672-
"x86_64-apple-darwin" => "darwin64-x86_64-cc",
673-
"x86_64-linux-android" => "linux-x86_64",
674-
"x86_64-unknown-freebsd" => "BSD-x86_64",
675-
"x86_64-unknown-dragonfly" => "BSD-x86_64",
676-
"x86_64-unknown-linux-gnu" => "linux-x86_64",
677-
"x86_64-unknown-linux-gnux32" => "linux-x32",
678-
"x86_64-unknown-linux-musl" => "linux-x86_64",
679-
"x86_64-unknown-netbsd" => "BSD-x86_64",
680-
_ => panic!("don't know how to configure OpenSSL for {}", target),
681-
};
682-
configure.arg(os);
683-
configure.env("CC", builder.cc(target));
684-
for flag in builder.cflags(target, GitRepo::Rustc) {
685-
configure.arg(flag);
686-
}
687-
// There is no specific os target for android aarch64 or x86_64,
688-
// so we need to pass some extra cflags
689-
if target == "aarch64-linux-android" || target == "x86_64-linux-android" {
690-
configure.arg("-mandroid");
691-
configure.arg("-fomit-frame-pointer");
692-
}
693-
if target == "sparc64-unknown-netbsd" {
694-
// Need -m64 to get assembly generated correctly for sparc64.
695-
configure.arg("-m64");
696-
if builder.config.build.contains("netbsd") {
697-
// Disable sparc64 asm on NetBSD builders, it uses
698-
// m4(1)'s -B flag, which NetBSD m4 does not support.
699-
configure.arg("no-asm");
700-
}
701-
}
702-
// Make PIE binaries
703-
// Non-PIE linker support was removed in Lollipop
704-
// https://source.android.com/security/enhancements/enhancements50
705-
if target == "i686-linux-android" {
706-
configure.arg("no-asm");
707-
}
708-
configure.current_dir(&obj);
709-
builder.info(&format!("Configuring openssl for {}", target));
710-
builder.run_quiet(&mut configure);
711-
builder.info(&format!("Building openssl for {}", target));
712-
builder.run_quiet(Command::new("make").arg("-j1").current_dir(&obj));
713-
builder.info(&format!("Installing openssl for {}", target));
714-
builder.run_quiet(Command::new("make").arg("install").arg("-j1").current_dir(&obj));
715-
716-
let mut f = t!(File::create(&stamp));
717-
t!(f.write_all(OPENSSL_VERS.as_bytes()));
718-
}
719-
}

src/bootstrap/test.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ impl Step for Cargo {
228228
self.host,
229229
"test",
230230
"src/tools/cargo",
231-
SourceType::Submodule);
231+
SourceType::Submodule,
232+
&[]);
232233

233234
if !builder.fail_fast {
234235
cargo.arg("--no-fail-fast");
@@ -290,7 +291,8 @@ impl Step for Rls {
290291
host,
291292
"test",
292293
"src/tools/rls",
293-
SourceType::Submodule);
294+
SourceType::Submodule,
295+
&[]);
294296

295297
// Copy `src/tools/rls/test_data` to a writable drive.
296298
let test_workspace_path = builder.out.join("rls-test-data");
@@ -352,7 +354,8 @@ impl Step for Rustfmt {
352354
host,
353355
"test",
354356
"src/tools/rustfmt",
355-
SourceType::Submodule);
357+
SourceType::Submodule,
358+
&[]);
356359

357360
let dir = testdir(builder, compiler.host);
358361
t!(fs::create_dir_all(&dir));
@@ -407,7 +410,8 @@ impl Step for Miri {
407410
host,
408411
"test",
409412
"src/tools/miri",
410-
SourceType::Submodule);
413+
SourceType::Submodule,
414+
&[]);
411415

412416
// miri tests need to know about the stage sysroot
413417
cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
@@ -466,7 +470,8 @@ impl Step for Clippy {
466470
host,
467471
"test",
468472
"src/tools/clippy",
469-
SourceType::Submodule);
473+
SourceType::Submodule,
474+
&[]);
470475

471476
// clippy tests need to know about the stage sysroot
472477
cargo.env("SYSROOT", builder.sysroot(compiler));
@@ -1777,7 +1782,8 @@ impl Step for CrateRustdoc {
17771782
target,
17781783
test_kind.subcommand(),
17791784
"src/tools/rustdoc",
1780-
SourceType::InTree);
1785+
SourceType::InTree,
1786+
&[]);
17811787
if test_kind.subcommand() == "test" && !builder.fail_fast {
17821788
cargo.arg("--no-fail-fast");
17831789
}

0 commit comments

Comments
 (0)