Cheers everyone, Latest Android NDK, r8d, includes clang 3.1, which happens to build Objective-C out of the box. So I decided to spend some time trying to get libobjc2, gnustep-make and gnustep-base to be built. To ensure joy all around the step-land, I've tried to document my merry adventures along the way.
NDK, naturally, does not include a runtime. What runtime could I possibly decide to try to build other than libobjc2? :-) So far, I got CMake to not scream obscenities at me, and actually generate a Makefile. No joy with actually compiling the beast. David, would you mind taking a look? I'm attaching the script which: - fetches the Android SDK and the NDK, - fetches GNUstep and libobjc2, - creates a standalone NDK (with a more traditional compiler folder layout), - creates CMake toolchain file for Android, and - runs CMake in libobjc2's folder. The script is not really a script; more of a documentation of what commands I ran. Hopefully it's clear enough. It documents my experiments on a vanilla Ubuntu Server 12.04 32-bit, but (aside for a few apt-get installs) I see no reason it shouldn't work on any Linux machine. (But since I did this on a cheap cloud VPS, I could share root access to the machine, if you want to save some time.) In addition to the script, I'm also attaching: - output of "make" with current libobjc2 trunk - an ugly patch that fixes Android's pthread incompatibility (by using "portable" portion of code) - output of "make" after the patch is applied, which reveals problems with "_Unwind_Action" apparently not being supported by clang 3.1. PS: David, you said [1] you've built portions of GNUstep for webOS, and did some work on getting the configure tests to pass. Have you recently tried cross-compiling an elementary build of GNUstep -- just elementary features of Make and Base, with as little external dependencies as possible? If so, can you share a few details about that? Maybe it's reusable for Android as well. [1]: http://lists.gnu.org/archive/html/discuss-gnustep/2011-09/msg00117.html
android-gnustep.sh
Description: Binary data
root@gnustep:~/gnustep/dev-libs/libobjc2/build# make -j 8
Scanning dependencies of target objcxx
Scanning dependencies of target objc
[ 1%] Building CXX object CMakeFiles/objcxx.dir/objcxx_eh.cc.o
[ 4%] [ 6%] [ 6%] [ 7%] [ 9%] [ 10%] [ 12%] Building C object
CMakeFiles/objc.dir/abi_version.c.o
Building C object CMakeFiles/objc.dir/class_table.c.o
Building C object CMakeFiles/objc.dir/caps.c.o
Building C object CMakeFiles/objc.dir/alias_table.c.o
Building C object CMakeFiles/objc.dir/block_to_imp.c.o
Building C object CMakeFiles/objc.dir/category_loader.c.o
Building C object CMakeFiles/objc.dir/dtable.c.o
[ 14%] Building C object CMakeFiles/objc.dir/eh_personality.c.o
In file included from /root/gnustep/dev-libs/libobjc2/block_to_imp.c:21:9:
warning: 'PAGE_SIZE' macro redefined
#define PAGE_SIZE 4096
^
/tmp/my-android-toolchain/bin/../sysroot/usr/include/asm/page.h:16:9: note:
previous definition is here
#define PAGE_SIZE (1UL << PAGE_SHIFT)
^
/root/gnustep/dev-libs/libobjc2/block_to_imp.c:37:2: error: expected expression
INIT_LOCK(trampoline_lock);
^
/root/gnustep/dev-libs/libobjc2/lock.h/root/gnustep/dev-libs/libobjc2/dtable.c::2811::
In file included from /root/gnustep/dev-libs/libobjc2/slot_pool.h:3:
/root/gnustep/dev-libs/libobjc2/pool.h:16:9: warning: 'PAGE_SIZE' macro
redefined
#define PAGE_SIZE 4096
^
/tmp/my-android-toolchain/bin/../sysroot/usr/include/asm/page.h:16:9: note:
previous definition is here
#define PAGE_SIZE (1UL << PAGE_SHIFT)
^
In file included from 28: note: expanded from macro 'INIT_LOCK'
# define INIT_LOCK(x) x = PTHREAD_RECURSIVE_MUTEX_INITIALIZER
^
/tmp/my-android-toolchain/bin/../sysroot/usr/include/pthread.h:46:48: note:
expanded from macro 'PTHREAD_RECURSIVE_MUTEX_INITIALIZER'
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER {0x4000}
^
/root/gnustep/dev-libs/libobjc2/alias_table.c:64:
/root/gnustep/dev-libs/libobjc2/hash_table.h:134:2: error: expected expression
INIT_LOCK(table->lock);
^
/root/gnustep/dev-libs/libobjc2/lock.h:28:28: note: expanded from macro
'INIT_LOCK'
# define INIT_LOCK(x) x = PTHREAD_RECURSIVE_MUTEX_INITIALIZER
^
/tmp/my-android-toolchain/bin/../sysroot/usr/include/pthread.h:46:48: note:
expanded from macro 'PTHREAD_RECURSIVE_MUTEX_INITIALIZER'
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER {0x4000}
^
In file included from 1 warning and 1 error generated.
make[2]: *** [CMakeFiles/objc.dir/block_to_imp.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/root/gnustep/dev-libs/libobjc2/dtable.c:359:2: error: expected expression
INIT_LOCK(initialize_lock);
^
/root/gnustep/dev-libs/libobjc2/lock.h:28:28: note: expanded from macro
'INIT_LOCK'
# define INIT_LOCK(x) x = PTHREAD_RECURSIVE_MUTEX_INITIALIZER
^
/tmp/my-android-toolchain/bin/../sysroot/usr/include/pthread.h:46:48: note:
expanded from macro 'PTHREAD_RECURSIVE_MUTEX_INITIALIZER'
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER {0x4000}
^
/root/gnustep/dev-libs/libobjc2/class_table.c:34:
/root/gnustep/dev-libs/libobjc2/hash_table.h:134:2: error: expected expression
INIT_LOCK(table->lock);
^
/root/gnustep/dev-libs/libobjc2/lock.h:28:28: note: expanded from macro
'INIT_LOCK'
# define INIT_LOCK(x) x = PTHREAD_RECURSIVE_MUTEX_INITIALIZER
^
/tmp/my-android-toolchain/bin/../sysroot/usr/include/pthread.h:46:48: note:
expanded from macro 'PTHREAD_RECURSIVE_MUTEX_INITIALIZER'
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER {0x4000}
^
11 error generated.
make[2]: *** [CMakeFiles/objc.dir/alias_table.c.o] Error 1
warning and 1 error generated.
make[2]: *** [CMakeFiles/objc.dir/dtable.c.o] Error 1
In file included from /root/gnustep/dev-libs/libobjc2/class_table.c:86:
/root/gnustep/dev-libs/libobjc2/hash_table.h:134:2: error: expected expression
INIT_LOCK(table->lock);
^
/root/gnustep/dev-libs/libobjc2/lock.h:28:28: note: expanded from macro
'INIT_LOCK'
# define INIT_LOCK(x) x = PTHREAD_RECURSIVE_MUTEX_INITIALIZER
^
/tmp/my-android-toolchain/bin/../sysroot/usr/include/pthread.h:46:48: note:
expanded from macro 'PTHREAD_RECURSIVE_MUTEX_INITIALIZER'
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER {0x4000}
^
Linking C shared library libobjcxx.so
2 errors generated.
make[2]: *** [CMakeFiles/objc.dir/class_table.c.o] Error 1
[ 14%] /root/gnustep/dev-libs/libobjc2/eh_personality.c:303:61: error: unknown
type name '_Unwind_Action'
_Unwind_Action
actions,
^
Built target objcxx
/root/gnustep/dev-libs/libobjc2/eh_personality.c:703:29: warning: implicit
declaration of function '_Unwind_Resume_or_Rethrow' is invalid in C99
[-Wimplicit-function-declaration]
_Unwind_Reason_Code err = _Unwind_Resume_or_Rethrow(e);
^
1 warning and 1 error generated.
make[2]: *** [CMakeFiles/objc.dir/eh_personality.c.o] Error 1
make[1]: *** [CMakeFiles/objc.dir/all] Error 2
make: *** [all] Error 2
lock.patch
Description: Binary data
root@gnustep:~/gnustep/dev-libs/libobjc2/build# make
Scanning dependencies of target objc
[ 1%] Building C object CMakeFiles/objc.dir/alias_table.c.o
[ 3%] Building C object CMakeFiles/objc.dir/block_to_imp.c.o
/root/gnustep/dev-libs/libobjc2/block_to_imp.c:21:9: warning: 'PAGE_SIZE' macro
redefined
#define PAGE_SIZE 4096
^
/tmp/my-android-toolchain/bin/../sysroot/usr/include/asm/page.h:16:9: note:
previous definition is here
#define PAGE_SIZE (1UL << PAGE_SHIFT)
^
1 warning generated.
[ 4%] Building C object CMakeFiles/objc.dir/category_loader.c.o
[ 6%] Building C object CMakeFiles/objc.dir/class_table.c.o
[ 7%] Building C object CMakeFiles/objc.dir/dtable.c.o
In file included from /root/gnustep/dev-libs/libobjc2/dtable.c:11:
In file included from /root/gnustep/dev-libs/libobjc2/slot_pool.h:3:
/root/gnustep/dev-libs/libobjc2/pool.h:16:9: warning: 'PAGE_SIZE' macro
redefined
#define PAGE_SIZE 4096
^
/tmp/my-android-toolchain/bin/../sysroot/usr/include/asm/page.h:16:9: note:
previous definition is here
#define PAGE_SIZE (1UL << PAGE_SHIFT)
^
1 warning generated.
[ 9%] Building C object CMakeFiles/objc.dir/eh_personality.c.o
/root/gnustep/dev-libs/libobjc2/eh_personality.c:303:61: error: unknown type
name '_Unwind_Action'
_Unwind_Action
actions,
^
/root/gnustep/dev-libs/libobjc2/eh_personality.c:703:29: warning: implicit
declaration of function '_Unwind_Resume_or_Rethrow' is invalid in C99
[-Wimplicit-function-declaration]
_Unwind_Reason_Code err = _Unwind_Resume_or_Rethrow(e);
^
1 warning and 1 error generated.
make[2]: *** [CMakeFiles/objc.dir/eh_personality.c.o] Error 1
make[1]: *** [CMakeFiles/objc.dir/all] Error 2
make: *** [all] Error 2
-- Ivan Vučica [email protected] - http://ivan.vucica.net/
_______________________________________________ Gnustep-dev mailing list [email protected] https://lists.gnu.org/mailman/listinfo/gnustep-dev
