分享

Tinycc

 quasiceo 2015-01-14

Using tcc for C development on Android tablet

Hello tcc devs,

For a while, I've been looking for a way to write (and test)
small programs in C on an Android tablet. Recently, I found
an app (based on tcc) which allows exactly that, and I started
wondering how it is done.

Android platforms are mostly based on ARM or MIPS CPUs (though
Intel has now ported Android to x86). I don't think tcc has ARM
and MIPS code generators, right? So I assume that the C code is
not actually compiled into machine code, but instead interpreted
"on the fly" using tcc's script mode. Would that seem like a
reasonable guess?

On to the app itself. Since it runs on Android, then either tcc
has been ported to Java so it can run on any Android system as
byte code, OR it has been compiled as a C++ app using the native
SDK (but then there would have to be one for ARM and one for MIPS).
Which is more likely? And did I miss other possibilities?

--
Thomas Preud'homme | 20 Sep 14:57 2012
Picon

Re: Using tcc for C development on Android tablet

Le jeudi 20 septembre 2012 13:04:54, Mason a écrit :
> Hello tcc devs,
> 
> For a while, I've been looking for a way to write (and test)
> small programs in C on an Android tablet. Recently, I found
> an app (based on tcc) which allows exactly that, and I started
> wondering how it is done.
> 
> Android platforms are mostly based on ARM or MIPS CPUs (though
> Intel has now ported Android to x86). I don't think tcc has ARM
> and MIPS code generators, right? So I assume that the C code is
> not actually compiled into machine code, but instead interpreted
> "on the fly" using tcc's script mode. Would that seem like a
> reasonable guess?

Tinycc does support arm CPUs. Right now it support 2 calling convention : the 
old ABIS and the base EABI calling convention. It should also support 
soon(ish) the standard variant EABI calling convention. To be more precise, it 
already supports this calling convention but there is some relocation missing 
for the linkage to work. I'm actually working on it though, and I hope to 
provide a patch in 1-2 weeks if everything goes well.

Since android uses the base EABI calling convention, it should work fully on 
android/ARM.

> 
> On to the app itself. Since it runs on Android, then either tcc
> has been ported to Java so it can run on any Android system as
> byte code, OR it has been compiled as a C++ app using the native
> SDK (but then there would have to be one for ARM and one for MIPS).
(Continue reading)

Mason | 20 Sep 16:47 2012
Picon

Re: Using tcc for C development on Android tablet

Thomas Preud'homme wrote:

> Mason wrote:
>
>> For a while, I've been looking for a way to write (and test)
>> small programs in C on an Android tablet. Recently, I found
>> an app (based on tcc) which allows exactly that, and I started
>> wondering how it is done.
>>
>> Android platforms are mostly based on ARM or MIPS CPUs (though
>> Intel has now ported Android to x86). I don't think tcc has ARM
>> and MIPS code generators, right? So I assume that the C code is
>> not actually compiled into machine code, but instead interpreted
>> "on the fly" using tcc's script mode. Would that seem like a
>> reasonable guess?
> 
> Tinycc does support arm CPUs. Right now it support 2 calling convention : the 
> old ABIS and the base EABI calling convention. It should also support 
> soon(ish) the standard variant EABI calling convention. To be more precise, it 
> already supports this calling convention but there is some relocation missing 
> for the linkage to work. I'm actually working on it though, and I hope to 
> provide a patch in 1-2 weeks if everything goes well.
> 
> Since android uses the base EABI calling convention, it should work fully on 
> android/ARM.

IIUC, it is possible to use tcc on an ARM-based Android system,
to produce ARM machine code which can be run locally?

So you'd guess the Android application (C4droid) is simply generating
(Continue reading)

Thomas Preud'homme | 20 Sep 17:30 2012
Picon

Re: Using tcc for C development on Android tablet

Le jeudi 20 septembre 2012 16:47:32, Mason a écrit :
> IIUC, it is possible to use tcc on an ARM-based Android system,
> to produce ARM machine code which can be run locally?

Absolutely, that's what I mean.

> So you'd guess the Android application (C4droid) is simply generating
> native ARM code, and running the resulting binary?

I'm not sure what does the application in the first place. Does it (compile and 
then) run a source code you give it?

If yes I would assume it's used via the -run switch or script mode as you call 
it.

> In that case, the app would not work on MIPS-based Android systems.
> (Because tcc cannot output MIPS machine code.)

Exactly. Script mode or not, it's not possible. Script mode works by outputing 
the binary in memory instead of doing it in a file and then executing this 
binary by calling the main function of this binary.

> In my example, tcc is not a cross-compiler, it would generate binaries
> for the same architecture it was compiled for. Thus for ARM-based systems,
> it would be compiled for ARM and generate ARM binaries.
> 
> Even though I could compile tcc for MIPS, it is pointless if it cannot
> generate MIPS machine code to run my compiled programs.

Yes absolutely. I mentionned this possibility to explain the difference between 
(Continue reading)

Mason | 20 Sep 17:50 2012
Picon

Re: Using tcc for C development on Android tablet

Thomas Preud'homme wrote:

> Script mode works by outputing the binary in memory instead of doing
> it in a file and then executing this binary by calling the main
> function of this binary.

Ah OK OK OK!! (à la JPP). I had naively imagined that script mode worked
as an interpreter, and thus worked on any platform. (Like bash interprets
shell scripts.)

--
David Mertens | 22 Sep 02:39 2012
Picon

Re: Using tcc for C development on Android tablet

I believe ROOT can run c++ code in an interpreted mode. It's an open source project developed be CERN that gets a lot of use in the high-energy physics community. Whether it compiles and runs on ARM, and more importantly whether there is an Android app for it, is anyone's guess.

Seems like either of these might make a great candidate for SL4A.

David

On Sep 20, 2012 10:50 AM, "Mason" <mpeg.blue-GANU6spQydw@public.> wrote:
Thomas Preud'homme wrote:

> Script mode works by outputing the binary in memory instead of doing
> it in a file and then executing this binary by calling the main
> function of this binary.

Ah OK OK OK!! (à la JPP). I had naively imagined that script mode worked
as an interpreter, and thus worked on any platform. (Like bash interprets
shell scripts.)

--
Regards.


_______________________________________________
Tinycc-devel mailing list
Tinycc-devel-qX2TKyscuCcdnm+yROfE0A@public.
https://lists./mailman/listinfo/tinycc-devel
<div>
<p>I believe ROOT can run c++ code in an interpreted mode. It's an open source project developed be CERN that gets a lot of use in the high-energy physics community. Whether it compiles and runs on ARM, and more importantly whether there is an Android app for it, is anyone's guess.</p>

<p>Seems like either of these might make a great candidate for SL4A.</p>
<p>David</p>
<div class="gmail_quote">On Sep 20, 2012 10:50 AM, "Mason" <<a href="mailto:mpeg.blue@...">mpeg.blue@...</a>> wrote:<br type="attribution"><blockquote class="gmail_quote">
Thomas Preud'homme wrote:<br><br>
> Script mode works by outputing the binary in memory instead of doing<br>
> it in a file and then executing this binary by calling the main<br>
> function of this binary.<br><br>
Ah OK OK OK!! (&agrave; la JPP). I had naively imagined that script mode worked<br>
as an interpreter, and thus worked on any platform. (Like bash interprets<br>
shell scripts.)<br><br>
--<br>
Regards.<br><br><br>
_______________________________________________<br>
Tinycc-devel mailing list<br><a href="mailto:Tinycc-devel@...">Tinycc-devel@...</a><br><a href="https://lists./mailman/listinfo/tinycc-devel" target="_blank">https://lists./mailman/listinfo/tinycc-devel</a><br>
</blockquote>
</div>
</div>
Milutin Jovanovi? | 24 Sep 18:08 2012
Picon

Re: Using tcc for C development on Android tablet


Picoc does a decent job of interpreting (most of) C. It has several down sides, but it is an interpreter.

https://code.google.com/p/picoc/

Miki.



On 21 September 2012 20:39, David Mertens <dcmertens.perl-Re5JQEeQqe8AvxtiuMwx3w@public.> wrote:

I believe ROOT can run c++ code in an interpreted mode. It's an open source project developed be CERN that gets a lot of use in the high-energy physics community. Whether it compiles and runs on ARM, and more importantly whether there is an Android app for it, is anyone's guess.

Seems like either of these might make a great candidate for SL4A.

David

On Sep 20, 2012 10:50 AM, "Mason" <mpeg.blue-GANU6spQydw@public.> wrote:
Thomas Preud'homme wrote:

> Script mode works by outputing the binary in memory instead of doing
> it in a file and then executing this binary by calling the main
> function of this binary.

Ah OK OK OK!! (à la JPP). I had naively imagined that script mode worked
as an interpreter, and thus worked on any platform. (Like bash interprets
shell scripts.)

--
Regards.


_______________________________________________
Tinycc-devel mailing list
Tinycc-devel <at>
https://lists./mailman/listinfo/tinycc-devel

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel-qX2TKyscuCcdnm+yROfE0A@public.
https://lists./mailman/listinfo/tinycc-devel


<div>
<br>Picoc does a decent job of interpreting (most of) C. It has several down sides, but it is an interpreter.<br><br><a href="https://code.google.com/p/picoc/">https://code.google.com/p/picoc/</a><br><br clear="all">Miki.<br><br><br><br><div class="gmail_quote">On 21 September 2012 20:39, David Mertens <span dir="ltr"><<a href="mailto:dcmertens.perl@..." target="_blank">dcmertens.perl@...</a>></span> wrote:<br><blockquote class="gmail_quote">
<p>I believe ROOT can run c++ code in an interpreted mode. It's an open source project developed be CERN that gets a lot of use in the high-energy physics community. Whether it compiles and runs on ARM, and more importantly whether there is an Android app for it, is anyone's guess.</p>

<p>Seems like either of these might make a great candidate for SL4A.</p>
<span class="HOEnZb">
<p>David</p></span><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On Sep 20, 2012 10:50 AM, "Mason" <<a href="mailto:mpeg.blue@..." target="_blank">mpeg.blue@...</a>> wrote:<br type="attribution"><blockquote class="gmail_quote">

Thomas Preud'homme wrote:<br><br>
> Script mode works by outputing the binary in memory instead of doing<br>
> it in a file and then executing this binary by calling the main<br>
> function of this binary.<br><br>
Ah OK OK OK!! (&agrave; la JPP). I had naively imagined that script mode worked<br>
as an interpreter, and thus worked on any platform. (Like bash interprets<br>
shell scripts.)<br><br>
--<br>
Regards.<br><br><br>
_______________________________________________<br>
Tinycc-devel mailing list<br><a href="mailto:Tinycc-devel@..." target="_blank">Tinycc-devel <at> </a><br><a href="https://lists./mailman/listinfo/tinycc-devel" target="_blank">https://lists./mailman/listinfo/tinycc-devel</a><br>
</blockquote>
</div>
</div></div>
<br>_______________________________________________<br>
Tinycc-devel mailing list<br><a href="mailto:Tinycc-devel@...">Tinycc-devel@...</a><br><a href="https://lists./mailman/listinfo/tinycc-devel" target="_blank">https://lists./mailman/listinfo/tinycc-devel</a><br><br>
</blockquote>
</div>
<br>
</div>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多