[Solved][2.1] Not able to compile on iOS

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
chchwy
Kobold
Posts: 30
Joined: Fri Feb 10, 2017 1:40 am
x 11

[Solved][2.1] Not able to compile on iOS

Post by chchwy »

With the latest commit of v2-1 branch on 21 April 2018

I got compiler errors in Xcode:

Code: Select all

<inline asm>:1:2 error: unknown directive
    .inst 0xde01
    ^
And this is my cmake command:

cmake -D OGRE_BUILD_PLATFORM_APPLE_IOS=1 -DOGRE_SIMD_SSE2=0 -DOGRE_SIMD_NEON=1 -DOGRE_BUILD_RENDERSYSTEM_METAL=1 -DOGRE_BUILD_RENDERSYSTEM_GL3PLUS=0 -DOGRE_BUILD_SAMPLES2=1 -DOGRE_CONFIG_THREADS=0 -DOGRE_CONFIG_ENABLE_JSON=1 -G Xcode ..
Last edited by chchwy on Fri May 11, 2018 2:33 am, edited 1 time in total.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Not able to compile on iOS

Post by dark_sylinc »

Is there more info in the full log? (Right click On the error, show in log)

That message does not help at all, sadly

Edit: apparently it may be the new OgreAssert stuff
chchwy
Kobold
Posts: 30
Joined: Fri Feb 10, 2017 1:40 am
x 11

Re: [2.1] Not able to compile on iOS

Post by chchwy »

It compile after I commented out 2 lines of code in `OgreMain/include/debugbreak/debugbreak.h`

Line 72
//__asm__ volatile(".inst 0xde01");

And line 120
//trap_instruction();
Last edited by chchwy on Mon Apr 30, 2018 6:31 am, edited 1 time in total.
zxz
Gremlin
Posts: 184
Joined: Sat Apr 16, 2016 9:25 pm
x 19

Re: [2.1] Not able to compile on iOS

Post by zxz »

The new assert code is giving us some problems as well. Our issue is different than chchwy's, so this is somewhat of a barely related hijack.

The issue arises mainly when mixing release and debug builds. When Ogre is built in debug, the macro OGRE_DEBUG_MODE will be different when included internally in Ogre, than when it is included from our project which is not being built in debug. I think that when Ogre headers are included externally, they must give the same result as when Ogre was built. Anything else results in mismatch in object sizes (due to extra members being added in debug.

The following lines in OgrePlatform.h will make the debug mode change depending on client code build settings:

Code: Select all

  // on Apple & Windows we override OgreBuildSettings.h for convenience
  // see https://bitbucket.org/sinbad/ogre/pull-requests/728
  // Win32 compilers use _DEBUG for specifying debug builds, for MinGW, we use DEBUG
  #if (defined(_DEBUG) || defined(DEBUG))
  #   define OGRE_DEBUG_MODE OGRE_DEBUG_LEVEL_DEBUG
  #else
  #   define OGRE_DEBUG_MODE OGRE_DEBUG_LEVEL_RELEASE
  #endif
For example, our project will see OGRE_DEBUG_MODE 0, while Ogre is built with OGRE_DEBUG_MODE 3.

I suppose one could make sure that both OGRE_DEBUG_LEVEL_DEBUG and OGRE_DEBUG_LEVEL_RELEASE are configured to the same level at all times, but it's somewhat unexpected that one has to do that.
xissburg
Halfling
Posts: 83
Joined: Sun Feb 21, 2010 4:58 pm
x 28

Re: [2.1] Not able to compile on iOS

Post by xissburg »

It seems debugbreak.h is broken on iOS. I also had to remove that trap_instruction(); and I replaced it with __builtin_trap();
chchwy
Kobold
Posts: 30
Joined: Fri Feb 10, 2017 1:40 am
x 11

Re: [2.1] Not able to compile on iOS

Post by chchwy »

Here is the full error log:

Code: Select all

CompileC build/OgreMain/OGRE.build/Debug-iphoneos/OgreMain.build/Objects-normal/armv7/OgreNode.o OgreMain/src/OgreNode.cpp normal armv7 c++ com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/mattchang/OgreSDK/Ogre2
    export LANG=en_US.US-ASCII
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=c++11 -stdlib=libc++ -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wno-shorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DCMAKE_INTDIR=\"Debug-iphoneos\" -DBOOST_THREAD_VERSION=4 -DOGRE_NONCLIENT_BUILD -DFREEIMAGE_LIB -D_MT -D_USRDLL -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk -funroll-loops -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -miphoneos-version-min=9.0 -g -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -fembed-bitcode-marker -index-store-path /Users/mattchang/Library/Developer/Xcode/DerivedData/OGRE-blajcurhwncoxdgiodvbuvanfnci/Index/DataStore -I/Users/mattchang/OgreSDK/Ogre2/build/lib/iphoneos/Debug/include -I/Users/mattchang/OgreSDK/Ogre2/OgreMain/include -I/Users/mattchang/OgreSDK/Ogre2/build/include -I/Users/mattchang/OgreSDK/Ogre2/OgreMain/include/iOS -I/Users/mattchang/OgreSDK/Ogre2/RenderSystems/Metal/include/Windowing/iOS -I/Users/mattchang/OgreSDK/Ogre2/iOSDependencies/include -I/Users/mattchang/OgreSDK/Ogre2/iOSDependencies/include/OIS -I/Users/mattchang/OgreSDK/Ogre2/iOSDependencies -I/Users/mattchang/OgreSDK/Ogre2/OgreMain/include/Threading -I/Users/mattchang/OgreSDK/Ogre2/OgreMain/src/nedmalloc -I/Users/mattchang/OgreSDK/Ogre2/build/OgreMain/OGRE.build/Debug-iphoneos/OgreMain.build/DerivedSources/armv7 -I/Users/mattchang/OgreSDK/Ogre2/build/OgreMain/OGRE.build/Debug-iphoneos/OgreMain.build/DerivedSources -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -F/Users/mattchang/OgreSDK/Ogre2/build/lib/iphoneos/Debug -Wall -Winit-self -Wno-overloaded-virtual -Wcast-qual -Wwrite-strings -Wextra -Wno-unused-parameter -Wshadow -Wno-missing-field-initializers -Wno-long-long -DDEBUG=1 -MMD -MT dependencies -MF /Users/mattchang/OgreSDK/Ogre2/build/OgreMain/OGRE.build/Debug-iphoneos/OgreMain.build/Objects-normal/armv7/OgreNode.d --serialize-diagnostics /Users/mattchang/OgreSDK/Ogre2/build/OgreMain/OGRE.build/Debug-iphoneos/OgreMain.build/Objects-normal/armv7/OgreNode.dia -c /Users/mattchang/OgreSDK/Ogre2/OgreMain/src/OgreNode.cpp -o /Users/mattchang/OgreSDK/Ogre2/build/OgreMain/OGRE.build/Debug-iphoneos/OgreMain.build/Objects-normal/armv7/OgreNode.o
    
    
<inline asm>:1:2: error: unknown directive
        .inst 0xde01
        ^
<inline asm>:1:2: error: unknown directive
        .inst 0xde01
        ^
<inline asm>:1:2: error: unknown directive
        .inst 0xde01
        ^
<inline asm>:1:2: error: unknown directive
        .inst 0xde01
        ^
<inline asm>:1:2: error: unknown directive
        .inst 0xde01
        ^
<inline asm>:1:2: error: unknown directive
        .inst 0xde01
        ^
<inline asm>:1:2: error: unknown directive
        .inst 0xde01
        ^
7 errors generated.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Not able to compile on iOS

Post by dark_sylinc »

I haven't forgotten about this, I just haven't got the time to touch anything Ogre related this week yet
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Not able to compile on iOS

Post by dark_sylinc »

PHEW! Bug fixed.

Thanks for reporting it.

This bug made me also look into something I've been wanting to look into for a while now: I noticed XCode reporting compiling 16 files when it should be compiling 8 and so on; and taking noticeable longer to compile than when building for macOS targets. I thought maybe we accidentally were building for the simulator, but that did not make sense since the simulator would throw out compiler errors with Metal.

Now thanks to this bug I noticed we were building for both arm64 and armv7 (and also armv7s). Ogre 2.1+ only supports arm64 because those are the only devices that support Metal.
Even if GLES3 were to work on iOS again, these devices are slow and have very little RAM available (unlike modern Android equivalents which have terrific Hardware specs coupled with the horribly limited GLES 3.0 API) which means I doubt Ogre 2.1+ would be useful there. Maybe in the future someone will want to maintain it, but we'll cross that bridge when we get there.

The build error was coming when building for armv7, which apparently defines __thumb__ but does not actually support Thumb. Probably some CMake -> XCode configuration shenanigan, or an XCode side effect of Apple no longer caring about these architectures.
Anyway I didn't pay much attention to it as I just disabled armv7.

This revealed another compiler error in debugbreak.h, this time for arm64, but it was very easy to fix.

Btw, build times for iOS are now literally halved thanks to not wasting time building for the unused armv7 platform.

Cheers
Matias
chchwy
Kobold
Posts: 30
Joined: Fri Feb 10, 2017 1:40 am
x 11

Re: [2.1] Not able to compile on iOS

Post by chchwy »

Can confirm it is compiling on iOS now without any issues.
Also the architecture change did save us a lot of time.

Thank you very much!
Post Reply