[swift-dev] Compiling Swift for Android x86

John McCall rjmccall at apple.com
Thu Aug 31 15:39:25 CDT 2017


> On Aug 31, 2017, at 4:24 PM, Max Rose via swift-dev <swift-dev at swift.org> wrote:
> Hi Everybody,
> 
> We're working on adding Android x86 to the available targets for Swift. Currently we're able to compile an executable through the toolchain. However, running the executable leads to a crash "cannot locate symbol '__sync_val_compare_and_swap_16' referenced by '[...]libswiftCore.so'".
> 
> In comparing the swift standard library for ARM to our swift standard library for x86 we noticed that the ARM standard library include symbols for __sync_val_compare_and_swap_{1, 2, and 4}, but the x86 library has an undefined symbol for __sync_val_compare_and_swap_16. This is the same for __sync_lock_test_and_set.
> 
> My main questions are:
> 1) Where is the __sync_val_compare_and_swap coming from?
> 2) Does this seem like and issue linking to the wrong atomic library, or is this a deeper issue? 
> 3) Is comparing Android ARM to x86 a valid comparison or are the platforms too different?
> 
> We're fairly new to compiler toolchains so any suggestions would be very much appreciated! With the introduction of the Android apps to Chromebooks, it will be great to be able to have Swift run on all Android platforms.

It's likely that that symbol is defined by a library that isn't linked in by default.  Fortunately for you, that's true of Linux as well.  You should be able to just search the code base for where we link in libatomic and make sure that the appropriate library is linked on Android as well.

John.


More information about the swift-dev mailing list