Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a45a81a

Browse files
committed
Patch coretests separately from the standard library source
1 parent f79601f commit a45a81a

8 files changed

+75
-38
lines changed

build_system/prepare.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ use std::process::Command;
66
use super::build_sysroot::{BUILD_SYSROOT, ORIG_BUILD_SYSROOT, SYSROOT_RUSTC_VERSION, SYSROOT_SRC};
77
use super::path::{Dirs, RelPath};
88
use super::rustc_info::{get_default_sysroot, get_rustc_version};
9+
use super::tests::LIBCORE_TESTS_SRC;
910
use super::utils::{copy_dir_recursively, git_command, retry_spawn_and_wait, spawn_and_wait};
1011

1112
pub(crate) fn prepare(dirs: &Dirs) {
1213
RelPath::DOWNLOAD.ensure_fresh(dirs);
1314

1415
spawn_and_wait(super::build_backend::CG_CLIF.fetch("cargo", "rustc", dirs));
1516

16-
prepare_sysroot(dirs);
17+
prepare_stdlib(dirs);
1718
spawn_and_wait(super::build_sysroot::STANDARD_LIBRARY.fetch("cargo", "rustc", dirs));
19+
20+
prepare_coretests(dirs);
1821
spawn_and_wait(super::tests::LIBCORE_TESTS.fetch("cargo", "rustc", dirs));
1922

2023
super::tests::RAND_REPO.fetch(dirs);
@@ -25,11 +28,11 @@ pub(crate) fn prepare(dirs: &Dirs) {
2528
spawn_and_wait(super::tests::PORTABLE_SIMD.fetch("cargo", "rustc", dirs));
2629
}
2730

28-
fn prepare_sysroot(dirs: &Dirs) {
31+
fn prepare_stdlib(dirs: &Dirs) {
2932
let sysroot_src_orig = get_default_sysroot(Path::new("rustc")).join("lib/rustlib/src/rust");
3033
assert!(sysroot_src_orig.exists());
3134

32-
eprintln!("[COPY] sysroot src");
35+
eprintln!("[COPY] stdlib src");
3336

3437
// FIXME ensure builds error out or update the copy if any of the files copied here change
3538
BUILD_SYSROOT.ensure_fresh(dirs);
@@ -47,7 +50,25 @@ fn prepare_sysroot(dirs: &Dirs) {
4750
eprintln!("[GIT] init");
4851
init_git_repo(&SYSROOT_SRC.to_path(dirs));
4952

50-
apply_patches(dirs, "sysroot", &SYSROOT_SRC.to_path(dirs));
53+
apply_patches(dirs, "stdlib", &SYSROOT_SRC.to_path(dirs));
54+
}
55+
56+
fn prepare_coretests(dirs: &Dirs) {
57+
let sysroot_src_orig = get_default_sysroot(Path::new("rustc")).join("lib/rustlib/src/rust");
58+
assert!(sysroot_src_orig.exists());
59+
60+
eprintln!("[COPY] coretests src");
61+
62+
fs::create_dir_all(LIBCORE_TESTS_SRC.to_path(dirs)).unwrap();
63+
copy_dir_recursively(
64+
&sysroot_src_orig.join("library/core/tests"),
65+
&LIBCORE_TESTS_SRC.to_path(dirs),
66+
);
67+
68+
eprintln!("[GIT] init");
69+
init_git_repo(&LIBCORE_TESTS_SRC.to_path(dirs));
70+
71+
apply_patches(dirs, "coretests", &LIBCORE_TESTS_SRC.to_path(dirs));
5172
}
5273

5374
pub(crate) struct GitRepo {

build_system/tests.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::build_sysroot::{self, SYSROOT_SRC};
1+
use super::build_sysroot;
22
use super::config;
33
use super::path::{Dirs, RelPath};
44
use super::prepare::GitRepo;
@@ -114,8 +114,9 @@ pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
114114
pub(crate) static PORTABLE_SIMD: CargoProject =
115115
CargoProject::new(&PORTABLE_SIMD_REPO.source_dir(), "portable_simd");
116116

117-
pub(crate) static LIBCORE_TESTS: CargoProject =
118-
CargoProject::new(&SYSROOT_SRC.join("library/core/tests"), "core_tests");
117+
pub(crate) static LIBCORE_TESTS_SRC: RelPath = RelPath::DOWNLOAD.join("coretests_src");
118+
119+
pub(crate) static LIBCORE_TESTS: CargoProject = CargoProject::new(&LIBCORE_TESTS_SRC, "core_tests");
119120

120121
const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
121122
TestCase::custom("test.rust-random/rand", &|runner| {

patches/0022-sysroot-Disable-not-compiling-tests.patch renamed to patches/0022-coretests-Disable-not-compiling-tests.patch

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ Subject: [PATCH] [core] Disable not compiling tests
1313
6 files changed, 16 insertions(+), 1 deletion(-)
1414
create mode 100644 library/core/tests/Cargo.toml
1515

16-
diff --git a/library/core/tests/Cargo.toml b/library/core/tests/Cargo.toml
16+
diff --git a/Cargo.toml b/Cargo.toml
1717
new file mode 100644
1818
index 0000000..46fd999
1919
--- /dev/null
20-
+++ b/library/core/tests/Cargo.toml
20+
+++ b/Cargo.toml
2121
@@ -0,0 +1,12 @@
2222
+[package]
23-
+name = "core"
23+
+name = "coretests"
2424
+version = "0.0.0"
2525
+edition = "2021"
2626
+
@@ -31,10 +31,10 @@ index 0000000..46fd999
3131
+[dependencies]
3232
+rand = { version = "0.8.5", default-features = false }
3333
+rand_xorshift = { version = "0.3.0", default-features = false }
34-
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
34+
diff --git a/lib.rs b/lib.rs
3535
index 42a26ae..5ac1042 100644
36-
--- a/library/core/tests/lib.rs
37-
+++ b/library/core/tests/lib.rs
36+
--- a/lib.rs
37+
+++ b/lib.rs
3838
@@ -1,3 +1,4 @@
3939
+#![cfg(test)]
4040
#![feature(alloc_layout_extra)]

patches/0023-sysroot-Ignore-failing-tests.patch renamed to patches/0023-coretests-Ignore-failing-tests.patch

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ Subject: [PATCH] [core] Ignore failing tests
1010
library/core/tests/time.rs | 1 +
1111
4 files changed, 18 insertions(+), 2 deletions(-)
1212

13-
diff --git a/library/core/tests/array.rs b/library/core/tests/array.rs
13+
diff --git a/array.rs b/array.rs
1414
index 4bc44e9..8e3c7a4 100644
15-
--- a/library/core/tests/array.rs
16-
+++ b/library/core/tests/array.rs
15+
--- a/array.rs
16+
+++ b/array.rs
1717
@@ -242,6 +242,7 @@ fn iterator_drops() {
1818
assert_eq!(i.get(), 5);
1919
}
@@ -46,10 +46,10 @@ index 4bc44e9..8e3c7a4 100644
4646

4747
#[test]
4848
fn cell_allows_array_cycle() {
49-
diff --git a/library/core/tests/atomic.rs b/library/core/tests/atomic.rs
49+
diff --git a/atomic.rs b/atomic.rs
5050
index 13b12db..96fe4b9 100644
51-
--- a/library/core/tests/atomic.rs
52-
+++ b/library/core/tests/atomic.rs
51+
--- a/atomic.rs
52+
+++ b/atomic.rs
5353
@@ -185,6 +185,7 @@ fn ptr_bitops() {
5454
}
5555

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
From ad7ffe71baba46865f2e65266ab025920dfdc20b Mon Sep 17 00:00:00 2001
2+
From: bjorn3 <[email protected]>
3+
Date: Thu, 18 Feb 2021 18:45:28 +0100
4+
Subject: [PATCH] Disable 128bit atomic operations
5+
6+
Cranelift doesn't support them yet
7+
---
8+
library/core/src/panic/unwind_safe.rs | 6 -----
9+
library/core/src/sync/atomic.rs | 38 ---------------------------
10+
library/core/tests/atomic.rs | 4 ---
11+
4 files changed, 4 insertions(+), 50 deletions(-)
12+
13+
diff --git a/atomic.rs b/atomic.rs
14+
index b735957..ea728b6 100644
15+
--- a/atomic.rs
16+
+++ b/atomic.rs
17+
@@ -185,10 +185,6 @@ fn atomic_alignment() {
18+
assert_eq!(align_of::<AtomicU64>(), size_of::<AtomicU64>());
19+
#[cfg(target_has_atomic = "64")]
20+
assert_eq!(align_of::<AtomicI64>(), size_of::<AtomicI64>());
21+
- #[cfg(target_has_atomic = "128")]
22+
- assert_eq!(align_of::<AtomicU128>(), size_of::<AtomicU128>());
23+
- #[cfg(target_has_atomic = "128")]
24+
- assert_eq!(align_of::<AtomicI128>(), size_of::<AtomicI128>());
25+
#[cfg(target_has_atomic = "ptr")]
26+
assert_eq!(align_of::<AtomicUsize>(), size_of::<AtomicUsize>());
27+
#[cfg(target_has_atomic = "ptr")]
28+
--
29+
2.26.2.7.g19db9cfb68
30+

patches/0027-sysroot-128bit-atomic-operations.patch renamed to patches/0027-stdlib-128bit-atomic-operations.patch

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,6 @@ index d9de37e..8293fce 100644
8585

8686
macro_rules! atomic_int_ptr_sized {
8787
( $($target_pointer_width:literal $align:literal)* ) => { $(
88-
diff --git a/library/core/tests/atomic.rs b/library/core/tests/atomic.rs
89-
index b735957..ea728b6 100644
90-
--- a/library/core/tests/atomic.rs
91-
+++ b/library/core/tests/atomic.rs
92-
@@ -185,10 +185,6 @@ fn atomic_alignment() {
93-
assert_eq!(align_of::<AtomicU64>(), size_of::<AtomicU64>());
94-
#[cfg(target_has_atomic = "64")]
95-
assert_eq!(align_of::<AtomicI64>(), size_of::<AtomicI64>());
96-
- #[cfg(target_has_atomic = "128")]
97-
- assert_eq!(align_of::<AtomicU128>(), size_of::<AtomicU128>());
98-
- #[cfg(target_has_atomic = "128")]
99-
- assert_eq!(align_of::<AtomicI128>(), size_of::<AtomicI128>());
100-
#[cfg(target_has_atomic = "ptr")]
101-
assert_eq!(align_of::<AtomicUsize>(), size_of::<AtomicUsize>());
102-
#[cfg(target_has_atomic = "ptr")]
10388
--
10489
2.26.2.7.g19db9cfb68
10590

patches/0028-sysroot-Disable-long-running-tests.patch renamed to patches/0028-coretests-Disable-long-running-tests.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Subject: [PATCH] Disable long running tests
77
library/core/tests/slice.rs | 2 ++
88
1 file changed, 2 insertions(+)
99

10-
diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs
10+
diff --git a/slice.rs b/slice.rs
1111
index 8402833..84592e0 100644
12-
--- a/library/core/tests/slice.rs
13-
+++ b/library/core/tests/slice.rs
12+
--- a/slice.rs
13+
+++ b/slice.rs
1414
@@ -1809,6 +1809,7 @@ fn sort_unstable() {
1515
assert!(v == [0xDEADBEEF]);
1616
}

scripts/setup_rust_fork.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ git fetch
1010
git checkout -- .
1111
git checkout "$(rustc -V | cut -d' ' -f3 | tr -d '(')"
1212

13-
git -c user.name=Dummy -c [email protected] am ../patches/*-sysroot-*.patch
13+
git -c user.name=Dummy -c [email protected] am ../patches/*-stdlib-*.patch
1414

1515
git apply - <<EOF
1616
diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml

0 commit comments

Comments
 (0)