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

Set LIBC_CHECK_CFG=1 when building Rust code in bootstrap #108898

Merged
merged 1 commit into from
Mar 9, 2023

Conversation

pietroalbini
Copy link
Member

Downstream forks of the Rust compiler might want to use a custom libc to add support for targets that are not yet available upstream. Adding a patch to replace libc with a custom one would cause compilation errors though, because Cargo would interpret the custom libc as part of the workspace, and apply the check-cfg lints on it.

Since rust-lang/libc#3037, the libc build script emits check-cfg flags only when the LIBC_CHECK_CFG environment variable is set, so this PR allows the use of custom libcs.

@rustbot
Copy link
Collaborator

rustbot commented Mar 8, 2023

r? @Mark-Simulacrum

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Mar 8, 2023
@Mark-Simulacrum
Copy link
Member

Adding a patch to replace libc with a custom one would cause compilation errors though, because Cargo would interpret the custom libc as part of the workspace, and apply the check-cfg lints on it.

This is interesting to me - maybe a missing feature in Cargo? It seems common that you may want to patch a dependency (e.g., to switch to an as-yet unreleased version) without putting it into the workspace. Might be worth a bug report upstream.

@bors r+ for this in the meantime though.

@bors
Copy link
Contributor

bors commented Mar 8, 2023

📌 Commit ead8b96 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 8, 2023
@pietroalbini
Copy link
Member Author

This is interesting to me - maybe a missing feature in Cargo? It seems common that you may want to patch a dependency (e.g., to switch to an as-yet unreleased version) without putting it into the workspace. Might be worth a bug report upstream.

Whoops, "part of the workspace" was the wrong way to say it. The problem is that it's not recognized as an external dependency, so --cap-lints is not applied anymore.

@Mark-Simulacrum
Copy link
Member

Sure, but I guess my point is that I think it should be possible to patch/vendor sources without treating things as internal. For example, building from a source tarball with vendored sources should work without needing this. So I think there's still a disconnect of some kind here.

@petrochenkov
Copy link
Contributor

I think it should be possible to patch/vendor sources without treating things as internal.

IIRC, overriding a dependency as git = 'my_path' instead of path = 'my_path' solves the issue.
(Maybe the path required file:// in the first case, but I don't remember exactly.)

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 9, 2023
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#108754 (Retry `pred_known_to_hold_modulo_regions` with fulfillment if ambiguous)
 - rust-lang#108759 (1.41.1 supported 32-bit Apple targets)
 - rust-lang#108839 (Canonicalize root var when making response from new solver)
 - rust-lang#108856 (Remove DropAndReplace terminator)
 - rust-lang#108882 (Tweak E0740)
 - rust-lang#108898 (Set `LIBC_CHECK_CFG=1` when building Rust code in bootstrap)
 - rust-lang#108911 (Improve rustdoc-gui/tester.js code a bit)
 - rust-lang#108916 (Remove an unused return value in `rustc_hir_typeck`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2ebb5b1 into rust-lang:master Mar 9, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 9, 2023
@pietroalbini pietroalbini deleted the pa-libc-check-cfg branch March 9, 2023 15:20
flip1995 pushed a commit to flip1995/rust that referenced this pull request Mar 10, 2023
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#108754 (Retry `pred_known_to_hold_modulo_regions` with fulfillment if ambiguous)
 - rust-lang#108759 (1.41.1 supported 32-bit Apple targets)
 - rust-lang#108839 (Canonicalize root var when making response from new solver)
 - rust-lang#108856 (Remove DropAndReplace terminator)
 - rust-lang#108882 (Tweak E0740)
 - rust-lang#108898 (Set `LIBC_CHECK_CFG=1` when building Rust code in bootstrap)
 - rust-lang#108911 (Improve rustdoc-gui/tester.js code a bit)
 - rust-lang#108916 (Remove an unused return value in `rustc_hir_typeck`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants