Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support LLVM 16 #13181

Merged
merged 25 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions .github/workflows/llvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,46 @@ jobs:
strategy:
fail-fast: false
matrix:
llvm_version: ["13.0.0", "14.0.0", "15.0.6"]
include:
- llvm_version: "13.0.0"
llvm_ubuntu_version: "20.04"
- llvm_version: "14.0.0"
llvm_ubuntu_version: "18.04"
- llvm_version: "15.0.6"
llvm_ubuntu_version: "18.04"
Comment on lines +22 to +24
Copy link
Member

@beta-ziliani beta-ziliani May 11, 2023

Choose a reason for hiding this comment

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

Why are these in 18.04? Don't they work in 20.04? 18.04 is close to EOL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the version number that comes with the LLVM download, our base image is now always 22.04

- llvm_version: "16.0.3"
llvm_ubuntu_version: "22.04"
name: "LLVM ${{ matrix.llvm_version }}"
steps:
- name: Checkout Crystal source
uses: actions/checkout@v3

- name: Cache LLVM and Clang
- name: Cache LLVM
id: cache-llvm
uses: actions/cache@v3
with:
path: |
C:/Program Files/LLVM
./llvm
path: ./llvm
key: llvm-${{ matrix.llvm_version }}
if: "${{ !env.ACT }}"

- uses: KyleMayes/install-llvm-action@13d5d77cbf0bd7e35cb02a8f9ed4bb85bed3393b # v1.8.0
with:
version: "${{ matrix.llvm_version }}"
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Install LLVM ${{ matrix.llvm_version }}
run: |
mkdir -p llvm
curl -L "https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.llvm_version }}/clang+llvm-${{ matrix.llvm_version }}-x86_64-linux-gnu-ubuntu-${{ matrix.llvm_ubuntu_version }}.tar.xz" > llvm.tar.xz
tar x --xz -C llvm --strip-components=1 -f llvm.tar.xz
if: steps.cache-llvm.outputs.cache-hit != 'true'

- name: Set LLVM_CONFIG
# LLVM_PATH is set by install-llvm-action
run: echo "LLVM_CONFIG=$LLVM_PATH/bin/llvm-config" >> $GITHUB_ENV
- name: Set up LLVM
run: |
sudo apt-get install -y libtinfo5
echo "PATH=$(pwd)/llvm/bin:$PATH" >> $GITHUB_ENV
echo "LLVM_CONFIG=$(pwd)/llvm/bin/llvm-config" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$(pwd)/llvm/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV

- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: "1.8.1"
crystal: "1.8.2"

- name: Build libllvm_ext
run: make -B deps
Expand Down
2 changes: 1 addition & 1 deletion src/llvm/ext/llvm-versions.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15.0 14.0 13.0 12.0 11.1 11.0 10.0 9.0 8.0
16.0 15.0 14.0 13.0 12.0 11.1 11.0 10.0 9.0 8.0
8 changes: 7 additions & 1 deletion src/llvm/ext/llvm_ext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ using namespace llvm;
#include <llvm/Bitcode/BitcodeWriter.h>
#include <llvm/Analysis/ModuleSummaryAnalysis.h>

#if LLVM_VERSION_GE(16, 0)
#define makeArrayRef ArrayRef
#endif

typedef DIBuilder *DIBuilderRef;
#define DIArray DINodeArray
template <typename T> T *unwrapDIptr(LLVMMetadataRef v) {
return (T *)(v ? unwrap<MDNode>(v) : NULL);
}
Expand Down Expand Up @@ -157,7 +163,7 @@ LLVMBool LLVMExtCreateMCJITCompilerForModule(
.setOptLevel((CodeGenOpt::Level)options.OptLevel)
.setTargetOptions(targetOptions);
bool JIT;
if (Optional<CodeModel::Model> CM = unwrap(options.CodeModel, JIT))
if (auto CM = unwrap(options.CodeModel, JIT))
builder.setCodeModel(*CM);
if (options.MCJMM)
builder.setMCJITMemoryManager(
Expand Down