Skip to content

Add DevkitPPC support #1851

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

Merged
merged 1 commit into from
Aug 6, 2020
Merged

Add DevkitPPC support #1851

merged 1 commit into from
Aug 6, 2020

Conversation

DarkKirb
Copy link

@DarkKirb DarkKirb commented Jul 29, 2020

DevkitPPC is the de-facto Homebrew development kit for the Nintendo Gamecube, Wii and Wii U consoles. It is based on a gcc+binutils+newlib toolchain.

This pull request adds initial support for these 3 consoles.

DevkitPPC does not support unix-style sockets natively, meaning that bindings
to these functions was removed for powerpc targets with "nintendo" as
vendor

Suggested target json files:

Nintendo Gamecube:

{
  "arch": "powerpc",
  "data-layout": "E-m:e-p:32:32-i64:64-n32",
  "dynamic-linking": false,
  "env": "newlib",
  "executables": true,
  "has-elf-tls": false,
  "has-rpath": true,
  "linker-flavor": "gcc",
  "llvm-target": "powerpc-eabi",
  "max-atomic-width": 32,
  "os": "dolphin",
  "target-c-int-width": "32",
  "target-endian": "big",
  "target-family": "unix",
  "target-mcount": "_mcount",
  "target-pointer-width": "32",
  "vendor": "nintendo"
}

Nintendo Wii:

{
  "arch": "powerpc",
  "data-layout": "E-m:e-p:32:32-i64:64-n32",
  "dynamic-linking": false,
  "env": "newlib",
  "executables": true,
  "has-elf-tls": false,
  "has-rpath": true,
  "linker-flavor": "gcc",
  "llvm-target": "powerpc-eabi",
  "max-atomic-width": 32,
  "os": "revolution",
  "target-c-int-width": "32",
  "target-endian": "big",
  "target-family": "unix",
  "target-mcount": "_mcount",
  "target-pointer-width": "32",
  "vendor": "nintendo"
}

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@JohnTitor
Copy link
Member

Looks good, let's re-run CI...

@JohnTitor JohnTitor closed this Jul 31, 2020
@JohnTitor JohnTitor reopened this Jul 31, 2020
@JohnTitor
Copy link
Member

It seems target_vendor is the newer change so we should gate it with the feature like const-extern-fn.

@DarkKirb
Copy link
Author

DarkKirb commented Jul 31, 2020

I added another commit to gate the cfg checks behind a feature as well. It appears to work for a ppc linux target with version 1.13.0

@JohnTitor
Copy link
Member

I think this would be better: JohnTitor@70e1129
This doesn't require the feature flag and it only applies cfg if Rust > 1.33.0.
You could tweak the condition and make sure rustc ci/style.rs && ./style src passes (I think it suggests using cfg_if! macros).

@DarkKirb
Copy link
Author

DarkKirb commented Aug 1, 2020

it doesn't appear to do that, probably because i'm only using one layer of conditionals inside the cfg

also i added another commit that removes the addrinfo struct outright on devkitpro, because it's not defined anywhere in the header files never mind, the style check file doesn't accept two s! blocks in one file

@JohnTitor
Copy link
Member

The changes look good to me. Does this work fine on your environment? If so, r=me once the commits are squashed.

DevkitPPC does not support unix sockets natively, meaning that bindings
to these functions was removed for powerpc targets with "nintendo" as
vendor.

Suggested target json files:

Nintendo Gamecube:
```
{
  "arch": "powerpc",
  "data-layout": "E-m:e-p:32:32-i64:64-n32",
  "dynamic-linking": false,
  "env": "newlib",
  "executables": true,
  "has-elf-tls": false,
  "has-rpath": true,
  "linker-flavor": "gcc",
  "llvm-target": "powerpc-eabi",
  "max-atomic-width": 32,
  "os": "dolphin",
  "target-c-int-width": "32",
  "target-endian": "big",
  "target-family": "unix",
  "target-mcount": "_mcount",
  "target-pointer-width": "32",
  "vendor": "nintendo"
}
```

Nintendo Wii:
```
{
  "arch": "powerpc",
  "data-layout": "E-m:e-p:32:32-i64:64-n32",
  "dynamic-linking": false,
  "env": "newlib",
  "executables": true,
  "has-elf-tls": false,
  "has-rpath": true,
  "linker-flavor": "gcc",
  "llvm-target": "powerpc-eabi",
  "max-atomic-width": 32,
  "os": "revolution",
  "target-c-int-width": "32",
  "target-endian": "big",
  "target-family": "unix",
  "target-mcount": "_mcount",
  "target-pointer-width": "32",
  "vendor": "nintendo"
}
```
@DarkKirb
Copy link
Author

DarkKirb commented Aug 5, 2020

works fine on my end
r? @JohnTitor

@JohnTitor
Copy link
Member

Hmm, it seems spurious:

+ cargo test --manifest-path libc-test/Cargo.toml --target aarch64-linux-android
   Compiling libc v0.2.74 (/checkout)
   Compiling libc-test v0.1.0 (/checkout/libc-test)
    Finished test [unoptimized + debuginfo] target(s) in 56.76s
     Running target/aarch64-linux-android/debug/deps/cmsg-8b6337b17e5d316d
/checkout/target/aarch64-linux-android/debug/deps/cmsg-8b6337b17e5d316d: 1 file pushed, 0 skipped. 10.8 MB/s (5735248 bytes in 0.505s)
status: exit code: 101
stdout ---

stderr ---
thread 'main' panicked at 'No option 'h' defined', /cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/getopts-0.2.21/src/lib.rs:799:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

thread 'main' panicked at 'failed to find successful test run', /tmp/runtest.rs:45:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: test failed, to rerun pass '--test cmsg'

Re-triggering CI...

@JohnTitor JohnTitor closed this Aug 5, 2020
@JohnTitor JohnTitor reopened this Aug 5, 2020
@JohnTitor JohnTitor closed this Aug 5, 2020
@JohnTitor JohnTitor reopened this Aug 5, 2020
Copy link
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, finally it's green. Thanks for contributing!

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.

3 participants