GCC
James Pankhurst (8374) 126 posts |
It’s been a long time since I wrote code on RISC OS, and 3 decades ago it was BASIC. So I figured I’d have a play with C and gcc, as that’s my current poison. Using RPCemu and the RISC OS 5 easy start bundle, I tried knocking up the essential Hello World using Sourcery. However, when it tries to build, it reports that “The Application needs 16000k of memory” and doesn’t build anything. I can’t for the life of me figure out where this 16000k is either configured or required, doesn’t seem to be a lack of ram in rpcemu, it’s configured as a 256mb SA, nor is it the Free or Next slots. Dropping to the CLI, gcc just reports a lack of memory, but nothing specific. What am I missing, or need to set? |
Paolo Fabio Zaino (28) 1853 posts |
Hi James, In a more general answer, if you setup your Next slot (in the Tasks Manager) to that amount of RAM, OR if you set up a WimpSlot -min 16000k in an Obey file that kickstarts your build process then GCC would have enough memory to do its job. HTH |
James Pankhurst (8374) 126 posts |
That’s what I thought with the Next slot, but it didn’t seem to make any difference. It’s just building from the Sourcery gui, and I couldn’t see any obvious options in it. I’ll poke about a bit more, or get desperate and use my Pi DDE instead. |
James Pankhurst (8374) 126 posts |
Ah ha! Ok, using a task window gcc and WimpSlot works. Also finally tracked down the setting in Sourcery, it was set at 8192k, so now it gets further but complains -mapcs-32 is an unknown option. Getting closer! |
Paolo Fabio Zaino (28) 1853 posts |
Nice work! :) |
James Pankhurst (8374) 126 posts |
And the -mapcs-32 is redundant but still generated by default, a little tool editing fixed that. I think using Obey files is much easier, at least once you know what options to pass. |
Paolo Fabio Zaino (28) 1853 posts |
Same. I just use Obey files by long time. |
James Pankhurst (8374) 126 posts |
I’m used to the likes of Visual Studio, so thought I’d see what Sourcery was like, but tbh Obeys are probably just as easy to do when the projects aren’t all that complex and you know what you need to do. Either way, somehow I think I’m cursed. I have a Pi setup that can’t type #, some careful remapping may be required, and a RPCemu that can’t type \, because the host has the oddest “UK” keyboard ever. |
Rick Murray (539) 13806 posts |
? Do you mean your keyboard is lacking the
Sounds like a laptop. Been there, seen that. It’s as if nobody needs to type filenames at the console any more. <sigh> I think one of my old machines had Aren’t non-standard keyboards fun? |
James Pankhurst (8374) 126 posts |
It’s a Motorola Atrix Lapdock, with a Pi 3A strapped to it, and the # is normally obtained by using the Fn+;. Well, I could have sworn it didn’t work…but does seem to be today.
Exactly that! Although I think it’s Alt Gr in this case. It’s a refurbished Thinkpad, with an ANSI physical keyboard that has UK key printing on. It works perfectly in Windows using the standard UK map, but it’s incorrect in Linux and RPCemu, but at least it has a 3 button trackpad. I’ve ordered an actual proper UK keyboard for it, so that should fix it. |
Kevin (224) 322 posts |
Would my Virtual Keyboard be of use with the missing keys? |
James Pankhurst (8374) 126 posts |
Hmm, it might, i’ll give it a go. |
David Buck (8493) 8 posts |
With !Sourcery, you need to go to the config settings and find the gcc compiler setting, at the top of the config window in a control for increasing the memory. You will need to crank it full up to 16MB. |
Andrew McCarthy (3688) 605 posts |
A while ago, I created a quick ‘getting started’ video for GCC C. I created it for anyone intending to use GCC C, and it’s intended to complement the RISC OS GCC resources at riscos.info. Also, here’s a hand-crafted playlist of assorted stuff which might be helpful. If you get !Sourcery to work for you; I’d be interested in how you got there. |
James Pankhurst (8374) 126 posts |
Finding it was most of the problem. As I didn’t know what I was looking for, I looked at everything with “gcc”, but turned out I wanted the “cc1” settings instead. With the setting maxed, to 16386k, the first stage at least tried to run. Things then seem to do nothing as it executes a 2nd phase, sitting there letting me abort or pause, without any obvious progress or, for that matter, exactly what it was trying to do. I think some additional fiddling would let me make a setting/toolset that did what I was after, doing “gcc -mlibscl -o |
Paolo Fabio Zaino (28) 1853 posts |
If needed for !Sourcery there is a PDF manual here: https://www.reallysmall.co.uk/Downloads/categories/riscos/development/sourcery/srcrym.pdf?1463843619 Choices should be explained from page 107. This is also the official download page for !Sourcery and where to get help with it: https://www.reallysmall.co.uk/Pages/categories/riscos/development/sourcery.php In any case, one of the issue with !Sourcery is to keep the configuration up-to-date and the fact it doesn’t yet support any Git client (for which either !SImpelGit on RISC OS, or other git clients on other OSes are still required) Also as mentioned by James, there can be some confusion in understanding “where” to put the compiling options. Normally compiling options like -mlibscl should go with the specific projects, so not in the !Sourcery configuration (that is because some program may use the GNU extensions which won’t work with the RISC OS SCL and require the UnixLib etc.) My recommendation when using DDE is to learn how to use the Shared Makefiles (and we have a video that will come out soon on this specific topic). GCC uses GNUMake, which is very powerful, but that can be complex to handle, so if it’s needed we can add videos on how to use GNUMake on RISC OS, we asked people what they want and no one mentioned GNU Make.
I can assure you that Obeys are fine even with really complex projects, I use them even for the build of my UltimaVM (a really fast and multi-threaded byte code interpreter for RISC OS, Linux, BSD, macOS and Windows) which is composed by many C files and even distributed in a complex directory tree. It would have taken me ages to use Sourcery for this complex project, while GNU Make works wonders at auto discovery files that needs to be built in a certain way. Just my 0.2c here.
This makes sense. It would have been nice if Sourcery would have generated an easy to maintain configuration. However one nice feature is that if you install your libraries and stuff always in the same places, then you could copy a past !Sourcery config across multiple machines, but otherwise it’s a pain to reconfigure every time. Visual Studio has everything nicely pre-configured, so while they are both GUI based, I think there is a huge difference in how they handle the build process :( For the missing keys, if you need the symbols in an editor, you can you !VirtualKeybaord as already suggested OR, not many RISC OS users know that our traditional !Chars App can be used for the missing symbols… Just run !Chars, then click to get focus in a text area and then (with the mouse) click on the symbol in !Chars you want to add to your text in that text area, most editors should work fine with this technique (I haven’t tested many, ’cause I mostly use !StrongEd and !StrongEd works fine, particularly useful on a Mac when using RPCEmu) HTH |