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

Add aarch64-unknown-switch-libnx target #74567

Closed
wants to merge 38 commits into from

Conversation

leo60228
Copy link
Contributor

@leo60228 leo60228 commented Jul 20, 2020

This adds a target for Nintendo Switch homebrew using the devkitA64 toolchain. It can be built using the (disabled) CI Docker image.

Needs to be done before merge:

Non-blocking issues:

  • It'd be nice if we could use LLD, but I couldn't get it to work
  • Currently, DWARF info is stored in the romfs (filesystem embedded in applications). It'd be preferable to have it in .rodata (like how unwind information works), but this doesn't seem to be supported by GNU ld.
  • Linker arguments should be changed to target options when possible (I tried to do this in a reverted commit, but I inexplicably get an undefined instruction when starting the application)

I have an example program for this target at https://github.com/leo60228/libnx.rs.

Some discussion on this target can be found at https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/homebrew.20target.20bikeshedding.

@rust-highfive
Copy link
Collaborator

r? @dtolnay

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

@rust-highfive
Copy link
Collaborator

⚠️ Warning ⚠️

  • These commits modify submodules.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 20, 2020
@dtolnay
Copy link
Member

dtolnay commented Jul 20, 2020

This is going to require review from the compiler team.

r? @pnkfelix

@rust-highfive rust-highfive assigned pnkfelix and unassigned dtolnay Jul 20, 2020
@leo60228
Copy link
Contributor Author

Going through the Tier 3 target policy RFC:

  • Any new tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. - me
  • Tier 3 targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. - see Zulip topic linked above
  • The target must not introduce license incompatibilities. - as far as I know this is not the case
  • Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0). - ✔️
  • The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the new target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by src/tools/tidy/src/deps.rs in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements. - ✔️
  • If the target supports building host tools (such as rustc or cargo), those host tools must not depend on proprietary (non-FOSS) libraries, other than ordinary runtime libraries supplied by the platform and commonly used by other binaries built for the target. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3. - N/A
  • New targets should not require proprietary (non-FOSS) components to link a functional binary or library. - ✔️
  • Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for any target with a standard memory allocator, std for targets with an operating system), but may leave some code unimplemented!(), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions. - I've been either returning an error or using stubs instead of panicking, but that should be close enough?
  • The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running tests (even if they do not pass), the documentation must explain how to run tests for the target, using emulation if possible or dedicated hardware if necessary. - not sure where to put this, but the CI scripts should work
  • Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that suggests a block on the PR based on the target. (A PR author may choose to help with a tier 3 target, but is not required to.) - this shouldn't be the case
  • Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target. - well, I'll wait for CI to pass, but this should be the case
  • In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target. - no related targets are currently supported, but I've tried to be careful about this anyway (I know @jam1garner is working on another Switch target)

@leo60228
Copy link
Contributor Author

(I have a shallow clone of this repo, but GitHub doesn't support force pushes from shallow clones. However, GitHub does support doing a git reset --hard through their REST API, so I can reset to the common ancestor then do a normal push. However, this can't be done atomically, and if a PR branch has no new commits it'll be automatically closed.)

@leo60228
Copy link
Contributor Author

After thinking about it, I've decided that this is a better solution than emulating it using seek.

@bors

This comment has been minimized.

@leo60228
Copy link
Contributor Author

I'm switching over to aarch64-unknown-switch-libnx based on a discussion on the libnx IRC.

@leo60228 leo60228 changed the title Add aarch64-unknown-switch-devkita64 target Add aarch64-unknown-switch-libnx target Jul 21, 2020
@leo60228
Copy link
Contributor Author

Due to rust-lang/libc#1829 (comment), I'm marking this as ready for review.

@leo60228 leo60228 marked this pull request as ready for review July 22, 2020 00:24
@bors

This comment has been minimized.

@leo60228
Copy link
Contributor Author

Rebased. Note that libbacktrace will likely break very badly on this platform, but backtraces should Just Work\™ once #74682 is merged.

@leo60228
Copy link
Contributor Author

@JohnCSimon Done.

@leo60228 leo60228 reopened this Aug 11, 2020
@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 13, 2020
@leo60228
Copy link
Contributor Author

Is there any update on review of this PR?

@bors
Copy link
Contributor

bors commented Aug 24, 2020

☔ The latest upstream changes (presumably #75110) made this pull request unmergeable. Please resolve the merge conflicts.

@Dylan-DPC-zz
Copy link

@leo60228 if you can resolve the conflicts, I will get this reviewed as soon as possible

@jyn514 jyn514 added the O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state label Sep 15, 2020
@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 8, 2020
@leo60228
Copy link
Contributor Author

leo60228 commented Oct 9, 2020

Sorry, I've been kind of procrastinating working on Rust recently. I'll start working on rebasing in the next few days (I'm getting back to my desktop on Sunday).

@JohnTitor JohnTitor added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 15, 2020
@JohnCSimon JohnCSimon added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Nov 3, 2020
@JohnCSimon
Copy link
Member

Triage: @leo60228 - Thanks for your contribution, but this has sat idle for a few weeks, I'm closing this as inactive, please feel free to reopen if you want to continue this PR.

@JohnCSimon JohnCSimon closed this Nov 3, 2020
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jul 15, 2022
…ch, r=wesleywiser

Add Nintendo Switch as tier 3 target

[Relevant Zulip Discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Upstreaming.20Nintendo.20Switch.20Support/near/253445503)

This is the first step towards working on incrementally adding support for the Nintendo Switch. After this lands `@leo60228` and I will work on ensuring further work is cleared from a legal perspective before continuing on to work on an allocator and porting libstd.

The plan is to keep these changes small and incremental enough so as to not cause unneeded burden on reviewers by submitting a single large patch, as was felt to be the case last attempt at upstreaming (rust-lang#74567).

All this specific patch does is add the target itself without and std support, which has been tested on-device and is working as expected.

Designated Target Maintainers:
* `@leo60228`
* `@jam1garner`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.