Cross-compiling
GavinWraith (26) 1532 posts |
Can I compile ANSI-C code on an Rpi3 under Raspbian to an ELF executable and have it run on an Rpi3 under RISC OS? |
Jeffrey Lee (213) 6046 posts |
If you’re patient enough to wait for the GCCSDK cross compiler to compile, then yes. |
Matthew Phillips (473) 687 posts |
Correct me if I am wrong, Gavin, but I think your question was whether you can use unadulterated gcc from the standard Raspbian package to compile an ELF which will then run on RISC OS. Not whether you can use GCCSDK to do the job. I tried GCCSDK on Debian or Ubuntu (can’t remember which) on a Beagleboard several years ago. I could not get it to work because GCCSDK was not expecting the machine’s native format to be ARM. That may have been improved since. |
GavinWraith (26) 1532 posts |
A vague phrase like ‘under Linux’ has, until recently, almost always been intended in the sense ‘under x86-Linux’. Only now has ‘under ARM-Linux’ become a likely alternative. I suppose we ought to be preciser still and specify which ARM architecture we mean. I suspect the answer to my question is no, because among other reasons, as Jeffery Lee points out in another thread, in RISC OS the C runtime code for stack-handling has to cater for linked lists of stack-chunks, which would be different from the way stacks are implemented in Linux. But it would be good if any port of RISC OS to Linux, whatever that means, incorporated facilities for cross-compiling to RISC OS. |
Tristan M. (2946) 1036 posts |
It needs a tweak to compile on ARM. I did it a certain way last time. Currently trying another, older workaround that I found in a riscos.info archive. I’ll get back to you later if the build succeeds. I’m currently trying this method. I’ve seen it before but haven’t tried it. https://www.mail-archive.com/gcc@gccsdk.riscos.info/msg02328.html Something else to be mindful of is to ensure that gcc, g++, and probably gcc-ar and gcc-nm are set up to be the defaults. Easiest way is to use update-alternatives. It’s still a pain but better than messing with symlinks directly. Haven’t had luch with CC=blah etc with GCCSDK. Maybe I’m just doing it wrong. Quite likely actually. |
Tristan M. (2946) 1036 posts |
It built, and I have it building wget from the autobuilder right now so it seems to work. Haven’t tested the wget binary for sanity yet of course because it’s still building :) But it should be okay. |
RonM (387) 60 posts |
building wget from the autobuilder Wget should always build for quite a while as it uses a fixed url for the source. Just be aware that the normal autobuilder method is to use ever changing testing repositories, and a change in the source can either error out, or sometimes appear to build, but on inspection of the success file, you may find patches that have failed. |