libretro / libretro-chailove

:heart: 2D Game Framework with ChaiScript
https://raw.githack.com/libretro/libretro-chailove/docs/index.html
MIT License
70 stars 22 forks source link

Does not compile in iOS #378

Closed jet082 closed 5 years ago

jet082 commented 5 years ago

This is related to this problem https://github.com/libretro/Dinothawr/issues/16#issuecomment-527801826

The solution is posted in a comment on this issue.

Error below:

<inline asm>:3:3: fatal error: unknown directive
  .arm
  ^
1 error generated.
make: *** [vendor/libretro-common/audio/conversion/float_to_s16_neon.o] Error 1
RobLoach commented 5 years ago

Thanks for the heads up! That .arm directive issue has plagued me for so long. Wish we could port it to C or somethign.

jet082 commented 5 years ago

Well, I fixed it in Dinothawr. I actually ran it earlier today on my iPad Pro to confirm that it works fine in ARM64.

It would seem to be fixable here as well.

As per here.

IMG_0011

jet082 commented 5 years ago

Welp, I got chailove to compile on iOS arm64. It's my most complex iOS-arm64 compile yet, but it fundamentally just follows the same rules as my dinothawr fix (that is to say, to ignore the neon optimizations in the audio stuff - which is fine performance-wise). It's a bit more complex, as you need to also comment out stuff that won't be used (cd drive detection, etc). Instructions below.

First, run libretro-build-ios-arm64.sh chailove - it will fail, but this is fine. It needs to fetch some stuff and this is an easy way to do that.

Then make the following changes:

Makefile - Remove the following lines (or comment them out)

rm -f $(TARGET) $(OBJECTS)
git clean -xdf
rm -rf vendor
git reset --hard HEAD
git submodule update -f --init --recursive
git submodule foreach --recursive git clean -xfd
git submodule foreach --recursive git reset --hard HEAD

@git submodule update --init --recursive

@git submodule update --remote

Makefile.libretro - Make the following changes

CC = cc -arch arm64 -isysroot $(IOSSDK)

to

CC = cc -DDONT_WANT_ARM_OPTIMIZATIONS -arch arm64 -isysroot -DHAVE_POSIX_MEMALIGN $(IOSSDK)
HAVE_NEON = 0

CC +=  -miphoneos-version-min=8.0
CFLAGS += -miphoneos-version-min=8.0

to

CC +=  -miphoneos-version-min=8.0 -DHAVE_POSIX_MEMALIGN
CFLAGS += -miphoneos-version-min=8.0 -DHAVE_POSIX_MEMALIGN

Add the following to Makefile.common

ifeq ($(platform), ios-arm64)
    LDFLAGS += -framework IOKit -framework Foundation
    FLAGS += -D__MACH__ -D__APPLE__ -DPHYSFS_PLATFORM_APPLE
    SOURCES_M += $(CORE_DIR)/vendor/didstopia-physfs/src/physfs_platform_apple.m
endif

Change #if defined(__ARM_NEON__) to #if defined(__ARM_NEON__) && false in libretro-chailove/vendor/libretro-common/audio/conversion/s16_to_float_neon.c, libretro-chailove/vendor/libretro-common/audio/conversion/float_to_s16_neon.c, and libretro-chailove/vendor/libretro-common/audio/resampler/drivers/sinc_resampler_neon.S

src/love/system.cpp - Comment out the following lines:

int result = std::system(command.c_str());
if (result != 0) {
    std::cout << "[ChaiLove] [system] Failed to execute " << command << std::endl;
    return false;
}

vendor/libretro-common/audio/resampler/drivers/sinc_resampler.c - Change the following line:

#if defined(WANT_NEON)
      sinc_resampler.process = resampler_sinc_process_neon;

to

#if defined(WANT_NEON) && false
      sinc_resampler.process = resampler_sinc_process_neon;

At this point, chailove will compile.

jet082 commented 5 years ago

I had to update the comment above. The original edits compiled, but did not run. These do.

Evidence :D

IMG_0019

WeedyWeedSmoker commented 5 years ago

@jet082 On the latest non-beta Xcode, the instructions right here still fail...

I'll try again (along with easyrpg, BTW) when the Xcode 11 beta is installed, just waiting for the download to finish first... 😄

WeedyWeedSmoker commented 5 years ago

@jet082 Still no luck on the latest Xcode, failing with the exact same error with current instructions...

RobLoach commented 5 years ago

@WeedyWeedSmoker @jet082 Made a PR over at https://github.com/libretro/libretro-chailove/pull/380 .... Probably missed soemthing.

jet082 commented 5 years ago

@WeedyWeedSmoker @jet082 Made a PR over at #380 .... Probably missed soemthing.

I have made a comment on how to fix your PR @RobLoach

jet082 commented 5 years ago

Fixed by https://github.com/libretro/libretro-chailove/commit/10d64cc67f51514cefbc264a52aa5d16c616d4c1