j2kun/mlir-tutorial

Force Bazel to use different minimum macos version

os12345678 opened this issue · 3 comments

I am trying to bazel build @llvm-project//mlir/...:all but am getting errors with the minimum macos version.

external/llvm-project/llvm/utils/TableGen/DFAEmitter.cpp:367:18: error: 'get<unsigned int, llvm::Record *, unsigned int, std::string>' is unavailable: introduced in macOS 10.13 OS << std::get<unsigned>(SingleAction); ^

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/variant:1544:22: note: 'get<unsigned int, llvm::Record *, unsigned int, std::string>' has been explicitly marked unavailable here constexpr const _Tp& get(const variant<_Types...>& __v) {

I have added --macos_minimum_os=10.13 in .bazelrc but it seems to get ignored - building with verbose_failure flag shows '-mmacosx-version-min=10.11.

sw_vers ProductName: macOS ProductVersion: 13.2.1 BuildVersion: 22D68
clang --version Apple clang version 14.0.0 (clang-1400.0.29.202) Target: arm64-apple-darwin22.3.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Any help is appreciated, thanks!

I don't have a mac machine to test on, but I think that flag may be for when you're building applications for Mac systems, not necessarily which C++ toolchain is used.

I see this in bazel upstream: https://github.com/bazelbuild/bazel/blob/28898a91543cb9388fae4231ccbebbba65177d71/src/main/starlark/builtins_bzl/common/xcode/providers.bzl#L177-L193

Which suggests to me you should be setting some macos_sdk_version: https://bazel.build/reference/command-line-reference#flag--macos_sdk_version

Could you try that and let me know if it works? Please send a PR to add that to .bazelrc if you get it working and have the time.

I'm afraid you may need to update your xcode version, because it looks like bazel detects the xcode version automatically here.

Thank you very much for this helpful tutorial! In my macbook air M2, this command cannot be ommitted in .bazelrc:common --host_cxxopt='-std=c++17'. However, the environment setup seems can be skiped. I just check this and I don't know why. I hope this information can be helpful.