clang and -integrated-as

Hello,

After the post about LLVM-MC, I tried to play with the “-integrated-as” flag.
Unfortunately, it does not works for a simple case which is an obj-c file with a class and a category to extend this class (on i386).

@interface Foo { void *isa; } @end
@implementation Foo
@end

@implementation Foo (Bar)
@end

clang -arch i386 -integrated-as -c test.m
:2:23: error: invalid assignment to ‘.objc_class_name_Foo’
.objc_class_name_Foo=0

To be exact, it stopped on these lines:

.lazy_reference .objc_class_name_Foo
.objc_class_name_Foo=0
.globl .objc_class_name_Foo

If the file does not contains a category, the .lazy_reference is not generated, and the code compile fine.

As LLVM-MV is fairly young, this is maybe a know issue, else should I fill a bug report ?

Thanks

– Jean-Daniel

Hello,

After the post about LLVM-MC, I tried to play with the “-integrated-as” flag.
Unfortunately, it does not works for a simple case which is an obj-c file with a class and a category to extend this class (on i386).

It was a known issue, we just didn’t get around to addressing it. Fixed in r101660, thanks for nudging us!

-Chris

Thanks for the quick fix :slight_smile:

-- Jean-Daniel

Unfortunately, it does not works as expected. It uncovers an other blocking bug :frowning:
The assembler generates an undefined symbol instead of generating an absolute symbol for classes, and so, in my test project, it now fails at linking time.

Look like this is due to the FIXME at line 198 in MCMachOSteamer.cpp ( FIXME: Set associated section. ).
This functions does not mark the symbol as absolute (by setting its section to absolute pseudo section), and so it is interpreted as undefined symbol by the MachOWriter.
Unfortunately, I don't known assembly and object generation enough to fix this.

-- Jean-Daniel

This is definitely a bug. I filed it internally to track it, Daniel will take a look when he has a chance.

-Chris