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
Re-introduce riscv64 support. #7
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sunfishcode
force-pushed
the
sunfishcode/riscv64
branch
2 times, most recently
from
September 10, 2021 22:30
c2f1b2b
to
448c6fb
Compare
The failure appears due to riscv64 using function-sections by default, which means that c-scape's trick for replacing libc functions doesn't work. |
sunfishcode
added a commit
that referenced
this pull request
Sep 13, 2021
Redesign how mustang ensures its libraries are linked in, to be somewhat more robust in the face of various kinds of optimizations. Use explicit symbols to pull in individual modules. This also makes it easier to split more c-scape functionality into separate modules. - Instead of having users declare `extern crate mustang`, have them invoke a macro, `mustang::can_compile_this!();`. - Don't declare c-scape functions as `pub`. Most code should use the `libc` crate declarations; `c-scape` uses `extern "C"` to intercept those at link time. - Put `extern "C"` functions in a named section; this overrides -ffunction-sections and puts all the functions in the same section, so that the linker doesn't DCE individual functions before they have a chance to intercept libc calls. - Similarly, add `#[inline(never)]` so that these functions aren't inlined, which can result in symbols being removed if an optimizer believes it has seen all of their uses. This helps with #7, though is not the only thing needed.
Merged
sunfishcode
added a commit
that referenced
this pull request
Sep 14, 2021
Redesign how mustang ensures its libraries are linked in, to be somewhat more robust in the face of various kinds of optimizations. Use explicit symbols to pull in individual modules. This also makes it easier to split more c-scape functionality into separate modules. - Instead of having users declare `extern crate mustang`, have them invoke a macro, `mustang::can_compile_this!();`. - Don't declare c-scape functions as `pub`. Most code should use the `libc` crate declarations; `c-scape` uses `extern "C"` to intercept those at link time. - Put `extern "C"` functions in a named section; this overrides -ffunction-sections and puts all the functions in the same section, so that the linker doesn't DCE individual functions before they have a chance to intercept libc calls. - Similarly, add `#[inline(never)]` so that these functions aren't inlined, which can result in symbols being removed if an optimizer believes it has seen all of their uses. This helps with #7, though is not the only thing needed.
Closed
sunfishcode
force-pushed
the
sunfishcode/riscv64
branch
from
September 15, 2021 18:41
448c6fb
to
03977af
Compare
Factoring these out into separate files appears to be insufficient to force them to all be linked in, replacing libc, so pull them all into a single module.
The `unwind` crate appears to work well for this purpose, even on panics with RUST_BACKTRACE=full. This uses the `fde-phdr-dl` backend, which uses `dl_iterate_phdr`, so implement `dl_iterate_phdr`. Fixes #27.
Unwind doesn't support 32-bit x86 yet, so drop it for now.
It's used by `init_have_lse_atomics` in libgcc/compiler-rt.
This has a better chance of allowing a user to open the file reliably.
sunfishcode
force-pushed
the
sunfishcode/riscv64
branch
5 times, most recently
from
October 6, 2021 01:23
4a01b82
to
80968f5
Compare
On RISC-V, the thread pointer is offset by 0x800 from the base of the TLS data, so introduce a `TLS_OFFSET` constant to make this adjustment.
sunfishcode
force-pushed
the
sunfishcode/riscv64
branch
from
October 6, 2021 18:26
80968f5
to
4883bf4
Compare
32-bit ARM is not yet supported by `unwinding`, but everything else works. Fixes #17.
Temporarily disable unwinding until the changes in gimli needed to support unwinding on aarch64 and riscv64 are available in a release. This allows us to avoid the `[patch.crates-io]` lines in Cargo.toml.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.