[cfe-dev] Getting started with clang

Robert Wuest rwuestfc at wuest.org
Tue Aug 18 10:56:28 PDT 2009


This does the trick.  At least for assembly output. Thanks.

On 08/18/2009 12:53 AM, Daniel Dunbar wrote:
> Hi Robert,
>
> The problem you are seeing is that -arch is not supported on
> non-Darwin platforms, and the driver just ignores it.
>
> -arch implies more than just a way to target a different architecture.
> My long term goal is to add a '-triple' option which will be the user
> level option for targeting a separate architecture, portably. You can
> see my basic plan at:
>    llvm.org/PR4127
>
> For now, although I hate to recommend this, it is possible to use the
> '-ccc-host-triple' to do what you want:
> --
> ddunbar at giles:tmp$ echo "void f0(){}" | clang -ccc-host-triple
> powerpc-unknown-unknown -x c - -S -o -
> 	.file	"-"
>
>
> 	.text
> 	.global	f0
> 	.type	f0, @function
> 	.align	2
> f0:
> 	blr
> 	.size	f0,.-f0
>
> --
> but this was never really the purpose of -ccc-host-triple...
>
> The real purpose of -ccc-host-triple, lest anyone care, was to have a
> way to tell the driver to pretend that it was on a different host
> system, for testing purposes. So you can also just tell the driver it
> is on Darwin and then -arch will work. :)
> --
> ddunbar at giles:tmp$ echo "void f0(){}" | clang -ccc-host-triple
> i386-apple-darwin9 -arch ppc -x c - -S -o -
> 	.machine ppc
> 	.section	__TEXT,__textcoal_nt,coalesced,pure_instructions
> 	.section	__TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
> 	.section	__TEXT,__text,regular,pure_instructions
>
>
> 	.globl	_f0
> 	.align	4
> _f0:
> 	blr
>
> 	.subsections_via_symbols
>
> --
> this only works up to a point, of course...
>
>   - Daniel
>
> On Mon, Aug 17, 2009 at 8:46 AM, Robert Wuest<rwuestfc at wuest.org>  wrote:
>> 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
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>




More information about the cfe-dev mailing list