[cfe-dev] Getting started with clang
Robert Wuest
rwuestfc at wuest.org
Mon Aug 17 08:46:35 PDT 2009
Hi,
I'm just getting started with clang and having some problems. I'm
trying to build a compiler to run on x8_64 and gen code for the
powerpc. My goal is to make some changes to the ppc code generator, but
I'm not off to a very good start.
I have the latest source tree of llvm and clang from subversion and
followed the build instructions. This definitely produces a working
native compiler as seen here:
$ clang hello.c
$ ./a.out
Hello, world
However, when I try the '-arch ppc' option, it still only produces
x86_64 code:
$ rm a.out
$ clang -arch ppc hello.c
clang: warning: argument unused during compilation: '-arch ppc'
$ ./a.out
Hello, world
I am also seeing different output than that shown in the
DriverInternals.html document that comes with clang. In the "Driver
Stages" section, there is an example I followed and get very different
result from the doc:
Trying to get identical output, I broke hello world into 2 source files.
It's trivial source; main() just calls hello() in f_hello.c. I know they
compile:
$ rm a.out
[rwuest at garion hello]$ clang main.c f_hello.c
[rwuest at garion hello]$ ./a.out
Hello, world
However, the print-phase option with arch statements has no "bind-arch
in the output (as indicated in the DriverInternals.html doc):
$ clang -ccc-print-phases -c -arch i386 -arch x86_64 main.c f_hello.c
0: input, "main.c", c
1: preprocessor, {0}, cpp-output
2: compiler, {1}, assembler
3: assembler, {2}, object
4: input, "f_hello.c", c
5: preprocessor, {4}, cpp-output
6: compiler, {5}, assembler
7: assembler, {6}, object
Have I missed something?
Robert
More information about the cfe-dev
mailing list