{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/56092","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/56092/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/56092/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/56092/events","html_url":"https://github.com/rust-lang/rust/pull/56092","id":382520790,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMyMjA2NjQ4","number":56092,"title":"std: Depend directly on crates.io crates","user":{"login":"alexcrichton","id":64996,"node_id":"MDQ6VXNlcjY0OTk2","avatar_url":"https://avatars1.githubusercontent.com/u/64996?v=4","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"labels":[{"id":583426710,"node_id":"MDU6TGFiZWw1ODM0MjY3MTA=","url":"https://api.github.com/repos/rust-lang/rust/labels/S-waiting-on-review","name":"S-waiting-on-review","color":"d3dddd","default":false}],"state":"open","locked":false,"assignee":{"login":"Mark-Simulacrum","id":5047365,"node_id":"MDQ6VXNlcjUwNDczNjU=","avatar_url":"https://avatars0.githubusercontent.com/u/5047365?v=4","gravatar_id":"","url":"https://api.github.com/users/Mark-Simulacrum","html_url":"https://github.com/Mark-Simulacrum","followers_url":"https://api.github.com/users/Mark-Simulacrum/followers","following_url":"https://api.github.com/users/Mark-Simulacrum/following{/other_user}","gists_url":"https://api.github.com/users/Mark-Simulacrum/gists{/gist_id}","starred_url":"https://api.github.com/users/Mark-Simulacrum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mark-Simulacrum/subscriptions","organizations_url":"https://api.github.com/users/Mark-Simulacrum/orgs","repos_url":"https://api.github.com/users/Mark-Simulacrum/repos","events_url":"https://api.github.com/users/Mark-Simulacrum/events{/privacy}","received_events_url":"https://api.github.com/users/Mark-Simulacrum/received_events","type":"User","site_admin":false},"assignees":[{"login":"Mark-Simulacrum","id":5047365,"node_id":"MDQ6VXNlcjUwNDczNjU=","avatar_url":"https://avatars0.githubusercontent.com/u/5047365?v=4","gravatar_id":"","url":"https://api.github.com/users/Mark-Simulacrum","html_url":"https://github.com/Mark-Simulacrum","followers_url":"https://api.github.com/users/Mark-Simulacrum/followers","following_url":"https://api.github.com/users/Mark-Simulacrum/following{/other_user}","gists_url":"https://api.github.com/users/Mark-Simulacrum/gists{/gist_id}","starred_url":"https://api.github.com/users/Mark-Simulacrum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mark-Simulacrum/subscriptions","organizations_url":"https://api.github.com/users/Mark-Simulacrum/orgs","repos_url":"https://api.github.com/users/Mark-Simulacrum/repos","events_url":"https://api.github.com/users/Mark-Simulacrum/events{/privacy}","received_events_url":"https://api.github.com/users/Mark-Simulacrum/received_events","type":"User","site_admin":false}],"milestone":null,"comments":57,"created_at":"2018-11-20T06:36:01Z","updated_at":"2018-12-09T03:10:19Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/56092","html_url":"https://github.com/rust-lang/rust/pull/56092","diff_url":"https://github.com/rust-lang/rust/pull/56092.diff","patch_url":"https://github.com/rust-lang/rust/pull/56092.patch"},"body":"Ever since we added a Cargo-based build system for the compiler the\r\nstandard library has always been a little special, it's never been able\r\nto depend on crates.io crates for runtime dependencies. This has been a\r\nresult of various limitations, namely that Cargo doesn't understand that\r\ncrates from crates.io depend on libcore, so Cargo tries to build crates\r\nbefore libcore is finished.\r\n\r\nI had an idea this afternoon, however, which lifts the strategy\r\nfrom #52919 to directly depend on crates.io crates from the standard\r\nlibrary. After all is said and done this removes a whopping three\r\nsubmodules that we need to manage!\r\n\r\nThe basic idea here is that for any crate `std` depends on it adds an\r\n*optional* dependency on an empty crate on crates.io, in this case named\r\n`rustc-std-workspace-core`. This crate is overridden via `[patch]` in\r\nthis repository to point to a local crate we write, and *that* has a\r\n`path` dependency on libcore.\r\n\r\nNote that all `no_std` crates also depend on `compiler_builtins`, but if\r\nwe're not using submodules we can publish `compiler_builtins` to\r\ncrates.io and all crates can depend on it anyway! The basic strategy\r\nthen looks like:\r\n\r\n* The standard library (or some transitive dep) decides to depend on a\r\n  crate `foo`.\r\n* The standard library adds\r\n\r\n  ```toml\r\n  [dependencies]\r\n  foo = { version = \"0.1\", features = ['rustc-dep-of-std'] }\r\n  ```\r\n* The crate `foo` has an optional dependency on `rustc-std-workspace-core`\r\n* The crate `foo` has an optional dependency on `compiler_builtins`\r\n* The crate `foo` has a feature `rustc-dep-of-std` which activates these\r\n  crates and any other necessary infrastructure in the crate.\r\n\r\nA sample commit for `dlmalloc` [turns out to be quite simple][commit].\r\nAfter that all `no_std` crates should largely build \"as is\" and still be\r\npublishable on crates.io! Notably they should be able to continue to use\r\nstable Rust if necessary, since the `rename-dependency` feature of Cargo\r\nis soon stabilizing.\r\n\r\nAs a proof of concept, this commit removes the `dlmalloc`,\r\n`libcompiler_builtins`, and `libc` submodules from this repository. Long\r\nthorns in our side these are now gone for good and we can directly\r\ndepend on crates.io! It's hoped that in the long term we can bring in\r\nother crates as necessary, but for now this is largely intended to\r\nsimply make it easier to manage these crates and remove submodules.\r\n\r\nThis should be a transparent non-breaking change for all users, but one\r\npossible stickler is that this almost for sure breaks out-of-tree\r\n`std`-building tools like `xargo` and `cargo-xbuild`. I think it should\r\nbe relatively easy to get them working, however, as all that's needed is\r\nan entry in the `[patch]` section used to build the standard library.\r\nHopefully we can work with these tools to solve this problem!\r\n\r\n[commit]: https://github.com/alexcrichton/dlmalloc-rs/commit/28ee12db813a3b650a7c25d1c36d2c17dcb88ae3"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/445507194","html_url":"https://github.com/rust-lang/rust/pull/56092#issuecomment-445507194","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/56092","id":445507194,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NTUwNzE5NA==","user":{"login":"bors","id":3372342,"node_id":"MDQ6VXNlcjMzNzIzNDI=","avatar_url":"https://avatars2.githubusercontent.com/u/3372342?v=4","gravatar_id":"","url":"https://api.github.com/users/bors","html_url":"https://github.com/bors","followers_url":"https://api.github.com/users/bors/followers","following_url":"https://api.github.com/users/bors/following{/other_user}","gists_url":"https://api.github.com/users/bors/gists{/gist_id}","starred_url":"https://api.github.com/users/bors/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bors/subscriptions","organizations_url":"https://api.github.com/users/bors/orgs","repos_url":"https://api.github.com/users/bors/repos","events_url":"https://api.github.com/users/bors/events{/privacy}","received_events_url":"https://api.github.com/users/bors/received_events","type":"User","site_admin":false},"created_at":"2018-12-09T03:10:19Z","updated_at":"2018-12-09T03:10:19Z","author_association":"CONTRIBUTOR","body":":pushpin: Commit ed19253c062085b2cdbb56c1354703882ab4a177 has been approved by `Mark-Simulacrum`\n\n<!-- @bors r=Mark-Simulacrum ed19253c062085b2cdbb56c1354703882ab4a177 -->"}}
{"actor":{"display_login":"bors"}}