tpoechtrager / osxcross

Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android (Termux)
GNU General Public License v2.0
2.85k stars 320 forks source link

error: 'path' is unavailable: introduced in macOS 10.15 #298

Closed mcandre closed 2 years ago

mcandre commented 2 years ago

I recently compiled osxcross using HEAD Apple Clang with a MacOSX 11.3 tarball. But osxcross complains that many C++17 features are missing.

Trace:

$ x86_64-apple-darwin20.4-clang++   -I/src/include  -O3 -Werror -std=c++17 -Wextra -Wall -pedantic -Weffc++ -Wmost   -o CMakeFiles/rez.dir/src/cmd/rez/main.cpp.o -c /src/src/cmd/rez/main.cpp
In file included from /src/src/cmd/rez/main.cpp:11:
/src/include/rez/rez.hpp:125:67: error: 'path' is unavailable: introduced in macOS 10.15
std::filesystem::path ApplyBinaryExtension(const std::filesystem::path &basename, bool windows);

Source:

https://github.com/mcandre/rez/blob/606fb58159e648a60599fea0278bd00a44a4068d/include/rez/rez.hpp

Toolchain build steps:

https://github.com/mcandre/snek/blob/b16f63adb67adf7a908171b984d06494ed6180f6/docker/darwin/Dockerfile

For comparison, I am able to build this file easily using the official Xcode toolchain directly on physical Apple macOS hardware.

Something is lost in osxcross regarding C++17 support, which Xcode Clang ordinarily provides.

How can we fix missing C++17 features in osxcross?

One interesting thing, this StackOverflow post claims that the dylib for libstdc++ implements such features.

https://stackoverflow.com/a/54834871/350106

However, the toolchain built by ./build.sh did not preserve any dylib files. These are missing from my Docker image.

There are even a handful of original dylibs in the MacOSX SDK tarball. Not even those appear in my osxcross build artifact directory tree.

$ tar -tvf MacOSX11.3.sdk.tar.xz | grep -i dylib
-rw-r--r-- xcel/xcel      3088 2021-05-03 14:16 MacOSX11.3.sdk/usr/lib/lazydylib1.o
-rw-r--r-- xcel/xcel       536 2021-05-03 14:16 MacOSX11.3.sdk/usr/lib/dylib1.o
-rw-r--r-- xcel/xcel       536 2021-05-03 14:16 MacOSX11.3.sdk/usr/lib/dylib1.10.5.o

The only libs I have right now in the osxcross toolchain are:

$ ls /usr/local/osxcross/lib
libtapi.so       libxar.a   libxar.so
libtapi.so.8svn  libxar.la  libxar.so.1

Apple Clang on Docker comes with a huge collection of .a format library files. Maybe I'll try to force osxcross to search through these.

mcandre commented 2 years ago

I see now. As the README indicates, the default macOS target version is not the maximum supported version, but a few releases behind.

I am following the documentation and configuring an environment variable like MACOSX_DEPLOYMENT_TARGET=10.15, which can see the more modern C++17 features.

cmake notes: