Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not add external libraries to libstd stamp file #72698

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ impl Step for Std {
cargo,
args(builder.kind),
&libstd_stamp(builder, compiler, target),
vec![],
true,
);

Expand Down Expand Up @@ -102,7 +101,6 @@ impl Step for Rustc {
cargo,
args(builder.kind),
&librustc_stamp(builder, compiler, target),
vec![],
true,
);

Expand Down Expand Up @@ -160,7 +158,6 @@ macro_rules! tool_check_step {
cargo,
args(builder.kind),
&stamp(builder, compiler, target),
vec![],
true,
);

Expand Down
51 changes: 13 additions & 38 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,13 @@ impl Step for Std {
return;
}

let mut target_deps = builder.ensure(StartupObjects { compiler, target });
builder.ensure(StartupObjects { compiler, target });
copy_third_party_objects(builder, &compiler, target);

let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
if compiler_to_use != compiler {
builder.ensure(Std { compiler: compiler_to_use, target });
builder.info(&format!("Uplifting stage1 std ({} -> {})", compiler_to_use.host, target));

// Even if we're not building std this stage, the new sysroot must
// still contain the third party objects needed by various targets.
copy_third_party_objects(builder, &compiler, target);

builder.ensure(StdLink {
compiler: compiler_to_use,
target_compiler: compiler,
Expand All @@ -83,7 +79,6 @@ impl Step for Std {
return;
}

target_deps.extend(copy_third_party_objects(builder, &compiler, target).into_iter());

let mut cargo = builder.cargo(compiler, Mode::Std, target, "build");
std_cargo(builder, target, compiler.stage, &mut cargo);
Expand All @@ -97,7 +92,6 @@ impl Step for Std {
cargo,
vec![],
&libstd_stamp(builder, compiler, target),
target_deps,
false,
);

Expand All @@ -114,15 +108,12 @@ fn copy_third_party_objects(
builder: &Builder<'_>,
compiler: &Compiler,
target: Interned<String>,
) -> Vec<PathBuf> {
) {
let libdir = builder.sysroot_libdir(*compiler, target);

let mut target_deps = vec![];

let mut copy_and_stamp = |sourcedir: &Path, name: &str| {
let copy = |sourcedir: &Path, name: &str| {
let target = libdir.join(name);
builder.copy(&sourcedir.join(name), &target);
target_deps.push(target);
};

// Copies the CRT objects.
Expand All @@ -135,11 +126,11 @@ fn copy_third_party_objects(
if target.contains("musl") {
let srcdir = builder.musl_root(target).unwrap().join("lib");
for &obj in &["crt1.o", "Scrt1.o", "rcrt1.o", "crti.o", "crtn.o"] {
copy_and_stamp(&srcdir, obj);
copy(&srcdir, obj);
}
} else if target.ends_with("-wasi") {
let srcdir = builder.wasi_root(target).unwrap().join("lib/wasm32-wasi");
copy_and_stamp(&srcdir, "crt1.o");
copy(&srcdir, "crt1.o");
}

// Copies libunwind.a compiled to be linked with x86_64-fortanix-unknown-sgx.
Expand All @@ -151,16 +142,14 @@ fn copy_third_party_objects(
let src_path_env = "X86_FORTANIX_SGX_LIBS";
let src =
env::var(src_path_env).unwrap_or_else(|_| panic!("{} not found in env", src_path_env));
copy_and_stamp(Path::new(&src), "libunwind.a");
copy(Path::new(&src), "libunwind.a");
}

if builder.config.sanitizers && compiler.stage != 0 {
// The sanitizers are only copied in stage1 or above,
// to avoid creating dependency on LLVM.
target_deps.extend(copy_sanitizers(builder, &compiler, target));
copy_sanitizers(builder, &compiler, target);
}

target_deps
}

/// Configure cargo to compile the standard library, adding appropriate env vars
Expand Down Expand Up @@ -287,14 +276,13 @@ fn copy_sanitizers(
builder: &Builder<'_>,
compiler: &Compiler,
target: Interned<String>,
) -> Vec<PathBuf> {
) {
let runtimes: Vec<native::SanitizerRuntime> = builder.ensure(native::Sanitizers { target });

if builder.config.dry_run {
return Vec::new();
return;
}

let mut target_deps = Vec::new();
let libdir = builder.sysroot_libdir(*compiler, target);

for runtime in &runtimes {
Expand All @@ -311,11 +299,7 @@ fn copy_sanitizers(
.expect("failed to execute `install_name_tool`");
assert!(status.success());
}

target_deps.push(dst);
}

target_deps
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
Expand All @@ -325,7 +309,7 @@ pub struct StartupObjects {
}

impl Step for StartupObjects {
type Output = Vec<PathBuf>;
type Output = ();

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/rtstartup")
Expand All @@ -344,15 +328,13 @@ impl Step for StartupObjects {
/// They don't require any library support as they're just plain old object
/// files, so we just use the nightly snapshot compiler to always build them (as
/// no other compilers are guaranteed to be available).
fn run(self, builder: &Builder<'_>) -> Vec<PathBuf> {
fn run(self, builder: &Builder<'_>) {
let for_compiler = self.compiler;
let target = self.target;
if !target.contains("windows-gnu") {
return vec![];
return ();
}

let mut target_deps = vec![];

let src_dir = &builder.src.join("src/rtstartup");
let dst_dir = &builder.native_dir(target).join("rtstartup");
let sysroot_dir = &builder.sysroot_libdir(for_compiler, target);
Expand All @@ -378,17 +360,13 @@ impl Step for StartupObjects {

let target = sysroot_dir.join((*file).to_string() + ".o");
builder.copy(dst_file, &target);
target_deps.push(target);
}

for obj in ["crt2.o", "dllcrt2.o"].iter() {
let src = compiler_file(builder, builder.cc(target), target, obj);
let target = sysroot_dir.join(obj);
builder.copy(&src, &target);
target_deps.push(target);
}

target_deps
}
}

Expand Down Expand Up @@ -462,7 +440,6 @@ impl Step for Rustc {
cargo,
vec![],
&librustc_stamp(builder, compiler, target),
vec![],
false,
);

Expand Down Expand Up @@ -814,7 +791,6 @@ pub fn run_cargo(
cargo: Cargo,
tail_args: Vec<String>,
stamp: &Path,
additional_target_deps: Vec<PathBuf>,
is_check: bool,
) -> Vec<PathBuf> {
if builder.config.dry_run {
Expand Down Expand Up @@ -931,7 +907,6 @@ pub fn run_cargo(
deps.push((path_to_add.into(), false));
}

deps.extend(additional_target_deps.into_iter().map(|d| (d, false)));
deps.sort();
let mut new_contents = Vec::new();
for (dep, proc_macro) in deps.iter() {
Expand Down
70 changes: 14 additions & 56 deletions src/ci/azure-pipelines/try.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,59 +26,17 @@ jobs:
strategy:
matrix:
dist-x86_64-linux: {}
dist-x86_64-linux-alt:
IMAGE: dist-x86_64-linux

# The macOS and Windows builds here are currently disabled due to them not being
# overly necessary on `try` builds. We also don't actually have anything that
# consumes the artifacts currently. Perhaps one day we can re-enable, but for now
# it helps free up capacity on Azure.
# - job: macOS
# timeoutInMinutes: 600
# pool:
# vmImage: macos-10.15
# steps:
# - template: steps/run.yml
# strategy:
# matrix:
# dist-x86_64-apple:
# SCRIPT: ./x.py dist
# INITIAL_RUST_CONFIGURE_ARGS: --target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc
# DEPLOY: 1
# RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
# MACOSX_DEPLOYMENT_TARGET: 10.7
# NO_LLVM_ASSERTIONS: 1
# NO_DEBUG_ASSERTIONS: 1
# DIST_REQUIRE_ALL_TOOLS: 1
#
# dist-x86_64-apple-alt:
# SCRIPT: ./x.py dist
# INITIAL_RUST_CONFIGURE_ARGS: --enable-extended --enable-profiler --set rust.jemalloc
# DEPLOY_ALT: 1
# RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
# MACOSX_DEPLOYMENT_TARGET: 10.7
# NO_LLVM_ASSERTIONS: 1
# NO_DEBUG_ASSERTIONS: 1
#
# - job: Windows
# timeoutInMinutes: 600
# pool:
# vmImage: 'vs2017-win2016'
# steps:
# - template: steps/run.yml
# strategy:
# matrix:
# dist-x86_64-msvc:
# INITIAL_RUST_CONFIGURE_ARGS: >
# --build=x86_64-pc-windows-msvc
# --target=x86_64-pc-windows-msvc,aarch64-pc-windows-msvc
# --enable-full-tools
# --enable-profiler
# SCRIPT: python x.py dist
# DIST_REQUIRE_ALL_TOOLS: 1
# DEPLOY: 1
#
# dist-x86_64-msvc-alt:
# INITIAL_RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-extended --enable-profiler
# SCRIPT: python x.py dist
# DEPLOY_ALT: 1
dist-i586-gnu-i586-i686-musl: {}
- job: Windows
timeoutInMinutes: 600
pool:
vmImage: 'vs2017-win2016'
steps:
- template: steps/run.yml
strategy:
matrix:
dist-x86_64-mingw:
SCRIPT: python x.py dist
INITIAL_RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu --enable-full-tools --enable-profiler
CUSTOM_MINGW: 1
DIST_REQUIRE_ALL_TOOLS: 1