Startup Situation Freshly installed VM with minimal install (only ssh server and standard system utilities) of Debian 9 Stretch 64bit 0. install clang7 or 8 ------------------------------------------------------ File: /etc/apt/sources.list.d/llvm.list # clang-7 deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-7 main deb-src http://apt.llvm.org/stretch/ llvm-toolchain-stretch-7 main # clang-8 deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-8 main deb-src http://apt.llvm.org/stretch/ llvm-toolchain-stretch-8 main install clang: apt-get install clang-7 lldb-7 llvm-7 - or - apt-get install clang-8 lldb-8 llvm-8 1. Download the sourcecode of gnustep and dependencies ------------------------------------------------------ apt-get install build-essential git autoconf automake wget sudo gdb mkdir ~/gnustep cd ~/gnustep wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz git clone https://github.com/apple/swift-corelibs-libdispatch git clone https://github.com/gnustep/scripts git clone https://github.com/gnustep/libobjc2 git clone https://github.com/gnustep/make git clone https://github.com/gnustep/base git clone https://github.com/gnustep/corebase git clone https://github.com/gnustep/gui git clone https://github.com/gnustep/back ./scripts/install-dependencies 2. Build dependencies ------------------------------------------------------ # Note libiconf does not build if the compiler is set to clang or the linker to lld. # no time to fix this so we compile it with gcc for now. Dont think that affects anything else really cd ~/gnustep tar -xvzf libiconv-1.15.tar.gz cd libiconv-1.15 ./configure --enable-static --enable-dynamic make make install 3. Setting some defaults ------------------------------------------------------ #for CLANG7 export CC="/usr/bin/clang-7" export CXX="/usr/bin/clang++-7" #for clang8 export CC="/usr/bin/clang-8" export CXX="/usr/bin/clang++-8" export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" export RUNTIME_VERSION="gnustep-2.0" export OBJCFLAGS="-fblocks" 4. installing libdispatch ------------------------------------------------------ cd ~/gnustep/swift-corelibs-libdispatch mkdir build cd build cmake .. -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_BUILD_TYPE=RelWithDebInfo make make install ldconfig 5. install libobjc2 runtime ------------------------------------------------ cd ~/gnustep/libobjc2 mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_STATIC_LIBOBJC=1 -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX} make -j8 make install ldconfig make test On CLANG-7: 100% tests passed, 0 tests failed out of 162 On CLANG-8: 99% tests passed, 2 tests failed out of 162 The following tests FAILED: 18 - AssociatedObject_optimised (OTHER_FAULT) 20 - AssociatedObject_legacy_optimised (OTHER_FAULT) Errors while running CTest Makefile:83: recipe for target 'test' failed make: *** [test] Error 8 These tests pass if in ~/gnustep/libobjc2/Test/AssociatedObject.m the lines static BOOL deallocCalled = NO; static const char* objc_setAssociatedObjectKey = "objc_setAssociatedObjectKey"; are having the "static" removed. According to David Chisnal, clang does optimize something away here that the test fails but the library should be ok. 6. install gnustep-make ------------------------------------------------ cd make ./configure \ --with-layout=fhs \ --disable-importing-config-file \ --enable-native-objc-exceptions \ --enable-objc-arc \ --enable-install-ld-so-conf \ --with-library-combo=ng-gnu-gnu \ --with-config-file=/usr/local/etc/GNUstep/GNUstep.conf \ --with-user-config-file='.GNUstep.conf' \ --with-user-defaults-dir='GNUstep/Library/Defaults' \ --with-objc-lib-flag="-l:libobjc.so.4.6" make install cd .. source /usr/local/etc/GNUstep/GNUstep.conf 7. install gnustep-base ------------------------------------------------ cd base ./configure --with-config-file=/usr/local/etc/GNUstep/GNUstep.conf using CLANG7: ... checking alignment of pthread_mutex_t... 8 checking alignment of pthread_cond_t... 8 checking for pthread_join in -lpthread... yes checking for pthread_getthreadid_np... no checking for pthread_main_np... no checking for sched_yield in -lrt... yes checking for nanosleep... yes checking for usleep... yes checking for Sleep... no checking for objc_root_class attribute support... found checking for pthread_setname_np()... glibc checking for pthread_spin_lock... yes checking for gettid()... yes checking whether objc really works... yes checking if the compiler supports -fconstant-string-class... yes checking if +load method is executed before main... yes checking for objc_sync_enter... no configure: error: The objc runtime library does not appear to have synchronisation support. Try re-configuring gnustep-make with a CPPFLAGS variable containing a -L point to specify the directory containing the correct libobjc, or using the --with-objc-lib-flag=... option. if i work around this in configure.ac to tell it by hand it has synchronisation support, then properties fails, and then nonabi etc. Basically it looks like everything is not clang or libobjc2 but gcc and old ABi instead. using CLANG-8: configure passes without any problem make -j8 make install all looks good but: # make check This is gnustep-make 2.7.0. Type 'make print-gnustep-make-help' for help. Running in gnustep-make version 2 strict mode. Making check in Source ... Making check in Additions ... make[2]: Nothing to be done for 'check'. Making check in subprojects of library libgnustep-base... make[2]: Nothing to be done for 'check'. make[2]: Nothing to be done for 'check'. Making check for library libgnustep-base... make[2]: Nothing to be done for 'internal-library-check'. Making check in Tools ... Making check in make_strings ... make[2]: Nothing to be done for 'check'. Making check in NSTimeZones ... make[1]: Nothing to be done for 'check'. Making check in Resources ... make[1]: Nothing to be done for 'check'. Making check in Tests ... (\ GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES="/home/user/gnustep/base/base.make";\ ADDITIONAL_INCLUDE_DIRS="-I/home/user/gnustep/base/Headers -I/home/user/gnustep/base/Source/.";\ ADDITIONAL_LIB_DIRS="-L/home/user/gnustep/base/Source/./obj";\ ADDITIONAL_LDFLAGS="-Wl,-rpath,/home/user/gnustep/base/Source/./obj";\ LD_LIBRARY_PATH="/home/user/gnustep/base/Source/./obj:";\ PATH="/home/user/gnustep/base/Tools/./obj:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";\ export GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES;\ export ADDITIONAL_INCLUDE_DIRS;\ export ADDITIONAL_LDFLAGS;\ export ADDITIONAL_LIB_DIRS;\ export LD_LIBRARY_PATH;\ export PATH;\ if [ "no" = "yes" ]; then \ gnustep-tests --debug base;\ else \ gnustep-tests base;\ fi; \ ) /bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) --- Running tests in base/Functions --- base/Functions/NSByteSwapping.m: Failed file: NSByteSwapping.m aborted without running all tests! base/Functions/NSGeometry1.m: Failed file: NSGeometry1.m aborted without running all tests! base/Functions/NSPathUtilities.m: Failed file: NSPathUtilities.m aborted without running all tests! base/Functions/NSZone.m: Failed file: NSZone.m aborted without running all tests! and so on. ALL TESTS FAIL apt-get install gdb gnustep-tests --debug . reveals that a simple [NSAutoreleasePool new] is causing a initialisaiton of NSObject which in turn does create some NSString which then creates an exception which creates an infinite loop #705 0x00007ffff78d6370 in +[NSException raise:format:] (self=0x7ffff7abdb1c, _cmd=, name=0x7fffff7ff6d8, format=0x0) at NSException.m:1377 #706 0x00007ffff7913d66 in -[NSObject doesNotRecognizeSelector:] (self=, _cmd=, aSelector=0x7ffff7dc7d48 <.objc_selector_stringWithFormat:arguments:_320:816[1{__va_list_tag=II^v^v}]24>) at NSObject.m:1723 #707 0x00007ffff79a8c66 in GSFFIInvocationCallback (cif=0x1522f00, retp=0x7fffff818ed0, args=0x7fffff818d30, user=0x1522eb8) at GSFFIInvocation.m:606 #708 0x00007ffff54bfe2f in ffi_closure_unix64_inner () from /usr/lib/x86_64-linux-gnu/libffi.so.6 #709 0x00007ffff54c01a0 in ffi_closure_unix64 () from /usr/lib/x86_64-linux-gnu/libffi.so.6 #710 0x00007ffff78d63a6 in +[NSException raise:format:arguments:] (self=0x7ffff7d68088 <._OBJC_CLASS_NSException>, _cmd=, name=0x7ffff7db2e48 <.objc_str_NSInvalidArgumentException>, format=0x7fffff7ff6d8, argList=0x0) at NSException.m:1390 #711 0x00007ffff78d6370 in +[NSException raise:format:] (self=0x7ffff7abdb1c, _cmd=, name=0x7fffff7ff6d8, format=0x0) at NSException.m:1377 #712 0x00007ffff7913d66 in -[NSObject doesNotRecognizeSelector:] (self=, _cmd=, aSelector=0x7ffff7dc7d48 <.objc_selector_stringWithFormat:arguments:_320:816[1{__va_list_tag=II^v^v}]24>) at NSObject.m:1723 #713 0x00007ffff79a8c66 in GSFFIInvocationCallback (cif=0x1522910, retp=0x7fffff819240, args=0x7fffff8190a0, user=0x15228c8) at GSFFIInvocation.m:606 #714 0x00007ffff54bfe2f in ffi_closure_unix64_inner () from /usr/lib/x86_64-linux-gnu/libffi.so.6 #715 0x00007ffff54c01a0 in ffi_closure_unix64 () from /usr/lib/x86_64-linux-gnu/libffi.so.6 #716 0x00007ffff78d63a6 in +[NSException raise:format:arguments:] (self=0x7ffff7d68088 <._OBJC_CLASS_NSException>, _cmd=, name=0x7ffff7db2e48 <.objc_str_NSInvalidArgumentException>, format=0x7fffff7ff6d8, argList=0x0) at NSException.m:1390 #717 0x00007ffff78d6370 in +[NSException raise:format:] (self=0x7ffff7abdb1c, _cmd=, name=0x7fffff7ff6d8, format=0x0) at NSException.m:1377 -------------------- Conclusions: -------------------- libobjc2 compiles more or less fine under clang-7 nd clang-8. under clang7, gnustep-base can not get configured. It just fails at every corner. one of the test cases behaving differently with clang-7 vs clang-8 and which is executed from configure.ac is the following one: #include int main(int argc, const char **argv) { printf("%d\n", __has_feature(objc_nonfragile_abi) ? 0 : 1); } if this is compiled with the default gnustep-configure flags, we get this: clang-7 -MMD -MP -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNUSTEP_RUNTIME=1 -D_NONFRAGILE_ABI=1 -DGNUSTEP_BASE_LIBRARY=1 -fno-strict-aliasing \ -fexceptions -fobjc-exceptions -D_NATIVE_OBJC_EXCEPTIONS -pthread -fPIC -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -g -O2 -fblocks \ -fobjc-runtime=gnustep-2.0 -fblocks -fconstant-string-class=NSConstantString -I. -I/usr/local/include \ test.m \ -rdynamic -pthread -fexceptions -fobjc-runtime=gnustep-2.0 -fblocks -L/Users/afink/GNUstep/Library/Libraries -L/usr/local/lib -lpthread -l:libobjc.so.4.6 -lm /tmp/test-100fae.o:(.data..objc_init[.objc_init]+0x18): undefined reference to `__start___objc_classes' /tmp/test-100fae.o:(.data..objc_init[.objc_init]+0x20): undefined reference to `__stop___objc_classes' /usr/bin/ld: a.out: hidden symbol `__start___objc_classes' isn't defined /usr/bin/ld: final link failed: Bad value clang: error: linker command failed with exit code 1 (use -v to see invocation) with clang8 the link problem is not existing: clang-8 -MMD -MP -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNUSTEP_RUNTIME=1 -D_NONFRAGILE_ABI=1 -DGNUSTEP_BASE_LIBRARY=1 -fno-strict-aliasing \ -fexceptions -fobjc-exceptions -D_NATIVE_OBJC_EXCEPTIONS -pthread -fPIC -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -g -O2 -fblocks \ -fobjc-runtime=gnustep-2.0 -fblocks -fconstant-string-class=NSConstantString -I. -I/usr/local/include \ test.m \ -rdynamic -pthread -fexceptions -fobjc-runtime=gnustep-2.0 -fblocks -L/Users/afink/GNUstep/Library/Libraries -L/usr/local/lib -lpthread -l:libobjc.so.4.6 -lm