Rust-GCC / gccrs

GCC Front-End for Rust
https://rust-gcc.github.io/
GNU General Public License v2.0
2.31k stars 144 forks source link

PowerPC support? #1573

Open barracuda156 opened 1 year ago

barracuda156 commented 1 year ago

Does anyone know if some initial support for PowerPC exists with gccrs? Would be awesome to have it. If any testing needed, I am eager to join in.

P. S. I am primarily interested in Darwin PPC, but if Linux, *BSD or AIX version exists, that can be at least some start to fix things for MacOS PPC.

liushuyu commented 1 year ago

Does anyone know if some initial support for PowerPC exists with gccrs? Would be awesome to have it.

I think it is! Although there are some unit-test failures, many fundamental parts should be working.

barracuda156 commented 1 year ago

Does anyone know if some initial support for PowerPC exists with gccrs? Would be awesome to have it.

I think it is! Although there are some unit-test failures, many fundamental parts should be working.

Thank you, sounds good.

@catap Looks like we should try this.

barracuda156 commented 1 year ago

@liushuyu @ibuclaw BTW if you are familiar with Macports, does gccrs need to install some components into libgcc or it uses standard libgcc (i.e. no extra dylibs etc.)?

(A bit of context: On my main system, 10.6 PPC, gcc11/gcc12 builds only inside Macports. On 10.5.8 standalone build works as well. But to test it on 10.6 PPC, I need to either add gccrs into gcc12 port or otherwise write a separate portfile for it – but the question re libgcc has to be solved, since Macports keeps runtime separately, making it shared across several gcc versions.)

liushuyu commented 1 year ago

@liushuyu @ibuclaw BTW if you are familiar with Macports, does gccrs need to install some components into libgcc or it uses standard libgcc (i.e. no extra dylibs etc.)?

I only have very rudimentary understanding of Macports. But libgcc must be from GCC 13 since that's the version this frontend is based on.

(A bit of context: On my main system, 10.6 PPC, gcc11/gcc12 builds only inside Macports. On 10.5.8 standalone build works as well. But to test it on 10.6 PPC, I need to either add gccrs into gcc12 port or otherwise write a separate portfile for it – but the question re libgcc has to be solved, since Macports keeps runtime separately, making it shared across several gcc versions.)

GCC 12 may not work with the gccrs front end now since Rust GCC is currently preparing for the mainline merge into GCC 13.

barracuda156 commented 1 year ago

I only have very rudimentary understanding of Macports. But libgcc must be from GCC 13 since that's the version this frontend is based on. GCC 12 may not work with the gccrs front end now since Rust GCC is currently preparing for the mainline merge into GCC 13.

Thank you. This should not be a problem in itself, we have GCC13 as gcc-devel port, and I am pretty sure it gonna build for powerpc*-apple-darwin, since the upstream supports Darwin PPC.

liushuyu commented 1 year ago

I only have very rudimentary understanding of Macports. But libgcc must be from GCC 13 since that's the version this frontend is based on. GCC 12 may not work with the gccrs front end now since Rust GCC is currently preparing for the mainline merge into GCC 13.

Thank you. This should not be a problem in itself, we have GCC13 as gcc-devel port, and I am pretty sure it gonna build for powerpc*-apple-darwin, since the upstream supports Darwin PPC.

You are very welcome to report your findings here.

Although, if you want to do something serious, you may still find rustc a better option.

barracuda156 commented 1 year ago

Although, if you want to do something serious, you may still find rustc a better option.

rustc does not build for PPC: https://trac.macports.org/ticket/65942 At least so far.

barracuda156 commented 1 year ago

@iains Just in case, have you tried this on 10.5.8? Judging from commits, it should at least build, including ppc64. See, for example: https://github.com/Rust-GCC/gccrs/pull/1543

liushuyu commented 1 year ago

rustc does not build for PPC: https://trac.macports.org/ticket/65942 At least so far.

Oh, I see you are trying to take the source build approach to bootstrap rustc from mrustc. In which case, that's going to be a dead-end for non-x86 or non-arm systems.

If you don't care about using foreign binaries, you may want to use the binaries from the Rust CI.

ibuclaw commented 1 year ago

@iains Just in case, have you tried this on 10.5.8? Judging from commits, it should at least build, including ppc64. See, for example: https://github.com/Rust-GCC/gccrs/pull/1543

(As I understand from in person conversation with Phil) gccrs doesn't require #1543 to build on darwin-ppc64. Even without, it should already be supported, but you just won't be able to get any target-specific information out of the compiler.

barracuda156 commented 1 year ago

Oh, I see you are trying to take the source build approach to bootstrap rustc from mrustc. In which case, that's going to be a dead-end for non-x86 or non-arm systems.

@liushuyu Why though? @catap has removed hard-coded x86: https://github.com/macports/macports-ports/pull/16284 We do not have PPC yet (as you can see, bootstrap fails), but mrustc builds, in principle rustc should build too. What is that we do not know?

If you don't care about using foreign binaries, you may want to use the binaries from the Rust CI.

I would imagine no ready-made binaries for Darwin PPC exist.

liushuyu commented 1 year ago

Oh, I see you are trying to take the source build approach to bootstrap rustc from mrustc. In which case, that's going to be a dead-end for non-x86 or non-arm systems.

@liushuyu Why though? @catap has removed hard-coded x86: macports/macports-ports#16284 We do not have PPC yet (as you can see, bootstrap fails), but mrustc builds, in principle rustc should build too. What is that we do not know?

If you don't care about using foreign binaries, you may want to use the binaries from the Rust CI.

I would imagine no ready-made binaries for Darwin PPC exist.

According to https://doc.rust-lang.org/beta/rustc/platform-support.html, PPC Darwin support does not seem to be mentioned. Maybe the page is outdated, you could try to find out yourself.

CohenArthur commented 1 year ago

@barracuda156 have you looked into https://github.com/rust-lang/rustc_codegen_gcc ? gccrs is waaaay behind rustc_codegen_gcc, and that might help you getting Rust on your machines

dkm commented 1 year ago

If rustc can't be build for some reason, rustc_cg_gcc will probably have the same issue as the first req is to have rustc. If the issue is within the LLVM build (I doubt it), I'm not sure you can skip it... so.....

barracuda156 commented 1 year ago

If rustc can't be build for some reason, rustc_cg_gcc will probably have the same issue as the first req is to have rustc. If the issue is within the LLVM build (I doubt it), I'm not sure you can skip it... so.....

LLVM is broken for PPC. We can only use GCC reliably, and that too with libstdc++.

P. S. LLVM 7.1 is partially working: https://github.com/iains/darwin-toolchains-start-here/discussions/29#discussioncomment-3544024 More here: https://github.com/iains/darwin-toolchains-start-here/discussions/31

bjorn3 commented 1 year ago

According to https://doc.rust-lang.org/beta/rustc/platform-support.html, PPC Darwin support does not seem to be mentioned. Maybe the page is outdated, you could try to find out yourself.

Rustc only supports macOS targets that latest XCode can still compile for. If you need other targets, you can create a patch to add a target spec to rustc and add support for it to crates like libc. You will have to add support to crates like libc one way or another even if you use gccrs or mrustc.

barracuda156 commented 1 year ago

I can confirm that gccrs builds for ppc32 on macOS. This is in Rosetta (build takes forever), I will build natively in a couple of days. gccrs