-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Official RaspberryPi Package #19
Comments
Just realised TCC doesn't support ARM. |
Actually the current repo of TCC does support ARM partly, though I'm not sure of it's completion level. Code written for CToy should compile easily to RasperryPi with GCC but I don't have the hardware to test all this. Volunteer welcomed :) |
Thanks for getting back to me. Good to know it's not a lost cause. I'm happy to test anything and report back on the result. I have the 3B+ and the RPi Zero, so could test perf at both ends of the spectrum, assuming I can get CToy up and running. I would need a few pointers though. To be honest, I'm a bit of a script wizard. I've been coding nearly ten years, but it's all very high level languages and full-stack Web stuff. I make the money, but feel like a bit of a fraud. I'm learning C now, but am still new to it all, so it may be more trouble than it's worth to guide me through this stuff. I'll obviously understand if you're too busy to hold my hand right now. Assuming I go with the GCC option, should I try and edit CToy to use GCC instead of TCC and use CToy as normal, or should I compile |
Sorry for the confusion. I just worked out that CToy already supports using other compilers; I just don't know how that works?? |
Let's first try to compile tcc, download this fork of tcc on your rasbi : Follow the instructions, it should be something like : Eventually what is needed for CToy is to get a build of "libtcc" as a dynamic library. |
@carlsmith, just in case TCC doesn't work on Raspberry Pi and you still want to develop on that platform, you can take a look to raylib, it's similar to CToy in several aspects... |
Thank guys. I'll spend some time trying to get CToy working, and see how that goes (keeping raylib in mind as a fallback). |
I couldn't get TCC to build on my RPi, and didn't really understand the error messages, and gave up. I can use CToy on my Mac for now, so I'm cool personally. I can try this again once I have a better idea of what I'm doing. It's a shame though; it'd be nice to see CToy on RPi at some point. |
Looking through the log, it looks like the |
I stumbled upon this thread, basically attempting to do the same thing: would like to run CToy on a raspberry pi. Set about cloning the repository and building it per the instructions. Choked when it hit libtcc.so A quick google search found me: https://github.com/Alex2804/libtcc-cmake (looks to be a fork of tcc 0.9.27) Cloned and built that (default is to build a static libtcc.a, a cmake config option can change that to shared libtcc.so). Copied that libtcc.so into 3rdparty/libtcc/linux, replacing the x86_64 instance of the library that was there, mimicked the architecture subdirectory and placed the static lib there. CToy still fails, but on linking CToy_player:
I've dealt with linking libraries before, but I guess I need some better awareness of this project: I'm far less familiar with cmake and its inner-workings... in traditional builds I'd just find the particular gcc line in question, copy it, manually edit it to suit my needs, and accomplish said step, and resume the But here in CToy I am struggling to locate the individual actions instantiated by the build system. I ran Basically: if I managed to build an architecture-specific libtcc.so that I desire to use in building CToy for said architecture (Raspberry Pi), how do I convince the existing CToy build system to see and use that? |
An update: after diving through the labyrinth of CMake files, I finally located the
|
First you need to use this fork of tcc : https://github.com/anael-seghezzi/tcc-0.9.26 You can build libtcc.so and libtcc1.a using make
you should copy libtcc.so and libtcc1.a in a new folder, for example CToy\3rdparty\libtcc\rpi
|
First of all: thank you for your response. I know this thread, and the overall repository, haven’t been active in a while. I only stumbled upon CToy a couple months ago, and only got around to actually playing with it this week. I hope it can be made to work, and then can be made to work in the manner I am intending (one issue at a time, though). Actually I think I first tried this one, as you had mentioned it earlier in the thread. Seems to get near the end, then:
With the exact same issue for what looks like each of the other .o files trying to be linked: tccgen.o, tccelf.o, libtcc.o, tccasm.o, tccrun.o, arm64-gen.o Which of course stops the build:
I checked tcc.h and you’ve got the #ifndef guards in place. Compiling with:
I want to say I experienced a somewhat issue with some code of mine where I was trying to build libraries at the end (static AND shared), and it was with some change introduced in gcc 10; versions prior didn’t have the issue. If memory serves, I needed to use I suppose I could try installing gcc-9 to see if that’ll work without complaint; sure would love to know what other detail I’m missing with gcc-10 though. Anyway… off to try it with gcc-9, I’ll report back when I have something to report. |
QUESTION: do I need to be building both Admittedly, the thought only just occurred to me. I did try to build
Build failures still occur, but after a static, then shared library were able to be built. Attempted integration into CToy, but still failed on linking CToy_Player with similar missing symbols as above. I likely am still trying to build CToy with |
okay; excellent thing about this endeavour is that I’m finally learning about I managed to produce a I copied these files into CToy/3rdparty/, although modelling things after your I dug around the CMakefiles… actually I grepped through the ENTIRE source tree, found any and all references to I then proceeded to do a fresh build of CToy with The same two missing symbols:
Using Your The I had a thought to actually try building CToy with the I guess at this point I could confirm whether or not a fresh build of tcc on a linux/x86_64 machine yields a libtcc.so.1 that includes those symbols (initial suspicion: that it doesn’t). I’ve never dived that deep into ELF headers, I’m assuming it is acting as a sort of table of contents, so they are merely representing an offset to some other code. Although I would guess rather specific code, so I wouldn’t expect it to be already existing, and I could just force in some symbols to point at. I don’t feel that well versed in x86_64 assembly (nor arm64 assembly) to try and attempt crafting the necessary logic, editing/wrangling on the binary libtcc.so.1 Not sure if the build is shortly done after CToy_player; I’ve not yet tried to trick it into thinking success to see what is next, but I’d assume the exact same issue would be present for the main I suppose I can try and sort through the |
x86_64 tests: I was able to build your I have seen them in the code as well, which leads me to wonder:
I have been doing some scans through the code looking for any obvious signs, an #ifdef/#ifndef for x86_64 that involves Thinking it may be something as simple as this. Find it, write some conditional to include it in arm64 (or all) builds, and away we go. Assuming said change isn’t based on any architecture-specific assembly. |
It's possible that if tcc_relocate and tcc_run are missing you are trying to cross-compile libtcc. Both libtcc and CToy are to be compiled with gcc (or clang), no need to compile with tcc itself |
SUCCESS! Although, not sure which variable did the trick (I’ll attempt a clean build of everything again later). For now, the two seemingly significant things I did:
Next thing I knew, I replaced them in the CToy source tree, continued my build there, where it quickly linked I edited them out (as follows), and it then worked:
I now have a working raspberry pi build of CToy! Thank you so much for your help. I will attempt another fresh build from scratch, to verify my ability to build with known details and understanding and confirm. |
Okay, I think I’ve gotten the bulk of build details successfully figured out and verified. You were right:
I was right:
Here’s a good thread talking about the issue: freeglut/freeglut#86 Line 232 on the This may actually impact ANYONE trying to build Onwards into the
I wrote myself a fetch and build script, so it performs all these workarounds, and gets everything built. I’m now at the point of trying to run
Actually, I satisfied the
Ran it and… “Hello, World!” printed to the console, then So close. I’ve booted back up with my 64-bit kernel, and am going to try the build again ( I’ll… report back again should this be successful or not. |
Successful build, 32- and 64-bit ARM on raspberry pi, but no love on actually running it. I get the same result, regardless of kernel:
At this point this seems like a deeper code-related issue. There were certainly a number of warnings during build, including one file with what looked like an Seems really close though. Be a shame not to get this going. I may also try and look up what modifications you made in your Just to collect related/useful information in one place, this raspberry pi forums thread was quite helpful with respect to sussing out some of the Anything else and I’d have to start knowing more specifics about how CToy is working. Thanks for the feedback. Any other suggestions? As I said, I’d really love to see this going. I’d like to put it to use in the classroom. Be a great instant feedback sort of thing as students are learning and experimenting. |
Thanks a lot for the effort and the report. It's good progress ! For the crash, I'm thinking that the local paths are not set properly, so it could be that when hello_world.c is trying to load "data/hello_world.png" it breaks, although it should print the error "ERROR CTOY: unable to read image". The other possibility is that tcc on ARM is just not complete... The "Illegal instruction" error is worrying. |
I'm also not sure you should try to build aarch64 if your processor is 32 bit, regardless of the kernel. |
Thank you again for the continued suggestions. I will try sample demo 6 and report back. If that fails, I will try the latest My pi is the 4B model, 64-bit CPU, it is just that the stable raspiOS still uses a 32-bit user land (32-bit libc). I suspect the 64-bit kernel on 32-bit userland is somewhat similar to the old intel PAE extensions allowing greater memory addressing, during similar hardware/OS transitional phases in the past. The full 64-bit kernel + userland distro is still in testing. I’d personally run it, but all my students are still running the 32-bit distro due to stability, so for now I’m definitely needing to compile it for 32-bit userland. Typically this causes no problems: when running in 64/32, binaries compiled work with other 32-bit resources, although it thinks it is aarch64 enough to trick But, the issue could well be As always, I will try and report back. |
Further environment details: It seems Okay, a change: I seem to have gotten rid of the Sample 1, sample 6, using Not even the “Hello, World!” to the console. Although there’s a new issue I am having to troubleshoot- during runtime, it now pops up a message:
Which considering its likely importance, is needing to be addressed. Thing is: I’ve put it in place. Not getting any path information, so I don’t know where it is trying to source it from. I compiled everything with debug support and have been following the execution in But: I seem to remember there being a kernel trace tool that reports system calls used ( |
Looks like Easy enough! Copied So, a successful build and execution of In the attempt to build
Question: how involved were your changes to I’ve started looking through your changes (simultaneously learning to use the Am I right in that you added For example, this from
I’m assuming that |
Good ! The most important modification I made is a hack to detect file change (tcc_set_io_read, tcc_set_io_lseek, tcc_set_io_close) > not very complicated to replicate. I also made some minor changes to tcc compilation to avoid calls to exit(0) when compilation fails, but it's not as essential. |
Having issues getting this to compile on a Macbook Air M2. No matter what compiler I pick, conftest.c fails to compile during the configure step and make itself errors out with |
My initial guess is that you are likely running into the same issues I was trying to get this built on the pi: ARM support for that modified fork of In my view, after the many back and forths with Anael in this thread, what may be the ideal path forward is to take a more recent version of You should be able to get the I also have a MacBook air M2, and dusting off my notes and trying a build on my Mac shouldn’t take too long, and I should have some time today to attempt this (unless I get overrun with a surge of students having questions during finals week). I will report back after I have poked at it. |
Okay, just pulled up my notes and attempted a build on my Macbook air M2 (macOS 14.2, Xcode command line tools clang 1500.1.0.2.5)... and I encountered the same error you did.
Looking in broader context, it looks like it is attempting to capture the boolean result of that comparison (ie "do we have a capable-enough ARM processor"). I short-circuited this by simply forcing it to true (I assume 1 is true):
I went and looked further into this Looks like To fix it, edit
It then built through to the final attempt to produce the library then failed, not liking a few of the options. I tried to salvage it in similar ways I was trying on the pi, and got it to produce a
Then attempted to built |
A lot of people are interested in running fantasy consoles on RPi, as an easy way of creating games that will run well on limited hardware. Something similar, based on C, could be popular.
The text was updated successfully, but these errors were encountered: