Pinephone - or, compile to ARM in general

Raspberry PI specific forum
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Pinephone - or, compile to ARM in general

Post by mdp »

Greetings,
with an interest to creating software for Mobile Linux (e.g. systems - like Manjaro, Mobian etc. - that work on the Pinephone), I just tried the Beta 3, on the normal Linux desktop, presuming to find an option like "compile to ARM", "target: Raspberry PI" etc.

I am not finding it in the compiler options: the only compiler that appears is 'PureBasic 6.00 Beta 3 (Linux - x64)'.

How does one compile for ARM using an x86 environment (your normal development machine)?

--

Mind you: the ability to properly code and compile from your phone/tablet will be greatly appreciated (finally. Though of course you often want to compile here and install there).
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Pinephone - or, compile to ARM in general

Post by Marc56us »

mdp wrote: Mon Jan 31, 2022 2:48 pm Greetings,
with an interest to creating software for Mobile Linux (e.g. systems - like Manjaro, Mobian etc. - that work on the Pinephone), I just tried the Beta 3, on the normal Linux desktop, presuming to find an option like "compile to ARM", "target: Raspberry PI" etc.

I am not finding it in the compiler options: the only compiler that appears is 'PureBasic 6.00 Beta 3 (Linux - x64)'.

How does one compile for ARM using an x86 environment?
Hello,

To compile for Raspberry, you need to compile from a Raspberry (hardware or emulator) with PB RPI compiler, because all is different.
You can nevertheless compile from the Linux IDE (or even Windows) and at the same time train the command line compiler installed on an RPI using a network mount, but you will not get the console feedback directly

In all case, you need PB arm version on ARM computer. Use link in your account: Download PureBasic 6.00 Beta 3 for Raspberry (Raspberry OS - arm32)
Compiler in IDE will display: Purebasic 6.0 ... - C Backend (Linux - arm32)
:wink:
Last edited by Marc56us on Mon Jan 31, 2022 3:24 pm, edited 1 time in total.
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Re: Pinephone - or, compile to ARM in general

Post by mdp »

Marc56us wrote: Mon Jan 31, 2022 2:56 pm To compile for Raspberry, you need to compile from a Raspberry (hardware or emulator) with PB RPI compiler, because all is different.
Use link in your account: Download PureBasic 6.00 Beta 3 for Raspberry (Raspberry OS - arm32)
Thank you,
right: it is not impossible to use an emulator to compile (e.g. instructions for use with QEmu would be e.g. at https://azeria-labs.com/emulate-raspberry-pi-with-qemu/ ), but I "dreamt" of the comfort of just changing the target through the local options.

On the other hand, I am not sure I ever compiled a PB executable for Win/Mac/Linux from Linux/Win/Mac, so it makes sense.

Thing is, with the FASM backend probably all three packages are "separate" (the libraries are different), but I supposed that with a C backend the distinctions (especially x86 vs ARM) would be made by GCC.
User avatar
mk-soft
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Pinephone - or, compile to ARM in general

Post by mk-soft »

Maybe try a PinePhone emulator,
But it has to be a Debian Arm32 based OS.

There is no Arm64 version of Purebasic yet. But maybe we can hope that there will be one soon.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Re: Pinephone - or, compile to ARM in general

Post by mdp »

mk-soft wrote: Mon Jan 31, 2022 3:42 pm Maybe try a PinePhone emulator
As soon as I will be able to set up an environment I will verify whether Raspberry PI compilations also work on the Pinephone (on Manjaro etc. - it is not strictly necessary that Linux Mobile only worked on "specially certified" devices), and I will report here.

I could of course try the full PB on the device - only, I do not have direct access to the phone, a friend made the (preliminary, "history opening") purchase.
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Re: Pinephone - or, compile to ARM in general

Post by mdp »

Marc56us wrote: Mon Jan 31, 2022 2:56 pm You can nevertheless compile from the Linux IDE (or even Windows) and at the same time train the command line compiler installed on an RPI using a network mount
( I used similar tricks say 15 years ago to compile/debug PureBasic code on headless servers... Sweet were the times :) )
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Re: Pinephone - or, compile to ARM in general

Post by mdp »

mk-soft wrote: Mon Jan 31, 2022 3:42 pm But it has to be a Debian Arm32 based OS. // There is no Arm64 version of Purebasic yet. But maybe we can hope that there will be one soon.
I see the problem, I missed that. PureBasic will compile (supposedly) to armv7 (32bit), while the mobile OS will very probably demand armv8 (64bit). Yes, that could be a problem, because the only compatibility layer available will probably be qemu then.

Thing is, I understand a 64bit armv8 CPU can accept a 32bit OS (through internal compatibility mode), but a 64bit OS will not allow for running 32bit armv7 executables.

In that case, compilation to ARM 64 bit, armv8 code would be highly desirable.
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Re: Pinephone - or, compile to ARM in general

Post by mdp »

I few words on the general matter. Suppose you have an "Android friendly" mobile device:
  • if the device boots Android,
    • chroot techniques that do not require rooting the device (PRoot) allow for Linux Desktop environments to be run on "any" Android device - only, I presume, with limited comfort, since I understand visualization would happen though a local VNC connection. So,
    • PB applications could be run on mobile devices in such environments, and even the PB IDE itself. Only, I see that the requirement seem to be for 64bit applications.
  • if the device boots a Linux Mobile distribution,
    • Android applications would be run through Waydroid - which reportedly works very well, with high compatibility.
    • PB applications, and even the PB IDE itself, could be run natively on such mobile devices. Only, again, the requirements seem to be for 64bit applications.
User avatar
idle
Always Here
Always Here
Posts: 5097
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Pinephone - or, compile to ARM in general

Post by idle »

short answer hmmmaby, I have just tested targeting web assembly, but I still need to make a nice way to strip the purebasic.c to automate the compile and even then, the issue is that you can't use any pb objects or libs. so it's all got to be done with imported c libs which isn't everyone's cup of tea.

So far I'v'e worked out how to include c headers to keep the constants and macros intact but you still need to port structures. if you need to access them in PB but otherwise it's really easy to use a c libs now or just include raw c.

My next task is looking into how I can feed the pbcompiler with c structure definitions. If that can be automated it saves a lot of messing around. so while I don't really want to write a c parser, I do have a lexer that works ok, but I'm looking into what transforms llvm offers.
  • so right now I can include c headers and use inline c to call the functions, constants and macros
    I have full control over the command line to both gcc or clang
    I can compile with either gcc or clang tool chain or both
    and I can theoretically target web assembly.
so yes it will be possible with clang and a bit of effort.

here are the supported targets from clang
Registered Targets:
aarch64 - AArch64 (little endian)
aarch64_32 - AArch64 (little endian ILP32)
aarch64_be - AArch64 (big endian)
amdgcn - AMD GCN GPUs
arm - ARM
arm64 - ARM64 (little endian)
arm64_32 - ARM64 (little endian ILP32)
armeb - ARM (big endian)
avr - Atmel AVR Microcontroller
bpf - BPF (host endian)
bpfeb - BPF (big endian)
bpfel - BPF (little endian)
hexagon - Hexagon
lanai - Lanai
mips - MIPS (32-bit big endian)
mips64 - MIPS (64-bit big endian)
mips64el - MIPS (64-bit little endian)
mipsel - MIPS (32-bit little endian)
msp430 - MSP430 [experimental]
nvptx - NVIDIA PTX 32-bit
nvptx64 - NVIDIA PTX 64-bit
ppc32 - PowerPC 32
ppc64 - PowerPC 64
ppc64le - PowerPC 64 LE
r600 - AMD GPUs HD2XXX-HD6XXX
riscv32 - 32-bit RISC-V
riscv64 - 64-bit RISC-V
sparc - Sparc
sparcel - Sparc LE
sparcv9 - Sparc V9
systemz - SystemZ
thumb - Thumb
thumbeb - Thumb (big endian)
wasm32 - WebAssembly 32-bit
wasm64 - WebAssembly 64-bit
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
xcore - XCore
Post Reply