Skip to content

Commit 30a4d2b

Browse files
Urgaujyn514
authored andcommitted
Add instructions to fix build errors in std after adding a new target
1 parent e5e5a9b commit 30a4d2b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/building/new-target.md

+16
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,22 @@ will then add a corresponding file for your new target containing a
7676

7777
Look for existing targets to use as examples.
7878

79+
After adding your target to the `rustc_target` crate you may want to add
80+
`core`, `std`, ... with support for your new target. In that case you will
81+
probably need access to some `target_*` cfg. Unfortunately when building with
82+
stage0 (the beta compiler), you'll get an error that the target cfg is
83+
unexpected because stage0 doesn't know about the new target specification and
84+
we pass `--check-cfg` in order to tell it to check.
85+
86+
To fix the errors you will need to manually add the unexpected value to the
87+
`EXTRA_CHECK_CFGS` list in `src/bootstrap/lib.rs`. Here is an example for
88+
adding `NEW_TARGET_OS` as `target_os`:
89+
```diff
90+
- (Some(Mode::Std), "target_os", Some(&["watchos"])),
91+
+ // #[cfg(bootstrap)] NEW_TARGET_OS
92+
+ (Some(Mode::Std), "target_os", Some(&["watchos", "NEW_TARGET_OS"])),
93+
```
94+
7995
## Patching crates
8096

8197
You may need to make changes to crates that the compiler depends on,

0 commit comments

Comments
 (0)