Skip to content

Commit bd47d68

Browse files
committedDec 12, 2018
Auto merge of rust-lang#56092 - alexcrichton:no-more-std-subodules, r=Mark-Simulacrum
std: Depend directly on crates.io crates Ever since we added a Cargo-based build system for the compiler the standard library has always been a little special, it's never been able to depend on crates.io crates for runtime dependencies. This has been a result of various limitations, namely that Cargo doesn't understand that crates from crates.io depend on libcore, so Cargo tries to build crates before libcore is finished. I had an idea this afternoon, however, which lifts the strategy from rust-lang#52919 to directly depend on crates.io crates from the standard library. After all is said and done this removes a whopping three submodules that we need to manage! The basic idea here is that for any crate `std` depends on it adds an *optional* dependency on an empty crate on crates.io, in this case named `rustc-std-workspace-core`. This crate is overridden via `[patch]` in this repository to point to a local crate we write, and *that* has a `path` dependency on libcore. Note that all `no_std` crates also depend on `compiler_builtins`, but if we're not using submodules we can publish `compiler_builtins` to crates.io and all crates can depend on it anyway! The basic strategy then looks like: * The standard library (or some transitive dep) decides to depend on a crate `foo`. * The standard library adds ```toml [dependencies] foo = { version = "0.1", features = ['rustc-dep-of-std'] } ``` * The crate `foo` has an optional dependency on `rustc-std-workspace-core` * The crate `foo` has an optional dependency on `compiler_builtins` * The crate `foo` has a feature `rustc-dep-of-std` which activates these crates and any other necessary infrastructure in the crate. A sample commit for `dlmalloc` [turns out to be quite simple][commit]. After that all `no_std` crates should largely build "as is" and still be publishable on crates.io! Notably they should be able to continue to use stable Rust if necessary, since the `rename-dependency` feature of Cargo is soon stabilizing. As a proof of concept, this commit removes the `dlmalloc`, `libcompiler_builtins`, and `libc` submodules from this repository. Long thorns in our side these are now gone for good and we can directly depend on crates.io! It's hoped that in the long term we can bring in other crates as necessary, but for now this is largely intended to simply make it easier to manage these crates and remove submodules. This should be a transparent non-breaking change for all users, but one possible stickler is that this almost for sure breaks out-of-tree `std`-building tools like `xargo` and `cargo-xbuild`. I think it should be relatively easy to get them working, however, as all that's needed is an entry in the `[patch]` section used to build the standard library. Hopefully we can work with these tools to solve this problem! [commit]: alexcrichton/dlmalloc-rs@28ee12d

File tree

99 files changed

+231
-314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+231
-314
lines changed
 

‎.gitmodules

-12
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
[submodule "src/rust-installer"]
66
path = src/tools/rust-installer
77
url = https://github.com/rust-lang/rust-installer.git
8-
[submodule "src/liblibc"]
9-
path = src/liblibc
10-
url = https://github.com/rust-lang/libc.git
118
[submodule "src/doc/nomicon"]
129
path = src/doc/nomicon
1310
url = https://github.com/rust-lang-nursery/nomicon.git
@@ -23,9 +20,6 @@
2320
[submodule "src/tools/rls"]
2421
path = src/tools/rls
2522
url = https://github.com/rust-lang-nursery/rls.git
26-
[submodule "src/libcompiler_builtins"]
27-
path = src/libcompiler_builtins
28-
url = https://github.com/rust-lang-nursery/compiler-builtins.git
2923
[submodule "src/tools/clippy"]
3024
path = src/tools/clippy
3125
url = https://github.com/rust-lang-nursery/rust-clippy.git
@@ -35,9 +29,6 @@
3529
[submodule "src/tools/miri"]
3630
path = src/tools/miri
3731
url = https://github.com/solson/miri.git
38-
[submodule "src/dlmalloc"]
39-
path = src/dlmalloc
40-
url = https://github.com/alexcrichton/dlmalloc-rs.git
4132
[submodule "src/doc/rust-by-example"]
4233
path = src/doc/rust-by-example
4334
url = https://github.com/rust-lang/rust-by-example.git
@@ -67,6 +58,3 @@
6758
[submodule "src/doc/edition-guide"]
6859
path = src/doc/edition-guide
6960
url = https://github.com/rust-lang-nursery/edition-guide
70-
[submodule "src/rust-sgx"]
71-
path = src/rust-sgx
72-
url = https://github.com/fortanix/rust-sgx

‎Cargo.lock

+47-38
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ dependencies = [
1515
name = "alloc"
1616
version = "0.0.0"
1717
dependencies = [
18-
"compiler_builtins 0.0.0",
18+
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
1919
"core 0.0.0",
20-
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
20+
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
2121
]
2222

2323
[[package]]
@@ -407,10 +407,11 @@ dependencies = [
407407

408408
[[package]]
409409
name = "compiler_builtins"
410-
version = "0.0.0"
410+
version = "0.1.2"
411+
source = "registry+https://github.com/rust-lang/crates.io-index"
411412
dependencies = [
412413
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
413-
"core 0.0.0",
414+
"rustc-std-workspace-core 1.0.0",
414415
]
415416

416417
[[package]]
@@ -456,7 +457,7 @@ dependencies = [
456457
name = "core"
457458
version = "0.0.0"
458459
dependencies = [
459-
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
460+
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
460461
]
461462

462463
[[package]]
@@ -658,10 +659,12 @@ dependencies = [
658659

659660
[[package]]
660661
name = "dlmalloc"
661-
version = "0.0.0"
662+
version = "0.1.1"
663+
source = "registry+https://github.com/rust-lang/crates.io-index"
662664
dependencies = [
663-
"compiler_builtins 0.0.0",
664-
"core 0.0.0",
665+
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
666+
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
667+
"rustc-std-workspace-core 1.0.0",
665668
]
666669

667670
[[package]]
@@ -814,10 +817,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
814817

815818
[[package]]
816819
name = "fortanix-sgx-abi"
817-
version = "0.0.0"
820+
version = "0.3.1"
821+
source = "registry+https://github.com/rust-lang/crates.io-index"
818822
dependencies = [
819-
"compiler_builtins 0.0.0",
820-
"core 0.0.0",
823+
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
824+
"rustc-std-workspace-core 1.0.0",
821825
]
822826

823827
[[package]]
@@ -1138,18 +1142,13 @@ name = "lazycell"
11381142
version = "1.2.1"
11391143
source = "registry+https://github.com/rust-lang/crates.io-index"
11401144

1141-
[[package]]
1142-
name = "libc"
1143-
version = "0.0.0"
1144-
dependencies = [
1145-
"compiler_builtins 0.0.0",
1146-
"core 0.0.0",
1147-
]
1148-
11491145
[[package]]
11501146
name = "libc"
11511147
version = "0.2.45"
11521148
source = "registry+https://github.com/rust-lang/crates.io-index"
1149+
dependencies = [
1150+
"rustc-std-workspace-core 1.0.0",
1151+
]
11531152

11541153
[[package]]
11551154
name = "libgit2-sys"
@@ -1520,19 +1519,19 @@ dependencies = [
15201519
name = "panic_abort"
15211520
version = "0.0.0"
15221521
dependencies = [
1523-
"compiler_builtins 0.0.0",
1522+
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
15241523
"core 0.0.0",
1525-
"libc 0.0.0",
1524+
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
15261525
]
15271526

15281527
[[package]]
15291528
name = "panic_unwind"
15301529
version = "0.0.0"
15311530
dependencies = [
15321531
"alloc 0.0.0",
1533-
"compiler_builtins 0.0.0",
1532+
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
15341533
"core 0.0.0",
1535-
"libc 0.0.0",
1534+
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
15361535
"unwind 0.0.0",
15371536
]
15381537

@@ -1683,7 +1682,7 @@ name = "profiler_builtins"
16831682
version = "0.0.0"
16841683
dependencies = [
16851684
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
1686-
"compiler_builtins 0.0.0",
1685+
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
16871686
"core 0.0.0",
16881687
]
16891688

@@ -1814,7 +1813,7 @@ name = "rand_chacha"
18141813
version = "0.1.0"
18151814
source = "registry+https://github.com/rust-lang/crates.io-index"
18161815
dependencies = [
1817-
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
1816+
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
18181817
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
18191818
]
18201819

@@ -1836,7 +1835,7 @@ name = "rand_hc"
18361835
version = "0.1.0"
18371836
source = "registry+https://github.com/rust-lang/crates.io-index"
18381837
dependencies = [
1839-
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
1838+
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
18401839
]
18411840

18421841
[[package]]
@@ -1861,7 +1860,7 @@ name = "rand_xorshift"
18611860
version = "0.1.0"
18621861
source = "registry+https://github.com/rust-lang/crates.io-index"
18631862
dependencies = [
1864-
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
1863+
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
18651864
]
18661865

18671866
[[package]]
@@ -2242,6 +2241,13 @@ name = "rustc-serialize"
22422241
version = "0.3.24"
22432242
source = "registry+https://github.com/rust-lang/crates.io-index"
22442243

2244+
[[package]]
2245+
name = "rustc-std-workspace-core"
2246+
version = "1.0.0"
2247+
dependencies = [
2248+
"core 0.0.0",
2249+
]
2250+
22452251
[[package]]
22462252
name = "rustc-workspace-hack"
22472253
version = "1.0.0"
@@ -2284,7 +2290,7 @@ dependencies = [
22842290
"alloc 0.0.0",
22852291
"build_helper 0.1.0",
22862292
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
2287-
"compiler_builtins 0.0.0",
2293+
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
22882294
"core 0.0.0",
22892295
]
22902296

@@ -2479,7 +2485,7 @@ dependencies = [
24792485
"alloc 0.0.0",
24802486
"build_helper 0.1.0",
24812487
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
2482-
"compiler_builtins 0.0.0",
2488+
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
24832489
"core 0.0.0",
24842490
]
24852491

@@ -2531,7 +2537,7 @@ dependencies = [
25312537
"alloc 0.0.0",
25322538
"build_helper 0.1.0",
25332539
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
2534-
"compiler_builtins 0.0.0",
2540+
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
25352541
"core 0.0.0",
25362542
]
25372543

@@ -2644,7 +2650,7 @@ dependencies = [
26442650
"alloc 0.0.0",
26452651
"build_helper 0.1.0",
26462652
"cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
2647-
"compiler_builtins 0.0.0",
2653+
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
26482654
"core 0.0.0",
26492655
]
26502656

@@ -2877,15 +2883,15 @@ dependencies = [
28772883
"alloc 0.0.0",
28782884
"build_helper 0.1.0",
28792885
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
2880-
"compiler_builtins 0.0.0",
2886+
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
28812887
"core 0.0.0",
2882-
"dlmalloc 0.0.0",
2883-
"fortanix-sgx-abi 0.0.0",
2884-
"libc 0.0.0",
2888+
"dlmalloc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
2889+
"fortanix-sgx-abi 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
2890+
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
28852891
"panic_abort 0.0.0",
28862892
"panic_unwind 0.0.0",
28872893
"profiler_builtins 0.0.0",
2888-
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
2894+
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
28892895
"rustc_asan 0.0.0",
28902896
"rustc_lsan 0.0.0",
28912897
"rustc_msan 0.0.0",
@@ -3217,9 +3223,9 @@ dependencies = [
32173223
name = "unwind"
32183224
version = "0.0.0"
32193225
dependencies = [
3220-
"compiler_builtins 0.0.0",
3226+
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
32213227
"core 0.0.0",
3222-
"libc 0.0.0",
3228+
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
32233229
]
32243230

32253231
[[package]]
@@ -3397,6 +3403,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
33973403
"checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc"
33983404
"checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007"
33993405
"checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2"
3406+
"checksum compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ad611263b9f31bdb66e66227d3b781600fd1e68d5deee29b23f5e2ac9cb4892"
34003407
"checksum compiletest_rs 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "89747fe073b7838343bd2c2445e7a7c2e0d415598f8925f0fa9205b9cdfc48cb"
34013408
"checksum core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e2640d6d0bf22e82bed1b73c6aef8d5dd31e5abe6666c57e6d45e2649f4f887"
34023409
"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
@@ -3418,6 +3425,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
34183425
"checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a"
34193426
"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
34203427
"checksum directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f"
3428+
"checksum dlmalloc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c46c65de42b063004b31c67a98abe071089b289ff0919c660ed7ff4f59317f8"
34213429
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
34223430
"checksum elasticlunr-rs 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a99a310cd1f9770e7bf8e48810c7bcbb0e078c8fb23a8c7bcf0da4c2bf61a455"
34233431
"checksum ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f56c93cc076508c549d9bb747f79aa9b4eb098be7b8cad8830c3137ef52d1e00"
@@ -3434,6 +3442,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
34343442
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
34353443
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
34363444
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
3445+
"checksum fortanix-sgx-abi 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "26105e20b4c3f7a319db1376b54ac9a46e5761e949405553375095d05a0cee4d"
34373446
"checksum fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213"
34383447
"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
34393448
"checksum fst 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d94485a00b1827b861dd9d1a2cc9764f9044d4c535514c0760a5a2012ef3399f"

0 commit comments

Comments
 (0)
Please sign in to comment.