Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch allows clice to be compiled and run on macOS.
Main Changes
Use
std::localtime_r
instead ofstd::chrono::zoned_time
std::chrono::zoned_time
is an experimental feature of libc++ and is unavailable on macOS, so I concatenate the output ofstd::localtime_r
and the millisecond part ofchrono::system_clock::now()
to get a time string identical to current implementation. I admit that it is a little bit clumsy and more like a temporary solution, and I am looking forward to a better one.Query
xcrun
to acquire macOS's SDK pathI noticed that clice cannot find all standard headers (, , etc.), which is not the case when running on Linux, so I referred to clangd's code. In short, when running on macOS, clangd will invoke
xcrun
to get the SDK path (detectSysroot
and append it into the compile commands, so I portqueryXcrun
to clice and imitate this behavior inmangleCommand
.Use
std::iota
instead ofstd::ranges::iota
Currently
std::ranges::iota
is also not supported by libc++. It looks likestd::iota
does exactly the same thing here.Build
Now I can build clice with lld and llvm-19, installed by following commands:
The macOS version is Sonoma 14.7.2 (23H311). The SDK version is 15.2 (Apple clang version 16.0.0 (clang-1600.0.26.6)).
Test