clang and -integrated-as

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

clang and -integrated-as

Jean-Daniel Dupas-2
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
<inline asm>: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





_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang and -integrated-as

Chris Lattner

On Apr 17, 2010, at 5:18 AM, Jean-Daniel Dupas wrote:

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


@interface Foo { void *isa; } @end
@implementation Foo 
@end
@implementation Foo (Bar)
@end

clang -arch i386 -integrated-as -c test.m
<inline asm>: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




_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang and -integrated-as

Jean-Daniel Dupas-2

Le 17 avr. 2010 à 20:29, Chris Lattner a écrit :

>
> On Apr 17, 2010, at 5:18 AM, Jean-Daniel Dupas wrote:
>
>> 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!

Thanks for the quick fix :-)

-- Jean-Daniel





_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang and -integrated-as

Jean-Daniel Dupas-2

Le 17 avr. 2010 à 21:08, Jean-Daniel Dupas a écrit :


Le 17 avr. 2010 à 20:29, Chris Lattner a écrit :


On Apr 17, 2010, at 5:18 AM, Jean-Daniel Dupas wrote:

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!

Thanks for the quick fix :-)

Unfortunately, it does not works as expected. It uncovers an other blocking bug :-(
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.

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

% clang -arch i386 -c test.m 
% nm -m test.o
00000000 (absolute) external .objc_class_name_Foo

% clang -arch i386 -c test.m -integrated-as
% nm -m test.o 
         (undefined) external .objc_class_name_Foo


-- Jean-Daniel





_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang and -integrated-as

Jean-Daniel Dupas-2

Le 17 avr. 2010 à 21:49, Jean-Daniel Dupas a écrit :

>
> Le 17 avr. 2010 à 21:08, Jean-Daniel Dupas a écrit :
>
>>
>> Le 17 avr. 2010 à 20:29, Chris Lattner a écrit :
>>
>>>
>>> On Apr 17, 2010, at 5:18 AM, Jean-Daniel Dupas wrote:
>>>
>>>> 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!
>>
>> Thanks for the quick fix :-)
>
> Unfortunately, it does not works as expected. It uncovers an other blocking bug :-(
> 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.
>
> =================
> @interface Foo { void *isa; }
> @end
> @implementation Foo
> @end
> =================
>
> % clang -arch i386 -c test.m
> % nm -m test.o
> 00000000 (absolute) external .objc_class_name_Foo
>
> % clang -arch i386 -c test.m -integrated-as
> % nm -m test.o
>          (undefined) external .objc_class_name_Foo

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





_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang and -integrated-as

Chris Lattner
In reply to this post by Jean-Daniel Dupas-2
On Apr 17, 2010, at 12:49 PM, Jean-Daniel Dupas wrote:
It was a known issue, we just didn't get around to addressing it.  Fixed in r101660, thanks for nudging us!

Thanks for the quick fix :-)

Unfortunately, it does not works as expected. It uncovers an other blocking bug :-(
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.

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

% clang -arch i386 -c test.m 
% nm -m test.o
00000000 (absolute) external .objc_class_name_Foo

% clang -arch i386 -c test.m -integrated-as
% nm -m test.o 
         (undefined) external .objc_class_name_Foo

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

-Chris

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev