PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Compiling with GCC but linking with eVC?

Is it possible to compile using the GCC compiler, and then take the output of GCC (the .s assembler or the .o files) and link them into a 'normal' eVC project?
I wouldn't imagine, especially since I've never heard of a gcc port for CE3.0 or ARMv4/5, but even if there is one, you would probably need to use it with its own linker. I'm not saying it is impossible, but as far as I know gcc isn't even an option.
warmi · 09 Mar 2003, 21:02 UTC — Uh ?
Never heard about gcc for arm ?
How do you think they compiled Linux for ipaqs, Sharp Zaurus and other pdas running ARM 4/5 CPUs.

But yeah, you are correct that you cannot take .o files and link them with eVC project ( nor you can do that with ASM since gcc uses slightly different rules for its asm output than does eVC.)
Bradskey · 09 Mar 2003, 23:15 UTC — Uh ?
warmi wrote:
Never heard about gcc for arm ?
How do you think they compiled Linux for ipaqs, Sharp Zaurus and other pdas running ARM 4/5 CPUs.

But yeah, you are correct that you cannot take .o files and link them with eVC project ( nor you can do that with ASM since gcc uses slightly different rules for its asm output than does eVC.)


Well yeah, that occurred to me after I posted, but the binaries it produces are for a Linux OS, not Win32.
Actually, if you have a look at the gcc sources you will find that there is a file "gcc\config\arm\arm-wince-pe.h".

This filename (and its contents) indicate that this is some sort of ARM target which uses the PE file format which is what WinCE uses (for executables).

I've seen this file a couple of times but never investigated further. Anyone know what this target is intended for/has been used for?

The major reason why I never looked further into this is that I wanted to replace the existing compiler completely. That would require the compiler to understand the MS specific keywords, SEH etc and gcc doesn't do that. Extending it to do so would also take quite a bit of work.
I thought that the Windows CE object files were just COFF format? (In which case GCC has an arm-coff utility)..

I'll definitely be investigating cross-compilation using GCC to compile for WinCE (compile vanilla C or ARM into an object file that EVC++ can link) in the near future (when my "new" toy arrives ;)).

If not, it probably wouldn't be too difficult to convert the .s output from GCC into something that the EV ARM assembler can cope with - I think I saw a converter that went GCC->ARM's SDK (maybe for the GameBoy Advance), and the MS ARM compiler's syntax is, to the best of my knowledge, identical...
Sergey Chaban · 10 Mar 2003, 17:58 UTC
Remember that if you use GCC (or any other compiler for that matter) you're pretty much limited to plain C, C++ name mangling for each compiler is completely different.

SC
angedelamort · 10 Mar 2003, 20:01 UTC
what is the main reason you want to compile with gcc instead of embedded?
angedelamort wrote:
what is the main reason you want to compile with gcc instead of embedded?


Well I personally probably wouldn't generally use it if it became a viable option, but it would be interesting to have a competing compiler and to see how this port of the renowned gcc stands up against eVC in code size, execution speed and other optimizations, plus the possibility of an included partial STL (although the STLPort for eVC30 works well for me).
angedelamort wrote:
what is the main reason you want to compile with gcc instead of embedded?


I want to because I have one of <a href="http://www.simtec.co.uk/products/EB110ATX/">these</a> and one of <a href="http://www.netwinder.org/cgi-bin/faq.cgi?req=show&file;=faq01.001.htp">these</a> and one of <a href="http://www.worldofwibble.com/aboutriscpc.html">these</a> (if I'm desperate), all with StrongARMs in them. The former two run NetBSD and Linux respectively (the latter runs "RISC OS" but it isn't all that useful as a development platform 'cos it's too slow with its paltry 16MHz (IIRC) bus).

If I can easily port stuff from GCC to embedded then my development platforms are rather nicer than a crappy botched Windows emulator (to my knowledge it won't play with ARM assembler code either) or a "limited" device like an iPAQ - i.e. they have "real" network, "real" keyboard and "real" video along with much more HD space. I originally bought the NetWinder for that purpose but it's all too useful sitting as my low-power firewall/router (what it was designed for) for me to crash it all the time messing around in Linux on it (those who think Linux can't be crashed easy, just try poking with "dodgy" framebuffer devices).

I'm toying with buying myself one of <a href="http://www.lart.tudelft.nl/">these</a> too (just for fun 8O ).

Cheers,

Ref.
(ARM fan-boi in case you hadn't noticed ;))
what is the main reason you want to compile with gcc instead of embedded?


Two words: compiler extensions :))

Plus the fact eVC puts spurious redundant lsl/lsr opcodes everywhere and slows everything down :((


I've seen mentioned that:
1) the object file format used by Microsoft compilers is called PE (Portable Executable)
2) PE is simply "COFF with extra headers" (COFF being Common Object File Format)

Now extrapolating information would that mean:
3) .obj is PE, and .o is COFF?
4) to convert .o to .obj, you must add some extra headers?
Is this correct? Any ideas on a tool to do this?
What happens if you use gcc and rename .o to .obj, will it just work??
Sergey Chaban · 11 Mar 2003, 03:17 UTC
Dave, why do you think those shifts are redundant?
I'm building with cross-gcc from time to time and it's not faster than eVT, quite opposite in fact.
Anyhow, you could build cross-gcc for CE, but it's quite painful.
Here is some howto, largely from memory.
First you will need both binutils and gcc packages, binutils needed because of cross-assembler and other tools (ar, ld) that will be used during GCC build.
You could build it under both Linux and Cygwin, but it's somewhat easier under Linux.
So you downloaded both gcc & binutils source (that's about 50 Megs),
now go to binutils dir and type the following:

./configure --target=arm-wince-pe --prefix=/gcc-ce

If you're building under linux and want to produce windows-hosted tool, you'll need to add --host=i686-pc (or something like that, perhaps "cygwin" must be added).

Replace gcc-ce with whatever location you want it to be installed.
After configure script is done, type "make install", most likely the build will fail in the GDB directory (always fails for me), then go to each tool's dir and build all needed tools one be one:
cd gas
make install
cd ../ld
make install
cd ../bfd
make install
cd ../binutils
make install

Now go to gcc dir and repeat "./configure --target=arm-wince-pe --prefix=/gcc-ce" "make install"
Under Cygwin you may have to edit some system files, because they lack some endianess defines for ARM target.
You may have to tweak some of the config files to exclude thumb & hardware FPU functions from libgcc build.
etc. etc. but with some luck ;) you'll get at least some of the tools in the gcc-ce dir - I just repeated these step with gcc 3.0.3 and managed to build C++ compiler and all the tools (I had to edit some stuff in lib1funcs.asm, but that's a hack, this could be fixed in config files).

After that you could link *.o files produced by compiler using Microsoft's linker, i.e. simply add them in the eVT IDE. Linker sometimes complains about some stuff in the object file, but I haver looked into it - it just works anyway.
However as I said above you're limited to C, e.g. you can't use GAPI lib from the GCC-compiled sources because GAPI export are C++ mangled names. Similary it's not possible to link C++ code compiled with GCC to eVC-compiled code (well it's actually possible but that's a lot hand-work).

I think I could send you precompiled binaries but this stuff is rather big.

SC
Sergey Chaban wrote:
Dave, why do you think those shifts are redundant?
...


I realise that in some case is it needed to preserve sign, however eVC clearly has bugs which puts extra lsl and lsrs into the code when sign preservation isn't needed at all.

For example I once had a loop which copied 16-bit values from a screen buffer to the physical screen (rotating orientation), and eVC was redundantly shifting these 16-bit values up and down. Surely a bug/problem with the C compiler?

I'll try and dig out the specific example sometime for you (has anyone else seen this by the way?)
Sergey Chaban · 11 Mar 2003, 12:30 UTC
however eVC clearly has bugs which puts extra lsl and lsrs into the code when sign preservation isn't needed at all.


Interesting, for sign-extension it would be lsl/asr (i.e. not lsr), right?

I found precompiled GCC binaries on the Rainer Keuchel's site. I think it will save you some time ;)
You'll need the following archives:
http://www.wince-devel.org/wince/gcc-3. ... nce-pe.zip
http://www.wince-devel.org/wince/gcc-li ... nce-pe.zip

You will need Cygwin as well.

If you want to build it yourself there are also some patches:
http://www.wince-devel.org/src/gcc-3.0. ... les.tar.gz

SC
Sergey Chaban wrote:
however eVC clearly has bugs which puts extra lsl and lsrs into the code when sign preservation isn't needed at all.


Interesting, for sign-extension it would be lsl/asr (i.e. not lsr), right?



Thanks for the pre-compiled cross-gcc link!
Yeah, for sign-extension lsl/asr would make sense, yet recently I've been seeing lsl/lsr pairs, which don't make any sense to me... Unless it's delay slots or something??
I can't remember what I was seeing in the unsigned short *pd,*ps; *pd=*ps; pd++; ps++; loop but I'll try to look it up when I get home

Hmm, I can't find it now. How strange - next time I see a spurious lsl/lsr I'll post it though
i came across this today. I don't have a redhat linux box to give it a try, but maybe some of you guys do. If this works i would be really interested in comparing gcc with the MS compiler.

cryo
Nice find. :)

I'll have to give it a go on my Mandrake i386 soon. Then I'll have to compile it on my ARM Debian or Redhat box ;)
Sergey Chaban · 14 Apr 2003, 18:47 UTC
I compiled this version to work under Windows (requires Cygwin).
It's here: http://mono.eurosoft.od.ua/wince/files/ ... .2.tar.bz2 (approx. 13 Megs).

There is also some test/benchmarking code: http://mono.eurosoft.od.ua/wince/files/ ... est.tar.gz
(this is DES cipher applied 50K times, compiled with both GCC3.2 and EVC4).

It appears to be much faster than older versions, definitely faster than 3.0.x.

Enjoy,
SC