rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.81k stars 12.77k forks source link

Change powerpc64 base CPU #59932

Open sanxiyn opened 5 years ago

sanxiyn commented 5 years ago

Currently, following targets use “ppc64” as base CPU: powerpc64-unknown-linux-gnu, powerpc64-unknown-linux-musl, powerpc64-unknown-freebsd.

In LLVM, “ppc64” implies “+altivec”. This is unfortunate, because it means Rust targets are unusable on devices based on PowerPC e5500, which is fairly popular. In particular, #43610 is about QorIQ P5040 SoC using PowerPC e5500 core, and #59040 is about QorIQ T1042 SoC using PowerPC e5500 core.

Thoughts?

cuviper commented 5 years ago

I think it would make sense to have a new std-only target for this, similar to how we have i586 for those who can't use i686 for lack of SSE2.

gnzlbg commented 5 years ago

The proposed change is only for the big-endian targets right? That is, the pp64le targets would still be compiled with altivec enabled right ?

sanxiyn commented 5 years ago

Yes, I am not proposing to change powerpc64le targets.

gnzlbg commented 5 years ago

Then this sounds good to me 👍

nagisa commented 5 years ago

I would be fine with disabling altivec by default on both ppc64, because it is easier to enable it back for new binaries than to disable it for already-built ones.

Removing I-nominated, because T-compiler don’t have stakeholders in PPC support to the best of my knowledge, so it is impossible for us to arrive at a meaningful decision.

gnzlbg commented 5 years ago

@nagisa is there a group for packagers / distros contributors ? I think this would interest them, since the ppc targets are being shipped for some linux distros.

cuviper commented 5 years ago

I would be fine with disabling altivec by default on both ppc64

By "both", do you mean ppc64le too? AFAIK little-endian only became a viable Linux target starting with POWER8, which definitely has Altivec. LLVM also defines the ppc64le CPU as POWER8.

because it is easier to enable it back for new binaries than to disable it for already-built ones.

It's easy to add features for your own code, but std is stuck at the baseline unless you xargo it.

nagisa commented 5 years ago

By "both", do you mean ppc64le too?

Yes. Then again, if ppc64le without altivec cannot possibly exist, then the lowest common denominator is good as well. Knowing PPC, though, you can run most of the chips in either endianess.

It's easy to add features for your own code, but std is stuck at the baseline unless you xargo it.

On one hand you’re right, on the other most of std is so generic, that in practice most of the code will end up using whatever features that are enabled for the final artifact. I guess https://github.com/rust-lang/rust/issues/38913 cannot come soon enough.

cuviper commented 5 years ago

Knowing PPC, though, you can run most of the chips in either endianess.

I don't know the full details, but this IBM FAQ says:

Which POWER processors support little endian mode?

The POWER8 processor is the first processor to support little endian and big endian modes equivalently. Although previous generations of the POWER processors had basic little endian functionality, they did not fully implement the necessary instructions in such a way to enable enterprise operating system offerings.

awilfox commented 5 years ago

Personally over here at Adélie we only ship BE PPC64, and we enable AltiVec in all of our packages. We may, in the future, offer a separate target for non-AltiVec PPC64 machines. I would definitely support Rust targeting more types of POWER, and I know the FreeBSD people specifically support the e5500s.

As an aside: IBM's really unreliable for endian questions. You can run BE on any generation of POWER, and you can run LE on most generations of POWER. You can even run accelerated LE in KVM on the Power Mac G5, though the firmware itself prevents bare metal LE mode. Not that I really recommend that; BE mode is faster, better, and easier to debug (biased opinion, of course).

gnzlbg commented 5 years ago

@lu-zero correctly pointed out that we currently do also enable VSX for ppc64le.

smvoss commented 5 years ago

Any movement on this?

ecnelises commented 7 months ago

Power8 fully supports little-endian mode, while Power7 partially supports it. In LLVM little-endian powerpc defaults to Power8, big-endian powerpc defaults to Power7. In theory, a Power8 target can still have no Altivec/VSX support because it can be disabled. I'm curious: isn't directly disabling vector feature or changing target-cpu in rustc command line enough?

sanxiyn commented 7 months ago

No, because prebuilt std is built with Altivec, disabling Altivec from command line does not work.

ecnelises commented 6 months ago

If altivec is disabled in building std, will anything become unavailable? For example, vector types in std::simd or core::arch::powerpc64.