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

Support building with "cargo" directly instead of "x.py" for development purposes #70999

Closed
wants to merge 13 commits into from

Conversation

luca-barbieri
Copy link
Contributor

This pull request allows to just use cargo in addition to x.py for rustc and libstd development.

This makes it much simpler for new contributors to contribute to rust since there is no need to learn how x.py and bootstrapping works, and makes incremental development faster because this new infrastructure does no bootstrapping at all.

To make it work, the user is supposed to install the latest nightly with rustup, and then make changes based on a checkout of the same git commit hash of that nightly: this allows to build a new rustc that works with the standard library from the nightly, and to build a new non-cfg(bootstrap) standard library with the compiler from the nightly.

To support this workflow, we check and warn in build.rs if the compiler and repository versions don't match, and we set the compiler release to the same one of the compiler used to build so that artifacts can be shared between them.

Summary of changes:

  • Several changes to make things build without the setup done by x.py
  • Centralization of code that reads CFG_ environment variables to rustc_session, so they can be set in the build.rs for rustc_session
  • build.rs code to detect the rustc version and warn if it is not the correct one, including suggestions on how to fix the issues

With these changes, this is currently working:

  • Running cargo check for single crates
  • Running cargo run in src/rustc and having a working compiler without any bootstrapping
  • Running cargo build in src/libstd, src/libcore or src/libtest
  • Testing by running __CARGO_TESTS_ONLY_SRC_ROOT=$(realpath $PWD/../..) cargo test -Z build-std --target x86_64-unknown-linux-gnu in src/libcore

What is not working and missing:

  • Testing libstd
  • Checking or building the whole workspace, even with the build-std incantation
  • No way to install the built artifacts, even though they work in place
  • No easy way to do a full bootstrap other than using x.py

Future work would be to document this, and modify cargo's std-aware code so that libstd can be tested and the special incantation is no longer needed to run libstd tests, and so that you can just build the whole workspace with "cargo build" and have it work as if the pieces were built independently.

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 10, 2020
@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-04-10T18:07:18.8333854Z ========================== Starting Command Output ===========================
2020-04-10T18:07:18.8336258Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/a64b6316-9517-48af-b81a-6e1f8db8be63.sh
2020-04-10T18:07:18.8336523Z 
2020-04-10T18:07:18.8340399Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-10T18:07:18.8361346Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70999/merge to s
2020-04-10T18:07:18.8365960Z Task         : Get sources
2020-04-10T18:07:18.8366262Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-10T18:07:18.8366571Z Version      : 1.0.0
2020-04-10T18:07:18.8366770Z Author       : Microsoft
---
2020-04-10T18:07:21.5692662Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-10T18:07:21.5750445Z ##[command]git config gc.auto 0
2020-04-10T18:07:21.5754606Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-10T18:07:21.5758674Z ##[command]git config --get-all http.proxy
2020-04-10T18:07:21.5767079Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/70999/merge:refs/remotes/pull/70999/merge
---
2020-04-10T18:11:17.6524223Z  ---> 3fc1b512c57b
2020-04-10T18:11:17.6524780Z Step 6/7 : ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
2020-04-10T18:11:17.6525265Z  ---> Using cache
2020-04-10T18:11:17.6525676Z  ---> 5ee4295733f4
2020-04-10T18:11:17.6527499Z Step 7/7 : ENV SCRIPT python2.7 ../x.py test src/tools/expand-yaml-anchors &&            python2.7 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu &&            python2.7 ../x.py build --stage 0 src/tools/build-manifest &&            python2.7 ../x.py test --stage 0 src/tools/compiletest &&            python2.7 ../x.py test src/tools/tidy &&            /scripts/validate-toolstate.sh
2020-04-10T18:11:17.6529201Z  ---> 3d07a0fa42fe
2020-04-10T18:11:17.6595110Z Successfully built 3d07a0fa42fe
2020-04-10T18:11:17.6628124Z Successfully tagged rust-ci:latest
2020-04-10T18:11:17.7328281Z Built container sha256:3d07a0fa42feb5754fc13bb2f7010ebe13e4b8b8cdbebed0c75d8da320c8c8ad
2020-04-10T18:11:17.7328281Z Built container sha256:3d07a0fa42feb5754fc13bb2f7010ebe13e4b8b8cdbebed0c75d8da320c8c8ad
2020-04-10T18:11:17.7342977Z Looks like docker image is the same as before, not uploading
2020-04-10T18:11:26.5810640Z [CI_JOB_NAME=mingw-check]
2020-04-10T18:11:26.6030404Z [CI_JOB_NAME=mingw-check]
2020-04-10T18:11:26.6064071Z == clock drift check ==
2020-04-10T18:11:26.6072828Z   local time: Fri Apr 10 18:11:26 UTC 2020
2020-04-10T18:11:26.9200101Z   network time: Fri, 10 Apr 2020 18:11:26 GMT
2020-04-10T18:11:26.9223493Z Starting sccache server...
2020-04-10T18:11:27.0028146Z configure: processing command line
2020-04-10T18:11:27.0028788Z configure: 
2020-04-10T18:11:27.0029798Z configure: rust.parallel-compiler := True
---
2020-04-10T18:14:27.7212137Z     Checking rustc_data_structures v0.0.0 (/checkout/src/librustc_data_structures)
2020-04-10T18:14:28.4999660Z error: unused extern crate
2020-04-10T18:14:28.5000444Z   --> src/librustc_data_structures/lib.rs:30:1
2020-04-10T18:14:28.5000943Z    |
2020-04-10T18:14:28.5001511Z 29 | / #[cfg(unix)]
2020-04-10T18:14:28.5002231Z 30 | | extern crate libc;
2020-04-10T18:14:28.5002969Z    | | ^^^^^^^^^^^^^^^^^-
2020-04-10T18:14:28.5004264Z    |                    help: remove it
2020-04-10T18:14:28.5004779Z    |
2020-04-10T18:14:28.5005364Z    = note: `-D unused-extern-crates` implied by `-D warnings`
2020-04-10T18:14:28.5005675Z 
2020-04-10T18:14:28.5005675Z 
2020-04-10T18:14:28.5039475Z error: aborting due to previous error
2020-04-10T18:14:28.5039716Z 
2020-04-10T18:14:28.5092468Z error: could not compile `rustc_data_structures`.
2020-04-10T18:14:28.5092734Z 
2020-04-10T18:14:28.5093125Z To learn more, run the command again with --verbose.
2020-04-10T18:14:28.5093677Z warning: build failed, waiting for other jobs to finish...
2020-04-10T18:14:37.7568053Z error: build failed
2020-04-10T18:14:37.7596457Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "2" "--release" "--color" "always" "--no-default-features" "--features" " llvm" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json-render-diagnostics"
2020-04-10T18:14:37.7610814Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap check
2020-04-10T18:14:37.7611498Z Build completed unsuccessfully in 0:03:10
2020-04-10T18:14:37.7659193Z == clock drift check ==
2020-04-10T18:14:37.7659193Z == clock drift check ==
2020-04-10T18:14:37.7682642Z   local time: Fri Apr 10 18:14:37 UTC 2020
2020-04-10T18:14:37.8581106Z   network time: Fri, 10 Apr 2020 18:14:37 GMT
2020-04-10T18:14:38.4476725Z 
2020-04-10T18:14:38.4476725Z 
2020-04-10T18:14:38.4537441Z ##[error]Bash exited with code '1'.
2020-04-10T18:14:38.4548705Z ##[section]Finishing: Run build
2020-04-10T18:14:38.4602172Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70999/merge to s
2020-04-10T18:14:38.4606575Z Task         : Get sources
2020-04-10T18:14:38.4606860Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-10T18:14:38.4607121Z Version      : 1.0.0
2020-04-10T18:14:38.4607342Z Author       : Microsoft
2020-04-10T18:14:38.4607342Z Author       : Microsoft
2020-04-10T18:14:38.4607634Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-10T18:14:38.4607978Z ==============================================================================
2020-04-10T18:14:38.7554585Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-10T18:14:38.7598525Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70999/merge to s
2020-04-10T18:14:38.7674474Z Cleaning up task key
2020-04-10T18:14:38.7675614Z Start cleaning up orphan processes.
2020-04-10T18:14:38.7894276Z Terminate orphan process: pid (4088) (python)
2020-04-10T18:14:38.8200022Z ##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@luca-barbieri luca-barbieri force-pushed the cargo_build branch 2 times, most recently from 340740b to bbdc4bf Compare April 10, 2020 18:42
@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-04-10T18:43:26.2414609Z ========================== Starting Command Output ===========================
2020-04-10T18:43:26.2418454Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/278bf842-fe9c-4af1-b1e7-e313ad1d7513.sh
2020-04-10T18:43:26.2419057Z 
2020-04-10T18:43:26.2424994Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-10T18:43:26.2447346Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70999/merge to s
2020-04-10T18:43:26.2450589Z Task         : Get sources
2020-04-10T18:43:26.2450897Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-10T18:43:26.2451150Z Version      : 1.0.0
2020-04-10T18:43:26.2451319Z Author       : Microsoft
---
2020-04-10T18:43:27.9167337Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-10T18:43:27.9683082Z ##[command]git config gc.auto 0
2020-04-10T18:43:27.9722065Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-10T18:43:27.9730037Z ##[command]git config --get-all http.proxy
2020-04-10T18:43:27.9743511Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/70999/merge:refs/remotes/pull/70999/merge
---
2020-04-10T18:46:53.7434523Z  ---> 3fc1b512c57b
2020-04-10T18:46:53.7434876Z Step 6/7 : ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
2020-04-10T18:46:53.7435351Z  ---> Using cache
2020-04-10T18:46:53.7435832Z  ---> 5ee4295733f4
2020-04-10T18:46:53.7437280Z Step 7/7 : ENV SCRIPT python2.7 ../x.py test src/tools/expand-yaml-anchors &&            python2.7 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu &&            python2.7 ../x.py build --stage 0 src/tools/build-manifest &&            python2.7 ../x.py test --stage 0 src/tools/compiletest &&            python2.7 ../x.py test src/tools/tidy &&            /scripts/validate-toolstate.sh
2020-04-10T18:46:53.7438936Z  ---> 3d07a0fa42fe
2020-04-10T18:46:53.7468862Z Successfully built 3d07a0fa42fe
2020-04-10T18:46:53.7492884Z Successfully tagged rust-ci:latest
2020-04-10T18:46:53.7765443Z Built container sha256:3d07a0fa42feb5754fc13bb2f7010ebe13e4b8b8cdbebed0c75d8da320c8c8ad
2020-04-10T18:46:53.7765443Z Built container sha256:3d07a0fa42feb5754fc13bb2f7010ebe13e4b8b8cdbebed0c75d8da320c8c8ad
2020-04-10T18:46:53.7783150Z Looks like docker image is the same as before, not uploading
2020-04-10T18:47:02.9924521Z [CI_JOB_NAME=mingw-check]
2020-04-10T18:47:02.9925367Z [CI_JOB_NAME=mingw-check]
2020-04-10T18:47:02.9925623Z == clock drift check ==
2020-04-10T18:47:02.9925922Z   local time: Fri Apr 10 18:47:02 UTC 2020
2020-04-10T18:47:02.9926229Z   network time: Fri, 10 Apr 2020 18:47:02 GMT
2020-04-10T18:47:02.9926719Z Starting sccache server...
2020-04-10T18:47:02.9926940Z configure: processing command line
2020-04-10T18:47:02.9927524Z configure: 
2020-04-10T18:47:02.9928000Z configure: rust.parallel-compiler := True
---
2020-04-10T18:47:31.8193626Z   Read-only file system (os error 30)
2020-04-10T18:47:31.8219384Z failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml
2020-04-10T18:47:31.8219890Z Build completed unsuccessfully in 0:00:29
2020-04-10T18:47:31.8265122Z == clock drift check ==
2020-04-10T18:47:31.8286236Z   local time: Fri Apr 10 18:47:31 UTC 2020
2020-04-10T18:47:31.9255087Z   network time: Fri, 10 Apr 2020 18:47:31 GMT
2020-04-10T18:47:39.8740117Z 
2020-04-10T18:47:39.8740117Z 
2020-04-10T18:47:39.8822479Z ##[error]Bash exited with code '1'.
2020-04-10T18:47:39.8838090Z ##[section]Finishing: Run build
2020-04-10T18:47:39.8887537Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70999/merge to s
2020-04-10T18:47:39.8893151Z Task         : Get sources
2020-04-10T18:47:39.8893513Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-10T18:47:39.8893854Z Version      : 1.0.0
2020-04-10T18:47:39.8894102Z Author       : Microsoft
2020-04-10T18:47:39.8894102Z Author       : Microsoft
2020-04-10T18:47:39.8894470Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-10T18:47:39.8894899Z ==============================================================================
2020-04-10T18:47:40.2533627Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-10T18:47:40.2583648Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70999/merge to s
2020-04-10T18:47:40.2674415Z Cleaning up task key
2020-04-10T18:47:40.2675655Z Start cleaning up orphan processes.
2020-04-10T18:47:40.2870988Z Terminate orphan process: pid (4064) (python)
2020-04-10T18:47:40.3018993Z ##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@luca-barbieri luca-barbieri force-pushed the cargo_build branch 3 times, most recently from c4fed25 to 98f6786 Compare April 10, 2020 19:35
@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-04-10T19:37:16.2415466Z ========================== Starting Command Output ===========================
2020-04-10T19:37:16.2418873Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/daa4ae0f-40ed-474d-808d-866003dcdc66.sh
2020-04-10T19:37:16.2419248Z 
2020-04-10T19:37:16.2423187Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-10T19:37:16.2440084Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70999/merge to s
2020-04-10T19:37:16.2443740Z Task         : Get sources
2020-04-10T19:37:16.2444070Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-10T19:37:16.2444374Z Version      : 1.0.0
2020-04-10T19:37:16.2444580Z Author       : Microsoft
---
2020-04-10T19:37:17.5308353Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-10T19:37:17.5314866Z ##[command]git config gc.auto 0
2020-04-10T19:37:17.5318996Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-10T19:37:17.5322839Z ##[command]git config --get-all http.proxy
2020-04-10T19:37:17.5330911Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/70999/merge:refs/remotes/pull/70999/merge
---
2020-04-10T19:39:58.9297512Z  ---> 78ad2f4d4aca
2020-04-10T19:39:58.9298631Z Step 6/7 : ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
2020-04-10T19:39:58.9304994Z  ---> Using cache
2020-04-10T19:39:58.9305432Z  ---> 4d2dc61c4d00
2020-04-10T19:39:58.9306681Z Step 7/7 : ENV SCRIPT python3 ../x.py test src/tools/expand-yaml-anchors &&            python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu &&            python3 ../x.py build --stage 0 src/tools/build-manifest &&            python3 ../x.py test --stage 0 src/tools/compiletest &&            python3 ../x.py test src/tools/tidy &&            /scripts/validate-toolstate.sh
2020-04-10T19:39:58.9312780Z  ---> 776b6266a8b7
2020-04-10T19:39:58.9407894Z Successfully built 776b6266a8b7
2020-04-10T19:39:59.5752142Z Successfully tagged rust-ci:latest
2020-04-10T19:39:59.5753590Z Built container sha256:776b6266a8b7d63e2d3c2b5a784dbf521184a904fb10bf818c6b5c7e1ab74d4a
2020-04-10T19:39:59.5753590Z Built container sha256:776b6266a8b7d63e2d3c2b5a784dbf521184a904fb10bf818c6b5c7e1ab74d4a
2020-04-10T19:39:59.5754618Z Looks like docker image is the same as before, not uploading
2020-04-10T19:40:06.1340752Z [CI_JOB_NAME=mingw-check]
2020-04-10T19:40:06.1574396Z [CI_JOB_NAME=mingw-check]
2020-04-10T19:40:06.1594411Z == clock drift check ==
2020-04-10T19:40:06.1600401Z   local time: Fri Apr 10 19:40:06 UTC 2020
2020-04-10T19:40:06.2828287Z   network time: Fri, 10 Apr 2020 19:40:06 GMT
2020-04-10T19:40:06.2853546Z Starting sccache server...
2020-04-10T19:40:06.3868068Z configure: processing command line
2020-04-10T19:40:06.3868831Z configure: 
2020-04-10T19:40:06.3870182Z configure: rust.parallel-compiler := True
---
2020-04-10T19:40:30.5916484Z   Read-only file system (os error 30)
2020-04-10T19:40:30.5937601Z failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml
2020-04-10T19:40:30.5938275Z Build completed unsuccessfully in 0:00:24
2020-04-10T19:40:30.6035476Z == clock drift check ==
2020-04-10T19:40:31.5848850Z   local time: Fri Apr 10 19:40:30 UTC 2020
2020-04-10T19:40:31.5849980Z   network time: Fri, 10 Apr 2020 19:40:30 GMT
2020-04-10T19:40:38.4664066Z 
2020-04-10T19:40:38.4664066Z 
2020-04-10T19:40:38.4723637Z ##[error]Bash exited with code '1'.
2020-04-10T19:40:38.4736083Z ##[section]Finishing: Run build
2020-04-10T19:40:38.4771177Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70999/merge to s
2020-04-10T19:40:38.4775790Z Task         : Get sources
2020-04-10T19:40:38.4776078Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-10T19:40:38.4776351Z Version      : 1.0.0
2020-04-10T19:40:38.4776555Z Author       : Microsoft
2020-04-10T19:40:38.4776555Z Author       : Microsoft
2020-04-10T19:40:38.4776845Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-10T19:40:38.4777179Z ==============================================================================
2020-04-10T19:40:38.7428062Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-10T19:40:38.7464621Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70999/merge to s
2020-04-10T19:40:38.7541127Z Cleaning up task key
2020-04-10T19:40:38.7542343Z Start cleaning up orphan processes.
2020-04-10T19:40:38.7699080Z Terminate orphan process: pid (3436) (python)
2020-04-10T19:40:38.7798448Z ##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

rustc_session exports it for other crates to avoid mismatching
crate versions.
Otherwise, the compiler can't actually compile anything.
The code was broken because it printed "llvm-config" instead of the
absolute path to the llvm-config executable, causing Cargo to always
rebuild librustc_llvm if using system LLVM.

Also, it's not the build system's job to rebuild when a system library
changes, so we simply don't emit "rerun-if-changed" if a path to LLVM
was not explicitly provided.
x.py sets it unconditionally, so want it for plain "cargo build"
librustc_session already has them, and the crates depend on it, so
they will be rebuilt anyway
If the sysroot does not exist, use the one from the toolchain used
to build rustc.
… on beta

This provides helpful messages when using `cargo build` and sets
--cfg=bootstrap when using a beta toolchain.
@Mark-Simulacrum
Copy link
Member

This is amazing! Thank you so much for getting this off the ground :)

I've pulled some of the commits here into a separate PR (#71029) and approved that, just to reduce the amount of commits in this PR. Those I'm prepared to see land immediately, I think they're required for progress here anyway.

I'm going to need to think a bit about the overall design, though. I'm not quite sure yet whether I want to split and somewhat duplicate code that's currently in bootstrap (or just doesn't really exist). One thought I had is that we should probable come up with some basic "workflows" -- e.g., I'm not quite sure what users would expect with a cargo-native build system.

I also think that to start we should just focus on supporting building and testing std, not rustc; rustc is more complicated (needs a bunch of environment variables set, has sysroot management to deal with, can't easily run without a std built by it)...

With that in mind, I think most of this PR I'm not prepared to land immediately, given that it introduces a lot of code that is either duplicating other code or adding code to manage some process, and I suspect that may be avoidable, so would like to try to avoid it first. I'm primarily concerned that we don't end up with divergent code between the environment variables that bootstrap sets and what the "cargo build" workflow wants, in an effort to avoid situations where we end up with that leading to e.g. CI failing but locally thing seeming to work.

I think the first thing we should get working is the following, in order:

  • cargo +$master_sha build --manifest-path src/libtest/Cargo.toml
  • cargo +$master_sha test --manifest-path src/libtest/Cargo.toml
  • "I want to use the std I edited somewhere else," which should not require rebuilding the compiler.

I believe that the first already mostly works on master and with the panic-unwind feature entirely works; certainly after #71029 it works fine. We should probably document that as soon as that lands in rustc-dev-guide, as it seems a major improvement for folks hacking on std with just the need for check/build builds, even if tests don't work quite yet.

The second will be more difficult. tests for core/alloc/std I believe all depend on rand, which has not been prepared for a in-tree world with rustc-dep-of-std. That means that they cannot build successfully unless you do what you did with -Zbuild-std.

That's a wall of text for sure, but hopefully I'm not too unclear. Feel free to ask if I should clarify my thoughts or if you disagree.

@Mark-Simulacrum
Copy link
Member

In terms of altering rustc -- I think one thought I've had is that we can likely move things from bootstrap's build parts into build.rs in many cases, especially with a helper crate that things can depend on which will parse config.toml to the extent needed (basically build_helper I think).

Another thought I had is that we might be able to build sysroots via a build.rs in a crate that has a build-dependency on src/rustc/Cargo.toml, which can the install the rustc and relevant libraries into the sysroot.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 12, 2020
…-Simulacrum

Partial work on building with Cargo

This cherry picks the commits I'm directly approving from rust-lang#70999, I want to land them so that that PR is smaller.
@bors
Copy link
Contributor

bors commented Apr 12, 2020

☔ The latest upstream changes (presumably #71059) made this pull request unmergeable. Please resolve the merge conflicts.

@joelpalmer joelpalmer added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 21, 2020
@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 21, 2020
@Dylan-DPC-zz
Copy link

@luca-barbieri if you can rebase this, we can get it merged

@joelpalmer joelpalmer added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 30, 2020
@joelpalmer
Copy link

Ping from Triage: Closing due to inactivity. @luca-barbieri please reopen with conflicts resolved. Thanks for the PR.

@joelpalmer joelpalmer closed this Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants