v icon indicating copy to clipboard operation
v copied to clipboard

Support cross-compiling to ppc

Open likema opened this issue 3 years ago • 14 comments

Hi,

I have a cross compiler powerpc64le-rhel7-linux-gnu-gcc.

How to cross-compile V source file by this cross compiler?

Thanks.

likema avatar Aug 14 '22 18:08 likema

V doesn't (currently) support ppc, so you will need to do a 2-step process.

First, compile V to C: v -o name.c name.v

Then, compile the C file as you normally would powerpc64le-rhel7-linux-gnu-gcc -o name name.c

Or whatever your favorite options may be.

I would also recommend updating your OS to something more recent... rhel 9 has been our for several months.

JalonSolov avatar Aug 14 '22 18:08 JalonSolov

But name.c depends on libgc.a .

Does it need to be built manually?

likema avatar Aug 14 '22 18:08 likema

Will the V dev team plan to support this kind of cross-build scenario?

likema avatar Aug 14 '22 18:08 likema

In general we'll need support from the community to be able to implement and maintain these kinds of lesser known targets. So if anyone reads this and is capable of fixing it, please chip in.

larpon avatar Aug 14 '22 20:08 larpon

@harens & @barracuda156, would you be interested in collaborating with @likema on this due to your involvement also in PPC hardware?

ylluminate avatar Aug 14 '22 23:08 ylluminate

@ylluminate From what I understand, ppc64le is substantially different from ppc and ppc64 on Darwin, but I am interested in the topic. Thank you for tagging me.

barracuda156 avatar Aug 15 '22 06:08 barracuda156

@ylluminate From what I understand, ppc64le is substantially different from ppc and ppc64 on Darwin, but I am interested in the topic. Thank you for tagging me.

Yes, ppc64le is an architecture of Power 8/9 on Linux.

likema avatar Aug 15 '22 06:08 likema

Not only ppc64le, but also loongarch64 cross-compile need to be supported.

I suggest something is similar with CMake toolchain file:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ppc64le)
set(CMAKE_C_COMPILER powerpc64le-rhel7-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER powerpc64le-rhel7-linux-gnu-g++)

likema avatar Aug 15 '22 06:08 likema

@likema By the way, why cross, why not build natively?

barracuda156 avatar Aug 15 '22 06:08 barracuda156

@likema By the way, why cross, why not build natively?

For saving cost

likema avatar Aug 15 '22 07:08 likema

@likema By the way, why cross, why not build natively?

For saving cost

@likema But does it build natively? For ppc it does. ppc64 not sure.

By the way, I am interested to implement ppc64 support, if it is lacking. Primarily for BE, but LE should be easier in fact.

barracuda156 avatar Aug 15 '22 07:08 barracuda156

By the way, I am interested to implement ppc64 support, if it is lacking. Primarily for BE, but LE should be easier in fact.

Thanks.

I also have powerpc64-rhel6-linux-gnu-gcc , which is big endian.

All of my cross compilers are built on Linux x86_64 by crosstool-ng

likema avatar Aug 15 '22 07:08 likema

V doesn't (currently) support ppc, so you will need to do a 2-step process.

@JalonSolov It actually builds on PPC systems (ppc32 at least): https://trac.macports.org/ticket/64913

barracuda156 avatar Aug 15 '22 19:08 barracuda156

Should have said - it doesn't currently support cross-compiling to ppc. If you can run it natively, it'll be fine... but the question was specifically about cross-compiling.

JalonSolov avatar Aug 15 '22 21:08 JalonSolov