Clang build ABI 1.9 Linux only (+latest gnustep-base) (solved)

For discussion of ports to POSIX based systems, especially using GNUStep.

Moderators: another_commander, winston, Getafix

Post Reply
User avatar
mcarans
---- E L I T E ----
---- E L I T E ----
Posts: 717
Joined: Sun Jun 20, 2010 6:00 pm

Clang build ABI 1.9 Linux only (+latest gnustep-base) (solved)

Post by mcarans »

I was able to get Oolite to build with Clang.

To force Clang usage, in the shell I did:

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++


I built libobjc2 2.2.1 from source as described here in that shell.

I built gnustep-base-1.31.1 from source as described here in the same shell (to ensure I still have the 2 exports to force Clang usage).


Then I built Oolite which compiled and linked fine. It ran and opened its window with Oolite logo, but then crashed with:

Configuration contains unknown keys - ("GNUSTEP_FILESYSTEM_LAYOUT")
Add them in the comma separated list GNUSTEP_EXTRA=... if required.
2025-07-22 19:58:06.426 oolite[37078:37079] Truncating thread name 'OOLogOutputHandler logging thread' to 15 characters due to platform limitations
oolite: /home/mcarans/Code/libobjc2-2.2.1/protocol.h:85: struct objc_protocol_method_description *protocol_method_at_index(struct objc_protocol_method_description_list *, int): Assertion `l->size >= sizeof(struct objc_protocol_method_description)' failed.
Aborted (core dumped)

Does anyone know what might be causing this error?
Last edited by mcarans on Wed Oct 29, 2025 7:12 am, edited 5 times in total.
User avatar
mcarans
---- E L I T E ----
---- E L I T E ----
Posts: 717
Joined: Sun Jun 20, 2010 6:00 pm

Re: Clang build (+latest gnustep-base) (solved)

Post by mcarans »

I had to add to the GNUmakefile above the line OBJC_PROGRAM_NAME = oolite:

ADDITIONAL_OBJCFLAGS += -fobjc-runtime=gnustep-1.9


Then Oolite starts up ok after clean and build. Adding ADDITIONAL_LDFLAGS += -fuse-ld=lld to force the use of the Clang/LLVM linker ldd instead of GNU's ld gives a segmentation fault for me. That means that rather strangely, I must use GNU's linker ld for linking when compiling with Clang (and gcc).

The -fobjc-runtime flag is described as follows here:

The GNUstep Objective-C runtime was designed as a drop-in replacement for the GCC runtime. It supports three ABIs:
  • The old GCC ABI, which provides support for Objective-C 1.0 features. This can be selected via the -fobjc-runtime=gcc flag in Clang or by compiling with GCC.
  • The initial GNUstep non-fragile ABI, which was intended to be compatible with the GCC ABI, but provide support for modern Objective-C features. This can be selected with the -fobjc-runtime=gnustep-1.9 flag in Clang.
  • 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.
User avatar
mcarans
---- E L I T E ----
---- E L I T E ----
Posts: 717
Joined: Sun Jun 20, 2010 6:00 pm

Re: Clang build (+latest gnustep-base) (solved)

Post by mcarans »

I've documented this in the wiki: https://wiki.alioth.net/index.php/Compi ... ead_of_gcc (it is linked to from the Developer's Corner page).
User avatar
mcarans
---- E L I T E ----
---- E L I T E ----
Posts: 717
Joined: Sun Jun 20, 2010 6:00 pm

Re: Clang build (+latest gnustep-base) (solved)

Post by mcarans »

I played the Oolite build compiled with Clang and it worked without any issues. I could not see any difference compared to compiling with gcc when playing the game.
User avatar
mcarans
---- E L I T E ----
---- E L I T E ----
Posts: 717
Joined: Sun Jun 20, 2010 6:00 pm

Re: Clang build (+latest gnustep-base) (solved)

Post by mcarans »

The Clang flag is now in the GNUmakefile and so doesn't need to be added manually when building Oolite with Clang instead of gcc.
User avatar
mcarans
---- E L I T E ----
---- E L I T E ----
Posts: 717
Joined: Sun Jun 20, 2010 6:00 pm

Re: Clang build ABI 1.9 (+latest gnustep-base) (solved)

Post by mcarans »

Assuming /usr is where you want the includes and libs to go (which is what Ubuntu expects), then the bash script below will setup libobjc2, tools-make and libs-base for Clang gnustep-1.9 assuming you have the repos checked out:

Code: Select all

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

cd libobjc2
rm -rf build
mkdir build
cd build
cmake -DTESTS=on -DCMAKE_BUILD_TYPE=Release -DGNUSTEP_INSTALL_TYPE=NONE -DCMAKE_INSTALL_PREFIX=/usr -DEMBEDDED_BLOCKS_RUNTIME=ON -DOLDABI_COMPAT=ON ../
cmake --build .
sudo cmake --install .
cd ../..

cd tools-make
./configure --prefix=/usr --with-library-combo=ng-gnu-gnu --with-libdir=lib --with-runtime-abi=gnustep-1.9 --with-objc-lib-flag="-L/usr/lib/x86_64-linux-gnu/ -lobjc"
make
sudo make install
cd ..

cd libs-base
. /usr/share/GNUstep/Makefiles/GNUstep.sh
./configure --prefix=/usr
make -j16
sudo make install
cd ..
User avatar
mcarans
---- E L I T E ----
---- E L I T E ----
Posts: 717
Joined: Sun Jun 20, 2010 6:00 pm

Re: Clang build ABI 1.9 (+latest gnustep-base) (solved)

Post by mcarans »

Curiously, compiling with the following (still using Clang) but leaving the ABI as 1.9 in Oolite's GNUmakefile also worked possibly opening up a way to get Clang working on MinGW64 where GNUStep base cannot be built with ABI 1.9:

Code: Select all

./configure --prefix=/usr --with-library-combo=gnu-gnu-gnu --with-libdir=lib --with-objc-lib-flag="-L/usr/lib/x86_64-linux-gnu/ -lobjc"
User avatar
mcarans
---- E L I T E ----
---- E L I T E ----
Posts: 717
Joined: Sun Jun 20, 2010 6:00 pm

Re: Clang build ABI 1.9 Linux only (+latest gnustep-base) (solved)

Post by mcarans »

I confirmed that building with Clang and anything other than gnustep-2.2 on MinGW64 will not work. With the gcc ABI of libobjc2, GNUStep Base compilation gives similar errors to with the 1.9 ABI ie.:

Code: Select all

ld.lld: error: duplicate symbol: .weak.__objc_class_ref_NSException.default..objc_sel_nameUTF8String
>>> defined at obj/libgnustep-base.obj/GSSocksParser/GSSocksParserPrivate.m.o
>>> defined at Additions/./obj/Additions.obj/NSObject+GNUstepBase.m.o

ld.lld: error: duplicate symbol: .weak.__objc_class_ref_NSString.default..objc_sel_nameUTF8String
>>> defined at obj/libgnustep-base.obj/GSSocksParser/GSSocksParserPrivate.m.o
>>> defined at Additions/./obj/Additions.obj/NSObject+GNUstepBase.m.o

ld.lld: error: duplicate symbol: .weak.__objc_class_ref_NSString.default..objc_sel_namealloc
>>> defined at Additions/./obj/Additions.obj/NSData+GNUstepBase.m.o
>>> defined at win32/./obj/win32.obj/NSString+Win32Additions.m.o
clang: error: linker command failed with exit code 1 (use -v to see invocation) 
Post Reply