Skip to content

Automatically download LLVM build based on host platform#23

Merged
gbaraldi merged 3 commits into
JuliaLang:mainfrom
giordano:mg/llvm-upgrade
May 10, 2026
Merged

Automatically download LLVM build based on host platform#23
gbaraldi merged 3 commits into
JuliaLang:mainfrom
giordano:mg/llvm-upgrade

Conversation

@giordano
Copy link
Copy Markdown
Member

Tested on Linux with x86-64 and aarch64 architectures, and macOS Apple Silicon, for both LLVM 20.1.8 and 21.1.8 (related to #22).

CC @gbaraldi @topolarity.

@giordano
Copy link
Copy Markdown
Member Author

The only annoying thing is that llvm-config in the macOS build hardcodes absolute paths referring to Homebrew prefix, so that works only if one actually uses Homebrew, which I don't on my laptop, but I found another machine with Homebrew and it worked there.

Also, for the record I had issues on a couple of different aarch64-linux machines where compilation with LLVM_VER=21.1.8 failed with

In file included from tools/gen_target_tables.cpp:9:
In file included from /home/mose/repo/cpufeatures/build/llvm-21.1.8/include/llvm/ADT/StringMap.h:17:
In file included from /home/mose/repo/cpufeatures/build/llvm-21.1.8/include/llvm/ADT/StringMapEntry.h:19:
In file included from /home/mose/repo/cpufeatures/build/llvm-21.1.8/include/llvm/ADT/StringRef.h:12:
/home/mose/repo/cpufeatures/build/llvm-21.1.8/include/llvm/ADT/DenseMapInfo.h:17:10: fatal error: 'cassert' file not found
   17 | #include <cassert>
      |          ^~~~~~~~~
1 error generated.

The problem was that Clang was finding the wrong GCC installation, I fixed that by manually passing --gcc-install-dir=/usr/lib/gcc/aarch64-linux-gnu/13 (on these machines Clang was picking GCC14 installation, which for some reason didn't have all the C++ header files). This was a very system-specific issue (it worked out-of-the-box on machines where Clang picks a working GCC installation), but I shared the solution just in case someone else runs into the same.


#include "llvm/Config/llvm-config.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/Twine.h"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this because different targets have different headers?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a fix to get LLVM 21 tables generating

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was always a bug:

OS << "0x" << Twine::utohexstr(Word) << "ULL";
refers to Twine without including the necessary header file. Previous versions relied on accidental forward inclusion, but that's not very robust (and finally broke with LLVM 21).

@gbaraldi
Copy link
Copy Markdown
Member

Looks reasonable

@giordano
Copy link
Copy Markdown
Member Author

Looks reasonable

If this is good to go, can you please merge? I can't do it myself 🙂

@gbaraldi
Copy link
Copy Markdown
Member

I can merge it but not give you the bit seemingly

@gbaraldi gbaraldi merged commit fb15ab3 into JuliaLang:main May 10, 2026
9 checks passed
@giordano giordano deleted the mg/llvm-upgrade branch May 10, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants