Page 1 of 1

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

Posted: Tue Jul 22, 2025 8:17 am
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?

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

Posted: Tue Jul 22, 2025 8:54 pm
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.

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

Posted: Wed Jul 23, 2025 6:01 am
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).

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

Posted: Sat Jul 26, 2025 3:34 am
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.

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

Posted: Sun Aug 03, 2025 9:29 pm
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.