setup-cpp icon indicating copy to clipboard operation
setup-cpp copied to clipboard

Support llvm-17/16/15 on Macos

Open msclock opened this issue 1 year ago • 10 comments

Brew has formulas about llvm-17/16/15/14, see https://github.com/Homebrew/homebrew-core/blob/master/Formula/l/llvm.rb

But in setup-cpp indicates llvm-17/16/15 are missing in

https://github.com/aminya/setup-cpp/blob/17a5a833c411175bd64ad1df88965b29b74b1a4b/src/llvm/llvm_url.ts#L103-L121

Upvote & Fund

@aminya is using Polar.sh so you can upvote and help fund this issue. The funding is received once the issue is completed & confirmed by you.

Thank you in advance for helping prioritize & fund our backlog!


Fund with Polar

msclock avatar Apr 10 '24 06:04 msclock

This has been on my TODO list. See #242.

Upvote & Fund

@aminya is using Polar.sh so you can upvote and help fund this issue. The funding is received once the issue is completed & confirmed by you.

Thank you in advance for helping prioritize & fund our backlog!


Fund with Polar

aminya avatar Apr 10 '24 06:04 aminya

@aminya thanks for your rapid feedback. Excellent work👍

msclock avatar Apr 10 '24 07:04 msclock

I can not understand why it does not work on Darwin:

bash-5.2$ sudo ./setup-cpp-x64-macos --compiler llvm-18  
Invalid semver version 18 used for the compiler.
::group::Installing llvm 18
Coerced version '18' to '18.0.0'
Installing llvm 18 x64 via direct downloading
Error: Unsupported target! (platform='darwin', version='18'). Try one of the following: {}
::endgroup::
took 0 seconds
Failed to install the llvm-18
setup-cpp finished
Run `source ~/.cpprc` or restart your shell to update the environment.
bash-5.2$ sudo ./setup-cpp-x64-macos --compiler llvm-17
Invalid semver version 17 used for the compiler.
::group::Installing llvm 17
Coerced version '17' to '17.0.0'
Installing llvm 17 x64 via direct downloading
Error: Unsupported target! (platform='darwin', version='17'). Try one of the following: {}
::endgroup::
took 0 seconds
Failed to install the llvm-17
setup-cpp finished
Run `source ~/.cpprc` or restart your shell to update the environment.
bash-5.2$ 

ClausKlein avatar Apr 10 '24 12:04 ClausKlein

Today, setup-cpp install llvm-14 by default, that is not helpflully!

bash-5.2$ clang --version
Homebrew clang version 17.0.6
Target: x86_64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
bash-5.2$ 

ClausKlein avatar Apr 10 '24 12:04 ClausKlein

Today, setup-cpp install llvm-14 by default, that is not helpflully!

bash-5.2$ clang --version
Homebrew clang version 17.0.6
Target: x86_64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
bash-5.2$ 

At least 15 should be installed.🧐

This is my 15.0.3 installed.

msclock avatar Apr 10 '24 12:04 msclock

No, I need at least 17 for C++ modules!

ClausKlein avatar Apr 10 '24 18:04 ClausKlein

There are no official LLVM binaries for x86 on Apple after LLVM 16. Brew builds LLVM from the source, which I consider impractical for day-to-day usage.

However, I am planning to add support for Apple ARM

aminya avatar Apr 10 '24 19:04 aminya

There are no official LLVM binaries for x86 on Apple after LLVM 16. Brew builds LLVM from the source, which I consider impractical for day-to-day usage.

However, I am planning to add support for Apple ARM

And is it practical to consider to use brew to install llvm-17/16. 🫤 For example:

brew install llvm@17
# export CXX as /usr/local/opt/llvm@17/bin/clang++
# export CC as /usr/local/opt/llvm@17/bin/clang
# export PATH as PATH=/usr/local/opt/llvm/bin:$PATH
brew install llvm@16
# export CXX as /usr/local/opt/llvm@16/bin/clang++
# export CC as /usr/local/opt/llvm@16/bin/clang
# export PATH as PATH=/usr/local/opt/llvm/bin:$PATH

msclock avatar Apr 11 '24 00:04 msclock

I have adopted the above workaround temporarily in macos-12 and it works here.

msclock avatar Apr 11 '24 11:04 msclock

The reason it works seems to be because some version is already cached/installed on the system: https://github.com/serious-scaffold/ss-cpp/actions/runs/8645856705/job/23703966694#step:5:18

Otherwise, it would take hours to compile Z3 and LLVM from the source for x86 if you try this on some other runner or locally.

I think there are some things we can do to reuse the already cached installations and error out for other versions. For Arm, this is totally solvable by using the official binaries.

aminya avatar Apr 11 '24 18:04 aminya