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 Dockerfile for riscv64-unknown-linux-gnu #1416

Closed
wants to merge 2 commits into from

Conversation

fintelia
Copy link
Contributor

See #1415

@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 @gnzlbg (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.

@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 1, 2019

Note that this is not tested on CI, that would require adding a build job to .travis.yml. Is that intended ?

@fintelia
Copy link
Contributor Author

fintelia commented Jul 1, 2019

Not intended so much as I just wasn't sure how to add the job to CI. I'll make that change in a bit

@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 1, 2019

I've restarted this particular build: https://travis-ci.com/rust-lang/libc/jobs/212378258

@fintelia
Copy link
Contributor Author

fintelia commented Jul 1, 2019

That runs into a sort of circular issue: there isn't a riscv64gc-unknown-linux-gnu target yet because the standard library can't be compiled for 64-bit RISC-V. And the standard library can't be built for it because the libc crate doesn't yet support it.

Perhaps there'd be a way to temporarily use the risc64gc-unknown-none-elf target?

@mati865
Copy link
Contributor

mati865 commented Jul 1, 2019

@fintelia to add new target you have to fix and test everything locally using by building Rust with modified dependencies (like patched libc), get dependencies fixes merged, get new target merged and finally add tests everywhere once the target works.

@fintelia
Copy link
Contributor Author

fintelia commented Jul 1, 2019

@mati865 That makes more sense

@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 1, 2019

@fintelia my recommendation is to add it as a libcore target only first to rust-lang/rust . That requires adding a target specification to rust-lang/rust/src/librustc_target, and not much more. Once that is done, libc is no_std, so it can be built against that. Once you have libcore and libc working, getting support for liballoc shouldn't be hard, you can just shim out to libc::malloc. The largest chunk of work is getting libstd support, depending on how similar this is to other unix targets, might be a breeze or not.

@mati865
Copy link
Contributor

mati865 commented Jul 1, 2019

Good point, I didn't know you can make something as big as *-unknown-linux-gnu std-less.

@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 1, 2019

Good point, I didn't know you can make something as big as *-unknown-linux-gnu std-less.

If the target isn't tier2, nothing is built, and then you have to build it with xargo, which you can use to build libcore only. So... it kind of works by omission 😆

@fintelia
Copy link
Contributor Author

fintelia commented Jul 1, 2019

Where is the tier listing actually specified in the rustc source? It seems that just adding a target spec file and including it in the supported_targets! macro is enough to cause ./x.py build to try building the standard library for that target

@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 1, 2019

@gnzlbg gnzlbg closed this Jul 27, 2019
@gnzlbg gnzlbg reopened this Jul 27, 2019
@bors
Copy link
Contributor

bors commented Aug 8, 2019

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

@gnzlbg
Copy link
Contributor

gnzlbg commented Aug 9, 2019

This needs rebasing. What was previously in the .travis.yml needs to be moved to ci/azure.yml (check out how the other targets are added there - should be pretty similar).

@gnzlbg
Copy link
Contributor

gnzlbg commented Sep 21, 2019

ping

@fintelia
Copy link
Contributor Author

Sorry for the delay on this. I don't think I'm going to have a chance to go through all of the steps to get this together in the near term so if anyone else is interested feel free to take over

Copy link
Contributor

@msizanoen1 msizanoen1 left a comment

Choose a reason for hiding this comment

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

You should also set CFLAGS_riscv64gc_unknown_linux_gnu to -mabi=lp64d -fPIC because:

  • cc crate add the -mabi=lp64 by default
  • the compiler default to non-PIC which causes linking error as rustc link a PIE executable by default.

Also the CC should be CC_riscv64gc_unknown_linux_gnu not CC_riscv64_unknown_linux_gnu.

@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 27, 2019

@msizanoen1 please feel free to fork this branch and update it as you see fit and submit a PR.

@msizanoen1
Copy link
Contributor

Actually getting std to compile for riscv64 is pretty simple: rust-lang/rust@master...msizanoen1:riscv-std

@JohnTitor
Copy link
Member

The dockerfile is added by #1684 and I'm closing this in favor of it, thanks for contributing!

@JohnTitor JohnTitor closed this Oct 15, 2020
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.

None yet

7 participants