Hi all,

I will try to explain my situation as simple as I can :))

- I have x86_64 Linux machine as host
- I want to compile tcc (from source, no prebuild binary) for running tcc
on that machine
- I have ARM Linux as target. I want to build my C code using tcc (on the
x86_64 machine) to run on that.

How can I do this?

I tried compiling tcc on the host machine using

```
./configure --cpu=arm
make -j8
```

but it failed with

```
perl ./texi2pod.pl tcc-doc.texi tcc-doc.pod
make[1]: Entering directory '/tmp/tinycc/lib'
../tcc -c bt-exe.c -o ../bt-exe.o -B.. -I..
pod2man --section=1 --center="Tiny C Compiler" --release="0.9.27"
tcc-doc.pod >tcc.1 && rm -f tcc-doc.pod
In file included from bt-exe.c:7:
../tccrun.c:1097: error: field not found: arm_pc
make[1]: *** [Makefile:85: ../bt-exe.o] Error 1
make[1]: Leaving directory '/tmp/tinycc/lib'
make: *** [Makefile:320: libtcc1.a] Error 2
make: *** Waiting for unfinished jobs....
```

But there is an executable `tcc` in the directory I'm compiling from. So I
create an useless C file (`ex0.c`):

```
int main(){return 0;}
```

and compile using that tcc executable:

```
./tcc ex0.c -o ex0.elf
/usr/lib/x86_64-linux-gnu/crt1.o: error: invalid object file
tcc: error: file 'crt1.o' not found
/usr/lib/x86_64-linux-gnu/crti.o: error: invalid object file
tcc: error: file 'crti.o' not found
/lib/x86_64-linux-gnu/libc.so.6: error: bad architecture
/usr/lib/x86_64-linux-gnu/libc.so.6: error: bad architecture
/lib/x86_64-linux-gnu/libc.so.6: error: bad architecture
tcc: error: /usr/lib/x86_64-linux-gnu/libc.so: unrecognized file type
/lib/x86_64-linux-gnu/libc.so.6: error: bad architecture
/usr/lib/x86_64-linux-gnu/libc.so.6: error: bad architecture
/lib/x86_64-linux-gnu/libc.so.6: error: bad architecture
tcc: error: /lib/x86_64-linux-gnu/libc.so: unrecognized file type
tcc: error: libtcc1.a not found
/usr/lib/x86_64-linux-gnu/crtn.o: error: invalid object file
tcc: error: file 'crtn.o' not found
```

How can I do this without an ARM/ARM64 Linux host?
I also have ARM64 Linux host, but I want to use on x86_64 host

Also, it's possible to do this on Windows? I want to compile C code using
tcc on x86 Windows to output ARM ELF for Linux (It's likely not possible,
so feel free to skip that)

Thank you so much!
giangvinhloc610
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to