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

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

Moderators: winston, another_commander, Getafix

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

Clang build (+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 Tue Jul 22, 2025 9:20 pm, edited 3 times in total.
User avatar
mcarans
---- E L I T E ----
---- E L I T E ----
Posts: 374
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: 374
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: 374
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: 374
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.
Post Reply