Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCORE-2166 Fix building with Xcode 16 #7802

Merged
merged 5 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
* Valgrind could report a branch on an uninitialized read when opening something that is not an encrypted Realm file as an encrypted Realm file ([PR #7789](https://github.com/realm/realm-core/pull/7789), since v14.10.0).
* Opening an FLX realm asynchronously may not wait to download all data ([#7720](https://github.com/realm/realm-core/issues/7720), since FLX sync was introduced).
* Fix compilation with Xcode 16 ([PR #7802](https://github.com/realm/realm-core/pull/7802))

### Breaking changes
* None.
Expand All @@ -19,7 +20,7 @@
-----------

### Internals
* None.
* Switch to building the Swift package and Cocoa binaries as C++20 ([PR #7802](https://github.com/realm/realm-core/pull/7802)).

----------------------------------------------

Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ endif()
set(PROJECT_VERSION ${DEP_VERSION})

# Project-wide build flags
set(CMAKE_CXX_STANDARD 17)
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -565,5 +565,5 @@ let package = Package(
.headerSearchPath("../"),
] + cxxSettings) as [CXXSetting]),
],
cxxLanguageStandard: .cxx17
cxxLanguageStandard: .cxx20
)
7 changes: 2 additions & 5 deletions evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,6 @@ buildvariants:
expansions:
cmake_bindir: "/opt/homebrew/bin"
cmake_toolchain_file: "./tools/cmake/xcode.toolchain.cmake"
extra_flags: "-DCMAKE_XCODE_ATTRIBUTE_SDKROOT=iphoneos"
cmake_build_tool_options: "-sdk iphonesimulator -arch arm64"
cmake_generator: Xcode
max_jobs: $(sysctl -n hw.logicalcpu)
Expand Down Expand Up @@ -1707,12 +1706,11 @@ buildvariants:
expansions:
cmake_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/cmake-3.26.3-macos-universal.tar.gz"
cmake_bindir: "./cmake_binaries/CMake.app/Contents/bin"
cmake_toolchain_file: "./tools/cmake/xcode.toolchain.cmake"
cmake_generator: Xcode
max_jobs: $(sysctl -n hw.logicalcpu)
cmake_build_type: Release
xcode_developer_dir: /Applications/Xcode13.1.app/Contents/Developer
extra_flags: -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_OSX_ARCHITECTURES=x86_64
extra_flags: -DREALM_ENABLE_ASSERTIONS=ON
tasks:
- name: benchmarks
- name: compile_test
Expand All @@ -1724,12 +1722,11 @@ buildvariants:
expansions:
cmake_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/cmake-3.26.3-macos-universal.tar.gz"
cmake_bindir: "./cmake_binaries/CMake.app/Contents/bin"
cmake_toolchain_file: "./tools/cmake/xcode.toolchain.cmake"
cmake_generator: Xcode
max_jobs: $(sysctl -n hw.logicalcpu)
cmake_build_type: Release
xcode_developer_dir: /Applications/Xcode13.1.app/Contents/Developer
extra_flags: -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_OSX_ARCHITECTURES=arm64
extra_flags: -DREALM_ENABLE_ASSERTIONS=ON
tasks:
- name: benchmarks

Expand Down
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
add_subdirectory(realm)
add_subdirectory(external/IntelRDFPMathLib20U2)
add_subdirectory(external/bson EXCLUDE_FROM_ALL)
if (NOT REALM_BUILD_LIB_ONLY)
add_subdirectory(external/bson EXCLUDE_FROM_ALL)
endif()

if (REALM_ENABLE_GEOSPATIAL)
add_subdirectory(external/s2)
Expand Down
2 changes: 1 addition & 1 deletion src/realm/util/time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ inline std::string format_utc_time(std::time_t time, const char* format)

} // namespace realm::util

#if __cplusplus < 202002L
#if __cplusplus < 202002L || (defined(__apple_build_version__) && __apple_build_version__ < 15000309)
// This is a C++17 version of https://en.cppreference.com/w/cpp/chrono/duration/operator_ltlt to make
// logging and comparing durations easier - especially in tests.
//
Expand Down
2 changes: 1 addition & 1 deletion test/benchmark-larger/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ int main()
<< std::endl;
start = end;
for (size_t i = 0; i < probe_size; ++i) {
sum += objects[i].get<Int>(col2);
sum = sum + objects[i].get<Int>(col2);
}
end = std::chrono::steady_clock::now();
diff = end - start;
Expand Down
8 changes: 7 additions & 1 deletion test/test_util_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,15 @@ TEST(Utils_File_dir)

TEST(Utils_File_dir_unicode)
{
#if __cplusplus < 202002L
using std::filesystem::u8path;
#else
auto u8path = [](const std::string& str) {
return std::filesystem::path(reinterpret_cast<const char8_t*>(str.c_str()));
};
#endif

constexpr char all_the_unicode[] = u8"фоо-бар Λορεμ ლორემ 植物 החלל جمعت søren";
const char* all_the_unicode = (const char*)u8"фоо-бар Λορεμ ლორემ 植物 החלל جمعت søren";
std::string dir_name = File::resolve(all_the_unicode, test_util::get_test_path_prefix());

// Create directory
Expand Down
17 changes: 5 additions & 12 deletions tools/cmake/xcode.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,11 @@ set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator;-appletvos;-appl
set(CMAKE_XCODE_ATTRIBUTE_SUPPORTS_MACCATALYST "YES")
set(CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2,3,4,7")

# With Xcode 14+ the base SDK *mostly* doesn't matter any more, as it
# officially supports multi-platform builds from a single target.
# However, as of Xcode 15 beta 8 xcodebuild (but not Xcode itself) requires the
# visionOS SDK to build for visionOS. 15.0 final doesn't include the visionOS
# SDK, so the SDKROOT is explicitly set by the invoker when building with the
# beta Xcode rather than here.
# Xcode 13 requires using the correct SDK. We no longer support Xcode 13, but
# still use it on evergreen to build the macOS tests (and nothing else).
# As of Xcode 14 the iphoneos SDK supports building for all platforms to
# support multi-platform builds. However, we still have some Xcode 13 builds (for
# benchmarks) that need to set the SDKROOT to macosx.
if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_SDKROOT)
set(CMAKE_XCODE_ATTRIBUTE_SDKROOT_1500 "iphoneos")
set(CMAKE_XCODE_ATTRIBUTE_SDKROOT_1400 "iphoneos")
set(CMAKE_XCODE_ATTRIBUTE_SDKROOT_1300 "macosx")
set(CMAKE_XCODE_ATTRIBUTE_SDKROOT "$(SDKROOT_$(XCODE_VERSION_MAJOR))")
set(CMAKE_XCODE_ATTRIBUTE_SDKROOT "iphoneos")
endif()

set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "12.0")
Expand All @@ -39,3 +31,4 @@ set(CMAKE_XCODE_ATTRIBUTE_TVOS_DEPLOYMENT_TARGET "12.0")

set(REALM_ENABLE_ASSERTIONS ON CACHE BOOL "Enable release assertions")
set(REALM_XCODE_TOOLCHAIN TRUE)
set(CMAKE_CXX_STANDARD 20)
Loading