axmol icon indicating copy to clipboard operation
axmol copied to clipboard

iOS Simulators ASTC compile error when PLATFORM set to OS64COMBINED

Open Yehsam23 opened this issue 3 years ago • 7 comments

  • axys version: Sep 19, 2022 dev
  • devices test on: iOS Simulators
  • developing environments
    • Xcode version: 14
    • cmake version: 3.24.2 Steps to Reproduce:
  1. Generate xcode arm64 & x86_64 project: cmake -S . -B build -GXcode -DCMAKE_TOOLCHAIN_FILE=$AX_ROOT/cmake/ios.toolchain.cmake -DPLATFORM=OS64COMBINED
  2. Open Project and change target to "iPhone Simulators"
  3. Will see ASTC erros, If you use the machine, there will be no problem, only on the simulator

Yehsam23 avatar Sep 21 '22 07:09 Yehsam23

This should be a feature request, not a bug, since OS64COMBINED isn't a supported target platform

rh101 avatar Sep 21 '22 10:09 rh101

Hi,

Error list:

image

paulocoutinhox avatar Sep 21 '22 10:09 paulocoutinhox

I think that the problem is related to BASE SDK that use iOS instead of Simulator in this case:

image

You can see on log: Using SDK: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk

And on simulator, it uses: -- Using SDK: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.0.sdk

paulocoutinhox avatar Sep 21 '22 10:09 paulocoutinhox

I post an issue to understand if has any solution:

https://github.com/leetal/ios-cmake/issues/160

paulocoutinhox avatar Sep 21 '22 10:09 paulocoutinhox

I make progress with option:

 -DAX_WITH_ASTC=OFF

But other problem happen:

error build: Undefined symbol: _BZ2_bzDecompress

error build: Undefined symbol: _BZ2_bzDecompressEnd

error build: Undefined symbol: _BZ2_bzDecompressInit

error build: Undefined symbol: store_image_block(astcenc_image&, image_block const&, block_size_descriptor const&, unsigned int, unsigned int, unsigned int, astcenc_swizzle const&)

error build: Undefined symbol: physical_to_symbolic(block_size_descriptor const&, physical_compressed_block const&, symbolic_compressed_block&)

error build: Undefined symbol: decompress_symbolic_block(astcenc_profile, block_size_descriptor const&, int, int, int, symbolic_compressed_block const&, image_block&)

error build: Undefined symbol: init_block_size_descriptor(unsigned int, unsigned int, unsigned int, bool, unsigned int, float, block_size_descriptor&)

The bz2 library is not flat, but selected when CMake project was generated:

-- Found BZip2: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/usr/lib/libbz2.tbd (found version "1.0.8") 
-- Looking for BZ2_bzCompressInit
-- Looking for BZ2_bzCompressInit - found

And it is selected from iOS SDK only.

paulocoutinhox avatar Sep 21 '22 13:09 paulocoutinhox

After search, we can remove BZIP2 to test:

-DAX_WITH_ASTC=OFF -DFT_DISABLE_BZIP2=ON

BZIP2 is ignored - OK

But ASTC is not REALLY disabled, because it still required it, see the errors:

error build: Undefined symbol: store_image_block(astcenc_image&, image_block const&, block_size_descriptor const&, unsigned int, unsigned int, unsigned int, astcenc_swizzle const&)

error build: Undefined symbol: physical_to_symbolic(block_size_descriptor const&, physical_compressed_block const&, symbolic_compressed_block&)

error build: Undefined symbol: decompress_symbolic_block(astcenc_profile, block_size_descriptor const&, int, int, int, symbolic_compressed_block const&, image_block&)

error build: Undefined symbol: init_block_size_descriptor(unsigned int, unsigned int, unsigned int, bool, unsigned int, float, block_size_descriptor&)

To full disable it, need comment this files inside base/CMakeLists.txt:

base/astc.h
base/astc.cpp

On variables _AX_BASE_HEADER and _AX_BASE_SRC.

And need comment astc on file AXLinkHelpers.cmake from target_link_libraries.

And need change inside CCImage.cpp from if (Configuration::getInstance()->supportsASTC()) to if (true).

With all this changes, it works on both platforms with single project:

IMG_FFBE5A87A38E-1

Simulator Screen Shot - iPhone 14 Pro - 2022-09-21 at 11 08 19

paulocoutinhox avatar Sep 21 '22 14:09 paulocoutinhox

I'm not familiar with cmake, however after using command to generate the Xcode project, you can set the preprocessor macros to not using ASTC NEON in simulator. Screenshot 2022-09-23 at 16 43 45 There are 3 targets to set, astc, axys, cpp_tests.

qoozta avatar Sep 23 '22 08:09 qoozta

@halx99 Maybe Label iOS ist usefull?

aismann avatar Oct 07 '22 11:10 aismann

Current project still have a limitation, because CMake need select bzip library per-platform, what make it be incompatible. If you generate CMake project for iOS, the bzip is from iphone SDK and if you generate for simulator CMake find inside simulator SDK.

One possible solution is add bzip library (-lbz2) and add library search folder based on platform:

iOS: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/usr/lib/

And Simulator: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.0.sdk/usr/lib/

Also, need consider tvOS paths too.

paulocoutinhox avatar Oct 12 '22 20:10 paulocoutinhox

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 11 '22 21:12 stale[bot]

This issue still exists when building with -DPLATFORM=OS. I had to follow @paulocoutinhox 's steps to resolve (although I didn't have the bzip issues).

If building for OS64, compiler errors from astc will occur due to immintrin.h being included (these are Intel-specific headers that should not be included in an arm build).

danarcari avatar Dec 29 '22 07:12 danarcari

Building astc as prebuilt maybe a good solution

halx99 avatar Dec 29 '22 10:12 halx99