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

Update the target compiler version #6

Closed
wants to merge 9 commits into from
Closed

Conversation

yvt
Copy link
Member

@yvt yvt commented Apr 23, 2022

No description provided.

@yvt yvt self-assigned this Apr 23, 2022
@yvt
Copy link
Member Author

yvt commented Apr 23, 2022

Build Failures

error: unconstrained generic constant
    --> src/r3_port_riscv/src/threading/imp.rs:1392:17
     |
1392 |                 PRIV = sym <<Traits as PortInstance>::Priv as csr::Num>::value,
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: try adding a `where` bound using this expression: `where [(); PRIV = sym <<Traits as PortInstance>::Priv as csr::Num>::value]:`
##[group]Run actions-rs/cargo@v1
with:
  command: test
  args: --workspace --
  use-cross: false
env:
  RUSTFLAGS: -A incomplete_features
  RUST_LOG: debug
##[endgroup]
[command]/home/runner/.cargo/bin/cargo test --workspace --
  ⋮
Error: internal compiler error: compiler/rustc_borrowck/src/universal_regions.rs:807:36: cannot convert `ReErased` to a region vid
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/879aff385a5fe0af78f3d45fd2f0b8762934e41e/compiler/rustc_errors/src/lib.rs:1313:9
stack backtrace:
   0:     0x7f742b5c69ed - std::backtrace_rs::backtrace::libunwind::trace::h7e24f1b268baded8
                               at /rustc/879aff385a5fe0af78f3d45fd2f0b8762934e41e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f742b5c69ed - std::backtrace_rs::backtrace::trace_unsynchronized::h4e406aaf9bfb8b43
                               at /rustc/879aff385a5fe0af78f3d45fd2f0b8762934e41e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f742b5c69ed - std::sys_common::backtrace::_print_fmt::hb14220ee1c3384af
                               at /rustc/879aff385a5fe0af78f3d45fd2f0b8762934e41e/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f742b5c69ed - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h79150e492b796ed8
                               at /rustc/879aff385a5fe0af78f3d45fd2f0b8762934e41e/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f742b62212c - core::fmt::write::h98b7856592a6c7ad
                               at /rustc/879aff385a5fe0af78f3d45fd2f0b8762934e41e/library/core/src/fmt/mod.rs:1194:17
   5:     0x7f742b5b80e1 - std::io::Write::write_fmt::h4cd1fd92935cd0a6
                               at /rustc/879aff385a5fe0af78f3d45fd2f0b8762934e41e/library/std/src/io/mod.rs:1655:15
   6:     0x7f742b5c9705 - std::sys_common::backtrace::_print::h3c1099b189a98d61
                               at /rustc/879aff385a5fe0af78f3d45fd2f0b8762934e41e/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f742b5c9705 - std::sys_common::backtrace::print::h3e18ac9c72fc07b8
                               at /rustc/879aff385a5fe0af78f3d45fd2f0b8762934e41e/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f742b5c9705 - std::panicking::default_hook::{{closure}}::hf0e1b39451f40a60
                               at /rustc/879aff385a5fe0af78f3d45fd2f0b8762934e41e/library/std/src/panicking.rs:295:22
   9:     0x7f742b5c9379 - std::panicking::default_hook::h629a27b071294339
                               at /rustc/879aff385a5fe0af78f3d45fd2f0b8762934e41e/library/std/src/panicking.rs:314:9
 ⋮
query stack during panic:
#0 [mir_borrowck] borrow-checking `sym::tests::<impl at src/r3_portkit/src/sym.rs:173:5: 180:6>::p_var::{constant#1}`
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `sym::tests::<impl at src/r3_portkit/src/sym.rs:173:5: 180:6>::p_var::{constant#1}`
#2 [mir_for_ctfe] caching mir of `sym::tests::<impl at src/r3_portkit/src/sym.rs:173:5: 180:6>::p_var::{constant#1}` for CTFE
#3 [eval_to_allocation_raw] const-evaluating + checking `sym::tests::<impl at src/r3_portkit/src/sym.rs:173:5: 180:6>::p_var::{constant#1}`
#4 [eval_to_const_value_raw] simplifying constant for the type system `sym::tests::<impl at src/r3_portkit/src/sym.rs:173:5: 180:6>::p_var::{constant#1}`  |  = note: this failure-note originates in the macro `sym_static` (in Nightly builds, run with -Z macro-backtrace for more info)

#5 [typeck] type-checking `sym::tests::<impl at src/r3_portkit/src/sym.rs:173:5: 180:6>::p_var`
#6 [typeck_item_bodies] type-checking all item bodies
#7 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `r3_portkit`
Error: warning: build failed, waiting for other jobs to finish...
Error: The process '/home/runner/.cargo/bin/cargo' failed with exit code 101

yvt added 3 commits May 14, 2022 22:11
It seems that [rust-lang/rust#96736][1] introduced checks for these
missing bounds, resulting in the following compilation error:

     error[E0277]: expected a `FnOnce<(Output,)>` closure, found `Mapper`
         --> src/r3_core/src/bind.rs:1360:5
          |
     1360 |     move || (mapper)(inner_bound_fn())
          |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(Output,)>` closure, found `Mapper`
          |
     note: required by a bound in `map_bind_inner`
         --> src/r3_core/src/bind.rs:1358:13
          |
     1352 | const fn map_bind_inner<InnerBoundFn, Output, Mapper, NewOutput>(
          |          -------------- required by a bound in this
     ...
     1358 |     Mapper: FnOnce(Output) -> NewOutput + Copy + Send + 'static,
          |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map_bind_inner`
     help: consider further restricting this bound
          |
     1349 |     Mapper: Copy + Send + 'static + core::ops::FnOnce<(Output,)>,
          |                                   ++++++++++++++++++++++++++++++

[1]: rust-lang/rust#96736
@yvt yvt force-pushed the ⬆️-nightly-2022-04-21 branch 4 times, most recently from 8597abc to 2addec3 Compare May 23, 2022 14:49
yvt added 3 commits May 24, 2022 01:23
Fixes linker errors in an application that is linked to `r3_port_riscv`
and does not use the `riscv-rt`-compatible startup routine provided by
`r3_port_riscv::use_rt!`.

Rust implements `rlib`s as static libraries (archives). Linkers treat
archives differently from object files: all object files participate in
linking, while archives will only participate in linking if they can
satisfy at least one undefined reference (version scripts don't count).
This means that in an application that does not use `use_rt!`,
`libriscv_rt*.rlib` does not participate in linking at all. This
behavior also causes `#[no_mangle]` and `#[used]` items to be ignored by
the linker (`KEEP` in linker scripts can't keep them either), leading to
a long-standing bug in Rust ([rust-lang/rust#47384][2]).

The situation changed with the merge of [rust-lang/rust#95604][1]. To
fix [rust-lang/rust#47384][2], this PR introduced a synthetic object
file containing references to all symbols pertaining to `#[no_mangle]`
and `#[used]` items. `libriscv_rt*.rlib` now participates in linking,
but the expectation is that `--gc-sections` will remove unused items in
the end, unless they are explicitly retained by `KEEP` in linker scripts
or other means.

This change unexpectedly caused breakage in the tests for `qemu_sifive_u
_s_rv(64,32)` targets, which use a custom startup routine instead of
`use_rt!`. For some reason, the linker didn't respect `--gc-sections`
for some items from `libriscv_rt*.rlib` and decided to include them in
the output binary. These items reference symbols that are defined by
the `riscv-rt` linker script, which isn't used by `qemu_sifive_u_s_
rv(64,32)` targets, hence the linker error.

The thing is, `riscv-rt` outputs these items in the `.init` section[3],
which is one of the section names hard-coded in LLD[4] to be excluded
from `--gc-sections`. As a result, these items were considered for
inclusion despite being referenced from nowhere.

This commit works around this problem by making `r3_port_riscv`'s
`riscv-rt` dependency optional, ensuring that `riscv-rt` participates
in linking only if needed by the application.

P.S. An exclamation mark (`!`) in the commit headline will be used to
indicate breaking changes from now on, as per [Conventional Commits
1.0.0][5].

[1]: rust-lang/rust#95604
[2]: rust-lang/rust#47384
[3]: https://github.com/rust-embedded/riscv-rt/blob/7de3d2744a465ad723519c04f13c56664e138cb9/asm.S#L20
[4]: https://github.com/llvm/llvm-project/blob/b86440ecde5c1dec5b898a3f1bc08ab9853d5ed9/lld/ELF/MarkLive.cpp#L183
[5]: https://www.conventionalcommits.org/en/v1.0.0/
This feature, which covers the `const fn` version of `MaybeUninit::
array_assume_init`, was added by [rust-lang/rust#96099][1].

[1]: rust-lang/rust#96099
@yvt yvt force-pushed the ⬆️-nightly-2022-04-21 branch from 2addec3 to cf7234e Compare May 24, 2022 00:31
@yvt
Copy link
Member Author

yvt commented May 24, 2022

Merged in 0393784

@yvt yvt closed this May 24, 2022
@yvt yvt deleted the ⬆️-nightly-2022-04-21 branch May 24, 2022 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant