![]() |
#1 |
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 23
Karma: 22222
Join Date: Oct 2010
Device: kindle3
|
tiny C compiler on the kindle
I have prepared a version of the Tiny C compiler (tcc) that can run on the Kindle.
You can find it at http://info.iet.unipi.it/~luigi/kindle/#TCC-for-Kindle For those who don't know, tcc is a single, small binary that can compile and runs C code on the fly. The only serious impairment (common to all C compilers) is that you often need a ton of headers to build anything useful; however, i am preparing a workaround which allows you to put all the definitions in a single file and ignore errors for missing headers. For those who want to give it a try -- the tarball contains the compiler, tcc, and some tiny objects (crt*.o) which you should put in /usr/lib (they are not needed if you just want to run code on the fly). Then edit your favourite hello world program and run it with tcc -run helloworld.c |
![]() |
![]() |
![]() |
#2 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Nice!
![]() I'll stick with my usual full fledged cross toolchain, but, still, it might be nice for on-the-fly very small C utils ![]() |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 35
Karma: 1566
Join Date: Nov 2010
Device: kindle 3wifi
|
Quote:
scratchbox-toolchain and sourcecody doesn't compile the simple helloworld the cross-compiler coming with ubuntu did compile, but it produced a segment fault on kindle at frame_dummy(). |
|
![]() |
![]() |
![]() |
#4 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
@kindle3zeng: I use a cross (right now, with an i686 GNU/Linux host) toolchain built using the crosstool-ng tool.
The actual config/shell history of the current build I'm using is detailed in the kindle-x-tc.tar.gz archive attached here. Unless you build against glibc 2.5 (which I don't), you may have to use some trickery to avoid pulling more recent GLIBC_* symbols on some projects. |
![]() |
![]() |
![]() |
#5 |
Confused
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 402
Karma: 5538
Join Date: Oct 2010
Location: Bay Area
Device: Kindle DXG
|
that and it might take like 10 hours to compile some stuff =X
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 35
Karma: 1566
Join Date: Nov 2010
Device: kindle 3wifi
|
Quote:
I compiled a toolchain with glibc with crosstool-ng. and right now I am trying to compile one with the glibc 2.5 from amazon. |
|
![]() |
![]() |
![]() |
#7 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Note that you can probably pretty much replicate the Kindle toolchain (gcc 4.1.2/glibc 2.5/Linux 2.6.22) with ct-ng if you enable the 'deprecated' option, no need to build it manually from amazon's tarballs.
And, unless you intend to build a whole lot of crap, you'll probably be good to go with a recent TC. I haven't yet hit a real TC related ABI mismatch showstopper with what I built so far. And I'm really, really not a fan of using a 3.5 years old TC, so I'm glad I haven't had to use a GCC 4.1 based TC ![]() Granted, with a kindle-like (ie. old) TC, at least you'll be mostly 100% sure it will run without issue on the Kindle, which is not really the case with my current TC, but, hey, where's the fun in that? ![]() Last edited by NiLuJe; 11-13-2010 at 03:46 PM. |
![]() |
![]() |
![]() |
#8 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 130
Karma: 10000
Join Date: Mar 2012
Device: Kindle 3G, Kindle Touch 3G, iRiver Story HD, Sony Reader
|
Hi,
I got hello world to run, but only once, and then get illegal instruction the second time. Also, do you have the header files? Thanks, James |
![]() |
![]() |
![]() |
#9 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
I packaged up lrizzo's tcc build, with the tinycc headers and the amazon gpl 5.0.0 headers, plus I added install and uninstall scripts, and a tccmake script to add the header include path and bind-mount a tcc-compatible replacement libc.so loader script needed to use this on newer kindles. I also include a demo.c program in the package, so it is ready to compile and test immediately after installing.
Although my demos run several times faster when compiled with a cross-toolchain, using tinycc (tcc) on the device is a LOT easier for development and testing, then doing a full cross-build for final distribution. ![]() Last edited by geekmaster; 04-20-2012 at 12:36 AM. |
![]() |
![]() |
![]() |
#10 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
The tcc download link link at lrizzo's web page linked above is missing a tilde ('~') character. You can get his program packaged with an installer and with everything you need to use it on all eink kindles, at the link provided in my previous post above.
![]() Last edited by geekmaster; 04-20-2012 at 01:16 AM. |
![]() |
![]() |
![]() |
#11 | |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#12 | |
Junior Member
![]() Posts: 1
Karma: 10
Join Date: Apr 2018
Device: PW2
|
Quote:
Downloaded the geekmaster package with the highest version number. tccmake of demo.c and then executing it seg fault. tccmake of my helloworld was okay. So then I went a little more complex and tried an eightball app my friend wrote and it was successful. Then I really pushed it by trying my eslisten program which uses pthread. To my surprise stat and fstat weren't available as unfindable by the linker. Pulling the libs to my computer and dumpobj it was confirmed as truth. Then, after seeing what linaro's cross compiler did with those function calls via hex editing the binary and searching stat came to know about __xstat and __fxstat. After doing the needful, it successfully ran! tldr; if you have to use stat, then use __xstat(3, filename, &statstruct); and if fstat then use __fxstat(3, filehandle, &statstruct); |
|
![]() |
![]() |
![]() |
#13 |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Did you notice you are posting to an eight year old thread?
Did it occur to you that there might have been changes/updates/corrections to tinyc in the past eight years? Translation: Mostly you are wasting your time by not using what is current. Posting in a current thread (which you create, they are cheap here) what you find the current situation to be. |
![]() |
![]() |
![]() |
#14 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 475
Karma: 445678
Join Date: Feb 2010
Device: Too many..
|
@jmiller099: demo.c doesn't work on PW1, PW2... but works OK on PW3, KT3! Maybe the code needs to be tweaked to suit the 1024x758 resolution.
@knc1:The version here is 0.9.25. The mainstream version was bumped up to 0.9.27 in Dec-17. |
![]() |
![]() |
![]() |
Tags |
tcc, tinycc |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Compiler Notes On James Branch Cabell | Greg Anos | Reading Recommendations | 0 | 01-20-2010 11:18 AM |
Kindle helps tiny e-book market | bookwormfjl | News | 7 | 04-04-2008 04:46 PM |
Kindle boosts tiny e-book market | Kingston | Amazon Kindle | 0 | 04-04-2008 02:13 PM |
iLiad How can I use iRex's cross-compiler toolchain? | yokos | iRex Developer's Corner | 8 | 12-11-2006 06:53 PM |
iLiad iLiad cross-compiler toolchain available from iRex | Matthijs | iRex Developer's Corner | 16 | 10-29-2006 02:25 PM |