Skip to content

Bump MacOS deplyment target to fix compilation error#339

Closed
k3a wants to merge 1 commit intoOpenBoardView:masterfrom
k3a:master
Closed

Bump MacOS deplyment target to fix compilation error#339
k3a wants to merge 1 commit intoOpenBoardView:masterfrom
k3a:master

Conversation

@k3a
Copy link
Contributor

@k3a k3a commented Oct 17, 2025

This fixes filesystem:path errors on recent MacOS:

platform.h:26:19: error: 'path' is unavailable: introduced in macOS 10.15
   26 | const filesystem::path show_file_picker(bool filterBoards = false);
      |                   ^

ref: NixOS/nixpkgs#452764

This fixes filesystem:path errors on recent MacOS:
platform.h:26:19: error: 'path' is unavailable: introduced in macOS 10.15
@piernov
Copy link
Member

piernov commented Oct 17, 2025

ghc::filesystem is used as a fallback for older systems.
Check is performed in

## filesystem ##

The check for AppleClang is commented out to force the ghc::filesystem fallback when built on macOS.
https://github.com/OpenBoardView/OpenBoardView/blob/master/src/openboardview/filesystem_impl.h is then used to select between std::filesystem or ghc::filesystem implementation.

The official macOS x86_64 release is built on Mac OS X 10.11 and runs fine there.

@k3a
Copy link
Contributor Author

k3a commented Oct 19, 2025

Thanks for the helpful pointers!
The mentioned check doesn't work on Nix on MacOS becase it uses a normal Clang:

-- The C compiler identification is Clang 21.1.1
-- The CXX compiler identification is Clang 21.1.1

clang version 21.1.1
Target: arm64-apple-darwin25.0.0
Thread model: posix
InstalledDir: /nix/store/8xihfndv2sbjnhg8ahm0g7dwa7bgysrw-clang-21.1.1/bin

For reference, on my MacOS 26 Tahoe, the system Clang is:

-- The C compiler identification is AppleClang 17.0.0.17000319
-- The CXX compiler identification is AppleClang 17.0.0.17000319

Apple clang version 17.0.0 (clang-1700.3.19.1)
Target: arm64-apple-darwin25.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

So for Nix builds, std::filesystem was still included with that 10.9 deployment target and that's why it failed with error: 'path' is unavailable: introduced in macOS 10.15.

I tried to replace the mentioned CMakeLists.txt with the following patch (an explicit check for !APPLE instead of checking for AppleClang):

From 1d6cd42f9c920ba371ba4fd1fda1589280a7904e Mon Sep 17 00:00:00 2001
From: Mario Hros <[email protected]>
Date: Sat, 18 Oct 2025 17:24:19 +0200
Subject: [PATCH] Disable std::filesystem for APPLE platforms to keep
 supporting MacOS 10.9 deployment target with non-apple Clang

---
 src/CMakeLists.txt | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index cdc6940ea71857a00e7b2bfb66b34a272114aeb8..8a8b4b36d5b792363a26f54b8529e8656f6d0b37 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -154,16 +154,16 @@ set(IMGUI_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/imgui ${CMAKE_CURRENT_SOURCE_

 ## filesystem ##
 message(CHECK_START "Checking for std::filesystem")
-## GCC 9 and Clang 9 include filesystem in the standard library. Apple is of course messing with us and AppleClang 11.4 is Clang 9.0
-if(((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0))
-       #OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.4))
+## GCC 9 and Clang 9 include filesystem in the standard library. disable for Apple due to CMAKE_OSX_DEPLOYMENT_TARGET < 10.15
+if(((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
+       AND !APPLE)
        message(CHECK_PASS "available")
        set(CMAKE_CXX_STANDARD 17)
        set(FILESYSTEM_LIBRARIES)
        add_definitions(-DWITH_STD_FILESYSTEM)
-# Clang 8 requires explicit linking with lc++fs. AppleClang 11.0 is Clang 8.0
-elseif((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0))
-       #OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0))
+# Clang 8 requires explicit linking with lc++fs. disable for Apple due to CMAKE_OSX_DEPLOYMENT_TARGET < 10.15
+elseif((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
+       AND !APPLE)
        message(CHECK_PASS "available")
        set(CMAKE_CXX_STANDARD 17)
        set(FILESYSTEM_LIBRARIES lc++fs)

It forced ghs::filesystem implementation as expected but it ended up badly as well, this time std::filesystem being ambiguous due to some deeply-included header from the standard library:

In file included from /nix/var/nix/builds/nix-80709-1695224203/source/src/openboardview/GUI/Preferences/BoardSettings/PDFFile.h:4:
/nix/var/nix/builds/nix-80709-1695224203/source/src/openboardview/PDFBridge/PDFFile.h:37:27: error: reference to 'filesystem' is ambiguous
   37 |         void writeToConfig(const filesystem::path &filepath);
      |                                  ^
/nix/var/nix/builds/nix-80709-1695224203/source/src/openboardview/filesystem_impl.h:15:11: note: candidate found by name lookup is 'filesystem'
   15 | namespace filesystem = ghc::filesystem;
      |           ^
/nix/store/zzn2cvbh4gs4zvyv9p52kclqqvqrfb5x-libcxx-19.1.2+apple-sdk-15.5/include/c++/v1/__chrono/file_clock.h:48:1: note: candidate found by name lookup is 'std::filesystem'
   48 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
      | ^
/nix/store/zzn2cvbh4gs4zvyv9p52kclqqvqrfb5x-libcxx-19.1.2+apple-sdk-15.5/include/c++/v1/__config:605:80: note: expanded from macro '_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM'
  605 |                                              inline namespace __fs { namespace filesystem {
      |                                                                                ^

Here is a snippet of libcxx-19.1.2+apple-sdk-15.5/include/c++/v1/__chrono/file_clock.h:48:1:

...
#if _LIBCPP_STD_VER >= 20

_LIBCPP_BEGIN_NAMESPACE_STD

namespace chrono {

// [time.clock.file], type file_clock
using file_clock = filesystem::_FilesystemClock;

template <class _Duration>
using file_time = time_point<file_clock, _Duration>;

} // namespace chrono

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 20
...

So it seems that we will need to bump the deployment target for Nix builds only.

I understand that you may want to keep the deployment target as low as possible and it may work for some time with the Apple Clang.

Unless you have some more tips on what to try, this PR will have to be closed, it seems.

@piernov
Copy link
Member

piernov commented Oct 19, 2025

IIRC this should have been fixed in 502d7ff.

@k3a
Copy link
Contributor Author

k3a commented Oct 19, 2025

Pull request #340 replaces this

@k3a k3a closed this Oct 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants