Skip to content

Commit

Permalink
Rollup merge of #82360 - osa1:issue82317, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
config.toml parsing error improvements

Improve error messages for musl-libdir and wasi-root keys. Previously
the parser would panic with `unwrap()`. Now it prints

      Target "wasm32-wasi" does not have a "wasi-root" key

(and similar for the `musl-libdir` field, which is used in target that
use musl)

Also update comments around wasi-root field to make it clear that the
field is only valid in wasm32-wasi target and needs to be moved to a
`[target.wasm32-wasi]` section to be valid.

Fixes #82317

---

r? `@Mark-Simulacrum`
  • Loading branch information
Joshua Nelson authored Mar 1, 2021
2 parents 57c568a + 81cfa98 commit c8825d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,9 @@ changelog-seen = 2
# The full path to the musl libdir.
#musl-libdir = musl-root/lib

# The root location of the `wasm32-wasi` sysroot.
# The root location of the `wasm32-wasi` sysroot. Only used for the
# `wasm32-wasi` target. If you are building wasm32-wasi target, make sure to
# create a `[target.wasm32-wasi]` section and move this field there.
#wasi-root = "..."

# Used in testing for configuring where the QEMU images are located, you
Expand Down
11 changes: 9 additions & 2 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ fn copy_self_contained_objects(
// To do that we have to distribute musl startup objects as a part of Rust toolchain
// and link with them manually in the self-contained mode.
if target.contains("musl") {
let srcdir = builder.musl_libdir(target).unwrap();
let srcdir = builder.musl_libdir(target).unwrap_or_else(|| {
panic!("Target {:?} does not have a \"musl-libdir\" key", target.triple)
});
for &obj in &["crt1.o", "Scrt1.o", "rcrt1.o", "crti.o", "crtn.o"] {
copy_and_stamp(
builder,
Expand All @@ -196,7 +198,12 @@ fn copy_self_contained_objects(
target_deps.push((target, DependencyType::TargetSelfContained));
}
} else if target.ends_with("-wasi") {
let srcdir = builder.wasi_root(target).unwrap().join("lib/wasm32-wasi");
let srcdir = builder
.wasi_root(target)
.unwrap_or_else(|| {
panic!("Target {:?} does not have a \"wasi-root\" key", target.triple)
})
.join("lib/wasm32-wasi");
for &obj in &["crt1.o", "crt1-reactor.o"] {
copy_and_stamp(
builder,
Expand Down

0 comments on commit c8825d0

Please sign in to comment.