axmol
axmol copied to clipboard
iOS Simulators ASTC compile error when PLATFORM set to OS64COMBINED
- axys version: Sep 19, 2022 dev
- devices test on: iOS Simulators
- developing environments
- Xcode version: 14
- cmake version: 3.24.2 Steps to Reproduce:
- Generate xcode arm64 & x86_64 project: cmake -S . -B build -GXcode -DCMAKE_TOOLCHAIN_FILE=$AX_ROOT/cmake/ios.toolchain.cmake -DPLATFORM=OS64COMBINED
- Open Project and change target to "iPhone Simulators"
- Will see ASTC erros, If you use the machine, there will be no problem, only on the simulator
This should be a feature request, not a bug, since OS64COMBINED isn't a supported target platform
Hi,
Error list:
I think that the problem is related to BASE SDK that use iOS instead of Simulator in this case:
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
I post an issue to understand if has any solution:
https://github.com/leetal/ios-cmake/issues/160
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.
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:


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.
There are 3 targets to set, astc, axys, cpp_tests.
@halx99 Maybe Label iOS ist usefull?
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.
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.
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).
Building astc as prebuilt maybe a good solution