aminya / setup-cpp

Install all the tools required for building and testing C++/C projects.
Apache License 2.0
185 stars 27 forks source link

Support llvm-17/16/15 on Macos #243

Closed msclock closed 4 days ago

msclock commented 5 months ago

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

aminya commented 5 months ago

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

msclock commented 5 months ago

@aminya thanks for your rapid feedback. Excellent work👍

ClausKlein commented 5 months ago

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 commented 5 months ago

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$ 
msclock commented 5 months ago

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.

ClausKlein commented 5 months ago

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

aminya commented 5 months ago

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

msclock commented 5 months ago

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 commented 5 months ago

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

aminya commented 5 months ago

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.