gnustep / libobjc2

Objective-C runtime library intended for use with Clang.
http://www.gnustep.org/
MIT License
426 stars 116 forks source link

Version 2 Objective-C ABI may not be mixed with earlier versions #196

Closed darkoverlordofdata closed 3 years ago

darkoverlordofdata commented 3 years ago

Using ubuntu 18.04.2 & clang version 7.0.0-3 After installing gnustep & gnustep-devel, I build and installed libobjc2. When I try to run my helloworld, which compiles and runs on FreeBSD, I get a runtime error:

Version 2 Objective-C ABI may not be mixed with earlier versions 
Abort 

There was a warning in the build that seems related:

clang: warning: argument unused during compilation: '-shared-libgcc' [-Wunused-command-line-argument] 
/usr/bin/ld: warning: libobjc.so.4, needed by /usr/lib/libgnustep-gui.so, may conflict with libobjc.so.4.6 

I find these files which seem conflicting:

/usr/lib/gcc/x86_64-linux-gnu/7/libobjc.a  
/usr/lib/gcc/x86_64-linux-gnu/7/libobjc_gc.so 
/usr/lib/gcc/x86_64-linux-gnu/7/libobjc_gc.a  
/usr/lib/gcc/x86_64-linux-gnu/7/libobjc.so 

/usr/local/lib/libobjc.so  
/usr/local/lib/libobjc.so.4.6 

How do I resolve this?

davidchisnall commented 3 years ago

The ABI is picked by the -fobjc-runtime= flag. If you do -fobjc-runtime=gnustep-1.{x} then you get the 1.x ABI, if you do -fobjc-runtime=gnustep-2.0 then you get the 2.0 ABI. I believe clang 7 is too old to support the 2.0 ABI (it might be the first version to support it?). This looks as if you are using some things compiled with gcc and trying to mix them with things compiled with a newer ABI. This is not supported.

darkoverlordofdata commented 3 years ago

I think the problem was clang7. I found https://github.com/plaurent/gnustep-build, which had some build scripts. There was one for ubuntu 19.04 - I have ubuntu 18.04, so I tried it. But it looks like the big difference is that it installs clang8. Noe everything works correctly.

darkoverlordofdata commented 3 years ago

Agreed - you need to fix the documentation. The reason I was using 7 was this statement in the readme: The modern (v2) ABI, which provides richer reflection metadata, smaller binaries and reduced memory usage. This is selected with the -fobjc-runtime=gnustep-2.0 flag in Clang 7.0 or later.

davidchisnall commented 3 years ago

Clang 7 does support the new ABI, and I think the 7.0.1 release fixes the bug that caused the GNUstep configure scripts to think that it didn't. Your issue was caused by compiling and linking GNUstep against GCC libobjc, and then compiling your code against this runtime. As the documentation says, the v2 ABI is not backwards compatible, you cannot (dynamically or statically) link things that use the two ABIs together and expect them to work. The error message reports this.

darkoverlordofdata commented 3 years ago

I'm glad that's clear to someone. To be honest, documentation on gnustep is so obfuscated and hard to find that I've given up on it.

On Fri, Apr 2, 2021 at 9:45 AM David Chisnall @.***> wrote:

Clang 7 does support the new ABI, and I think the 7.0.1 release fixes the bug that caused the GNUstep configure scripts to think that it didn't. Your issue was caused by compiling and linking GNUstep against GCC libobjc, and then compiling your code against this runtime. As the documentation says, the v2 ABI is not backwards compatible, you cannot (dynamically or statically) link things that use the two ABIs together and expect them to work. The error message reports this.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gnustep/libobjc2/issues/196#issuecomment-812610463, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJUE4UHF77PVR55QJKOGZTTGXYEJANCNFSM4YM6HVGQ .

--

Bruce Davidson