`build_detect_platform` seems to detect incorrect features for iOS
- Dominant language
- C++
- Stars
- 32.1k
- Forks
- 6.9k
- Avg merge
- 32m
- Merged PRs (30d)
- 1
Description
I'm having trouble building for iOS. I think I was able to get one of the recent 6.x releases to build a while ago, but it seems like something may have changed in 7.x that's causing problems for iOS.
Following the instructions in `INSTALL.md`, I first run `TARGET_OS=IOS make static_lib -j8`:
https://github.com/facebook/rocksdb/blob/9454e744ed0ca4bb27ebcd8d4f79c59ef723adcf/INSTALL.md?plain=1#L180-L181
I get two groups of errors:
```
./util/fastrange.h:62:5: error: unknown type name '__uint128_t'
__uint128_t wide = __uint128_t{range} * hash;
^
./util/fastrange.h:62:24: error: use of undeclared identifier '__uint128_t'
__uint128_t wide = __uint128_t{range} * hash;
^
./util/fastrange.h:62:35: error: expected ';' at end of declaration
__uint128_t wide = __uint128_t{range} * hash;
^
;
./util/fastrange.h:55:35: error: unused parameter 'hash' [-Werror,-Wunused-parameter]
static inline Range Fn(uint64_t hash, Range range) {
^
./util/fastrange.h:55:47: error: unused parameter 'range' [-Werror,-Wunused-parameter]
static inline Range Fn(uint64_t hash, Range range) {
^
```
```
In file included from cache/lru_cache.cc:10:
./cache/lru_cache.h:290:11: error: aligned deallocation function of type 'void (void *, std::align_val_t) noexcept' is only available on iOS 11 or newer
virtual ~LRUCacheShard() override = default;
^
cache/lru_cache.cc:673:18: note: in defaulted destructor for 'rocksdb::LRUCacheShard' first required here
shards_[i].~LRUCacheShard();
^
./cache/lru_cache.h:290:11: note: if you supply your own aligned allocation functions, use -faligned-allocation to silence this diagnostic
virtual ~LRUCacheShard() override = default;
^
```
(the second one looks similar to #4064)
I noticed that in the generated `make_config.mk`, `-DHAVE_UINT128_EXTENSION` is in `PLATFORM_CCFLAGS` and `PLATFORM_CXXFLAGS`:
```
PLATFORM_CCFLAGS= -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_MACOSX -DIOS_CROSS_COMPILE -DROCKSDB_LITE -Wshorten-64-to-32 -DHAVE_BMI -DHAVE_UINT128_EXTENSION -DROCKSDB_SUPPORT_THREAD_LOCAL -DHAVE_FULLFSYNC
PLATFORM_CXXFLAGS=-std=c++17 -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_MACOSX -DIOS_CROSS_COMPILE -DROCKSDB_LITE -Wshorten-64-to-32 -DHAVE_BMI -DHAVE_UINT128_EXTENSION -DROCKSDB_SUPPORT_THREAD_LOCAL -DHAVE_FULLFSYNC
```
Confused as to why I got the error when it seems like the [`__uint128` test](https://github.com/facebook/rocksdb/blob/d5dfa8c6fe74d8810b85d5cae1fd98a6b0427bb8/build_tools/build_detect_platform#L790-L801) in `build_tools/build_detect_platform` must have passed, I tried compiling that test by itself in a separate file:
The following command works:
```bash
g++ test.cc -o test.o
```
But I noticed that the Makefile will run this when targeting iOS:
https://github.com/facebook/rocksdb/blob/4f9c0fd083d00bacd86b723f7789658ccfd3f108/Makefile#L2423
So I tried something similar:
```bash
xcrun -sdk iphonesimulator g++ -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path) -arch i686 -arch x86_64 test.cc -o test.o
```
It seems like targeting i686 causes this to fail, because it succeeds if I only pass `-arch x86_64`:
```
$ xcrun -sdk iphonesimulator g++ -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path) -arch i686 test.cc -o test.o
test.cc:4:5: error: unknown type name '__uint128_t'
__uint128_t b = __uint128_t(a) * a;
^
test.cc:4:21: error: use of undeclared identifier '__uint128_t'
__uint128_t b = __uint128_t(a) * a;
^
2 errors generated.
```
The same error is shown when targeting armv7 for iOS (`xcrun -sdk iphoneos g++ -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -arch armv7 test.cc -o test.o`), but targeting arm64 alone succeeds.
I don't personally don't need support for any of the 32-bit architectures, but it seems like the Makefile tries to target them:
https://github.com/facebook/rocksdb/blob/4f9c0fd083d00bacd86b723f7789658ccfd3f108/Makefile#L2421-L2433
### Expected behavior
RocksDB compiles successfully for iOS
### Actual behavior
Errors are shown
### Steps to reproduce the behavior
```bash
TARGET_IOS make static_lib -j8
```
Here's my output of `clang -v` (I have Xcode 13.4 installed) :
```
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: x86_64-apple-darwin21.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
```
I'm on macOS Monterey 12.4 with an Intel-based Mac, using the macOS 12.3 SDK and iOS 15.5 SDK
Contributor guide
Assessment
This issue has not been assessed yet.