Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)

Hello Philipp,

Does that mean that I will have to configure llvm as a cross-compiler
even when using the C backend?

Not llvm, but llvm-gcc only. I've successfully used llvm-gcc for
crosscompiling with host=linux and target=mingw32 platform.

So, you have just to supply host, build and target triples to llvm-gcc
configure and be also sure, that configure will find target headers,
libraries and binutils (e.g. for mingw32 I'm copying mingw32 runtime,
cross-binutils & libraries to build directory).

Anton Korobeynikov schrieb:

Hello Philipp,

Does that mean that I will have to configure llvm as a cross-compiler
even when using the C backend?

Not llvm, but llvm-gcc only. I've successfully used llvm-gcc for
crosscompiling with host=linux and target=mingw32 platform.

So, you have just to supply host, build and target triples to llvm-gcc
configure and be also sure, that configure will find target headers,
libraries and binutils (e.g. for mingw32 I'm copying mingw32 runtime,
cross-binutils & libraries to build directory).

Why does it need target libraries and binutils? Can't I just Compile my
C++ code to C code (maybe using a template-only libstdc++, so I won't
have to link it) and then compile the resulting C code with sdcc and
link it to C libraries compiled directly with sdcc. I don't want to pass
my C libraries through LLVM since LLVM makes the code more inefficient
and they're partially written in assembler.

Philipp

Hello Philipp.

Why does it need target libraries and binutils?

gcc building process (and llvm-gcc4 as well) includes building of
target-specific stuff including:

1. Building crt-support code on several platforms
2. Building libgcc.a[.so]
3. Building libstdc++.a[.so]

If you don't want them to be built you should, probably you should
consult gcc documentation to find right options or change build scripts.

Can't I just Compile my C++ code to C code (maybe using a template-only
libstdc++, so I won't have to link it) and then compile the resulting C
code with sdcc and link it to C libraries compiled directly with sdcc.

Surely you can as soon as you have working llvm-gcc4.

Anton Korobeynikov schrieb:

Hello Philipp.

Why does it need target libraries and binutils?

gcc building process (and llvm-gcc4 as well) includes building of
target-specific stuff including:

1. Building crt-support code on several platforms

I don't think I need this. I wrote my own crt0.o in assembler.

2. Building libgcc.a[.so]

Why do I need this?

Philipp