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 Hexagon support #41524

Merged
merged 4 commits into from
Apr 27, 2017
Merged

Add Hexagon support #41524

merged 4 commits into from
Apr 27, 2017

Conversation

michaelwu
Copy link
Contributor

This requires an updated LLVM with https://reviews.llvm.org/D31999 and https://reviews.llvm.org/D32000 to build libcore.

A basic hello world builds and runs successfully on the hexagon simulator. libcore is fine with LLVM fixes, but libstd requires a lot more work since there's a custom rtos running on most hexagon cores. Running Linux sounds possible though, so maybe getting linux + musl going would be easier.

Here's the target file I've been using for testing

{
    "arch": "hexagon",
    "llvm-target": "hexagon-unknown-elf",
    "os": "none",
    "target-endian": "little",
    "target-pointer-width": "32",

    "data-layout": "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048",
    "linker": "hexagon-clang",
    "linker-flavor": "gcc",
    "executables": true,
    "cpu": "hexagonv60"
}

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @arielb1 (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.

@michaelwu
Copy link
Contributor Author

I also have a wip for support for HVX v60 intrinsics in librustc_platform_intrinsics, but I haven't tested it on the emulator yet.

This requires an updated LLVM with D31999 and D32000 to build libcore.

A basic hello world builds and runs successfully on the hexagon simulator.
@michaelwu
Copy link
Contributor Author

Oh. Looks like the builder is using an older system llvm which has a hexagon backend without an assembly parser. Should I avoid old llvms somehow? Or do we need a newer docker image?

@hanna-kruppe
Copy link
Contributor

hanna-kruppe commented Apr 25, 2017

We want to support older LLVM versions (currently 3.7 upwards) for the sake of distros and other people building rustc with their own LLVM, and hence we have a few (one?) builder that tests that. However, there's no need to support each and every feature with older LLVM, so as long as it builds and tests pass, everything's fine. So in the worst case, you could disable the Hexagon target when building with an older LLVM. (Of course, if everything except the asm parser can be made to work with reasonable effort, that's good as well.)

Edit: You could repurpose the version query in the build script to not include the "hexagon" component on older LLVM versions.

@michaelwu
Copy link
Contributor Author

michaelwu commented Apr 25, 2017

Just noticed your edit after pushing a commit to do exactly that.

I put in a version check requiring LLVM 4 or newer. Looks like LLVM 3.8 added the asm parser, but that's not likely to build libcore successfully. Probably actually need LLVM 5, but there's a chance LLVM 4 can work if we backport the necessary fixes.

@michaelwu
Copy link
Contributor Author

Turns out LLVM 4.0 plus some hexagon fixes does work, so I'll put up a PR for that soon.

@arielb1
Copy link
Contributor

arielb1 commented Apr 26, 2017

r? @alexcrichton

@alexcrichton
Copy link
Member

Looks good to me, thanks for the PR!

@michaelwu lemme know when you're good on testing (e.g. when .travis.yml changes are back to normal) and I'll r+

@aidanhs aidanhs added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 26, 2017
@michaelwu
Copy link
Contributor Author

@alexcrichton I think I've tested enough. I just added a commit to build hexagon in LLVM by default since the rest of the hexagon support in rust is going to be built anyway, so why not..

@alexcrichton
Copy link
Member

Just to confirm, but could you measure the before/after size of LLVM compiling in hexagon? Just want to make sure we're not surprisingly adding like 100MB of extra libs.

@michaelwu
Copy link
Contributor Author

On a release build of LLVM on x86-64 Linux, I'm measuring an increase of 30MB in the bin, include, and lib directories. llc is increased by about 2MB.

@hanna-kruppe
Copy link
Contributor

That doesn't matter, what's interesting for Rust is the size increase of the Rust toolchain (e.g., stage1 directory).

@michaelwu
Copy link
Contributor Author

Agreed - I'm doing full rust builds to see what happens. LLVM only size comparisons were faster to do. I expect the size increase to be close to the increase in llc's size though.

@michaelwu
Copy link
Contributor Author

stage1 directory increases by about 5mb.

@alexcrichton
Copy link
Member

Ok, that seems pretty reasonable, thanks for taking a look!

@bors: r+

@michaelwu
Copy link
Contributor Author

Hm, did bors miss that r+?

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Apr 26, 2017

📌 Commit 22eb3c6 has been approved by alexcrichton

@alexcrichton
Copy link
Member

there we go!

arielb1 pushed a commit to arielb1/rust that referenced this pull request Apr 26, 2017
…hton

Add Hexagon support

This requires an updated LLVM with https://reviews.llvm.org/D31999 and https://reviews.llvm.org/D32000 to build libcore.

A basic hello world builds and runs successfully on the hexagon simulator. libcore is fine with LLVM fixes, but libstd requires a lot more work since there's a custom rtos running on most hexagon cores. Running Linux sounds possible though, so maybe getting linux + musl going would be easier.

Here's the target file I've been using for testing
```
{
    "arch": "hexagon",
    "llvm-target": "hexagon-unknown-elf",
    "os": "none",
    "target-endian": "little",
    "target-pointer-width": "32",

    "data-layout": "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048",
    "linker": "hexagon-clang",
    "linker-flavor": "gcc",
    "executables": true,
    "cpu": "hexagonv60"
}
```
arielb1 pushed a commit to arielb1/rust that referenced this pull request Apr 26, 2017
…hton

Add Hexagon support

This requires an updated LLVM with https://reviews.llvm.org/D31999 and https://reviews.llvm.org/D32000 to build libcore.

A basic hello world builds and runs successfully on the hexagon simulator. libcore is fine with LLVM fixes, but libstd requires a lot more work since there's a custom rtos running on most hexagon cores. Running Linux sounds possible though, so maybe getting linux + musl going would be easier.

Here's the target file I've been using for testing
```
{
    "arch": "hexagon",
    "llvm-target": "hexagon-unknown-elf",
    "os": "none",
    "target-endian": "little",
    "target-pointer-width": "32",

    "data-layout": "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048",
    "linker": "hexagon-clang",
    "linker-flavor": "gcc",
    "executables": true,
    "cpu": "hexagonv60"
}
```
bors added a commit that referenced this pull request Apr 27, 2017
Rollup of 9 pull requests

- Successful merges: #41370, #41456, #41493, #41499, #41501, #41524, #41546, #41550, #41552
- Failed merges:
@bors bors merged commit 22eb3c6 into rust-lang:master Apr 27, 2017
@michaelwu michaelwu deleted the basic-hexagon branch April 27, 2017 15:46
@michaelwu
Copy link
Contributor Author

For anyone who wants an example of how to use this, I just put up https://github.com/michaelwu/hexagon-hello-world

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

7 participants