Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into raii
Browse files Browse the repository at this point in the history
merging with upstream.
  • Loading branch information
hiemstar committed Jun 27, 2024
2 parents e020696 + cc543db commit df66d4c
Show file tree
Hide file tree
Showing 25 changed files with 281 additions and 116 deletions.
4 changes: 2 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ freebsd_task:
name: FreeBSD
freebsd_instance:
matrix:
image_family: freebsd-13-2
# image_family: freebsd-12-3
image_family: freebsd-14-0
env:
matrix:
LLVM_VERSION: 11
Expand All @@ -13,6 +12,7 @@ freebsd_task:
LLVM_VERSION: 15
LLVM_VERSION: 16
LLVM_VERSION: 17
LLVM_VERSION: 18
install_script: pkg install -y bash coreutils cmake gmake llvm$LLVM_VERSION
script: |
export CC=cc
Expand Down
38 changes: 24 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Check Format
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- run: ./travis.sh
env:
CHECK_CLANG_FORMAT: 1
Expand All @@ -20,15 +20,15 @@ jobs:
strategy:
matrix:
os: ['macos-12', 'windows-2022']
llvm: ['11', '12', '13', '14', '15', '16', '17']
llvm: ['11', '12', '13', '14', '15', '16', '17', '18']
cuda: ['0', '1']
lua: ['luajit', 'moonjit']
exclude:
# macOS: exclude cuda
- os: 'macos-12'
cuda: '1'

# Windows: exclude LLVM 12-17
# Windows: exclude LLVM 12-18
- os: 'windows-2022'
llvm: '12'
- os: 'windows-2022'
Expand All @@ -41,6 +41,8 @@ jobs:
llvm: '16'
- os: 'windows-2022'
llvm: '17'
- os: 'windows-2022'
llvm: '18'

# CUDA: only LLVM 11
- llvm: '12'
Expand All @@ -55,6 +57,8 @@ jobs:
cuda: '1'
- llvm: '17'
cuda: '1'
- llvm: '18'
cuda: '1'

# Moonjit: only LLVM 12
- llvm: '11'
Expand All @@ -69,8 +73,10 @@ jobs:
lua: 'moonjit'
- llvm: '17'
lua: 'moonjit'
- llvm: '18'
lua: 'moonjit'
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- run: ./travis.sh
shell: bash
env:
Expand All @@ -81,7 +87,7 @@ jobs:
SLIB_INCLUDE_LLVM: 1
SLIB_INCLUDE_LUAJIT: 1
TERRA_LUA: ${{ matrix.lua }}
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: terra-${{ matrix.os }}-x86_64-llvm-${{ matrix.llvm }}
path: |
Expand All @@ -93,7 +99,7 @@ jobs:
strategy:
matrix:
distro: ['ubuntu-18.04']
llvm: ['11', '12.0.1', '13.0.1', '14.0.6', '15.0.2', '16.0.3', '17.0.5']
llvm: ['11', '12.0.1', '13.0.1', '14.0.6', '15.0.2', '16.0.3', '17.0.5', '18.1.7']
lua: ['luajit', 'moonjit']
cuda: ['0', '1']
test: ['1']
Expand All @@ -111,6 +117,8 @@ jobs:
cuda: '1'
- llvm: '17.0.5'
cuda: '1'
- llvm: '18.1.7'
cuda: '1'

# Moonjit with LLVM 14 only:
- llvm: '11'
Expand All @@ -125,6 +133,8 @@ jobs:
lua: 'moonjit'
- llvm: '17.0.5'
lua: 'moonjit'
- llvm: '18.1.7'
lua: 'moonjit'

include:
# Defaults:
Expand Down Expand Up @@ -182,7 +192,7 @@ jobs:
# static: '0'
# test: '1'
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- run: ./travis.sh
env:
DOCKER_DISTRO: ${{ matrix.distro }}
Expand Down Expand Up @@ -210,7 +220,7 @@ jobs:
- arch: 'ppc64le'
llvm: '11.1.0'
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- run: ./travis.sh
env:
DOCKER_DISTRO: ${{ matrix.distro }}
Expand All @@ -219,7 +229,7 @@ jobs:
DOCKER_CUDA: ${{ matrix.cuda }}
DOCKER_VARIANT: ${{ matrix.variant }}
DOCKER_TEST: ${{ matrix.test }}
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: docker-${{ matrix.distro }}-${{ matrix.arch }}-llvm-${{ matrix.llvm }}
path: |
Expand All @@ -229,11 +239,11 @@ jobs:
name: Compatibility Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: ./docker/compatibility_test.sh ubuntu 18.04 "18.04 20.04 22.04" "" 13.0.1 luajit prebuilt 2
- uses: actions/upload-artifact@v2
- uses: actions/checkout@v4
- run: ./docker/compatibility_test.sh ubuntu 18.04 "18.04 20.04 22.04 24.04" "" 18.1.7 luajit prebuilt 2
- uses: actions/upload-artifact@v4
with:
name: docker-ubuntu-18.04-x86_64-llvm-13
name: docker-ubuntu-18.04-x86_64-llvm-18
path: |
terra-*.tar.xz
terra-*.7z
Expand All @@ -245,7 +255,7 @@ jobs:
nixpkgs: ['unstable', '24.05']
cuda: ['false', 'true']
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v13
with:
nix_path: nixpkgs=channel:nixos-${{ matrix.nixpkgs }}
Expand Down
9 changes: 7 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Unreleased Changes (Intended to be Version 1.2.0)
# Release 1.2.0 (2024-06-25)

This release adds new LLVM versions and introduces experimental support for SPIR-V code generation. Note that as of the tested LLVM versions, LLVM's native SPIR-V backend is unable to generate correct SPIR-V code in all cases; but the LLVM SPIR-V target can still be used in combination with the [LLVM/SPIR-V Translator](https://github.com/KhronosGroup/SPIRV-LLVM-Translator) to generate valid code.

Users who generate code for AMD GPUs are strongly encouraged to upgrade to LLVM 18 and ROCm 6.0.0, as previous version combinations generate bad code to varying degrees.

## Added features

* Support for LLVM 17
* Support for LLVM 17 and 18
* Experimental support for SPIR-V code generation (e.g., for Intel GPUs)

## Fixed Bugs

Expand Down
3 changes: 3 additions & 0 deletions cmake/Modules/FindClang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ FIND_AND_ADD_CLANG_LIB(clangBasic)
if(LLVM_VERSION_MAJOR GREATER 14)
FIND_AND_ADD_CLANG_LIB(clangSupport)
endif()
if(LLVM_VERSION_MAJOR GREATER 17)
FIND_AND_ADD_CLANG_LIB(clangAPINotes)
endif()

find_path(CLANG_INCLUDE_DIRS clang/Basic/Version.h HINTS ${LLVM_INCLUDE_DIRS})

Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/GetLuaJIT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ else()
DEPENDS ${LUAJIT_SOURCE_DIR}
# MACOSX_DEPLOYMENT_TARGET is a workaround for https://github.com/LuaJIT/LuaJIT/issues/484
# see also https://github.com/LuaJIT/LuaJIT/issues/575
COMMAND ${MAKE_EXE} install "PREFIX=${LUAJIT_INSTALL_PREFIX}" "CC=${CMAKE_C_COMPILER}" "STATIC_CC=${CMAKE_C_COMPILER} -fPIC" CCDEBUG=$<$<CONFIG:Debug>:-g> XCFLAGS=-DLUAJIT_ENABLE_GC64 MACOSX_DEPLOYMENT_TARGET=10.7
COMMAND ${CMAKE_COMMAND} -E env --unset=MAKEFLAGS ${MAKE_EXE} install "PREFIX=${LUAJIT_INSTALL_PREFIX}" "CC=${CMAKE_C_COMPILER}" "STATIC_CC=${CMAKE_C_COMPILER} -fPIC" CCDEBUG=$<$<CONFIG:Debug>:-g> XCFLAGS=-DLUAJIT_ENABLE_GC64 MACOSX_DEPLOYMENT_TARGET=10.7
WORKING_DIRECTORY ${LUAJIT_SOURCE_DIR}
VERBATIM
)
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ let

in stdenv.mkDerivation rec {
pname = "terra";
version = "1.1.1";
version = "1.2.0";

src = ./.;

Expand Down
39 changes: 22 additions & 17 deletions release/share/terra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,46 +112,51 @@ Building Terra

If the binary releases are not appropriate, then you can also build Terra from source. Terra has the following dependencies:

* A working C/C++ compiler (GCC, Clang, MSVC, etc.)
* Windows only: Visual Studio 2013, 2015, 2017 or 2019
* A working C/C++ compiler (GCC, Clang, MSVC, etc.) that supports at least C++ 17
* Windows only: Visual Studio 2022 (other versions may work but are untested)
* CMake (version 3.5 or greater)
* Linux, macOS, FreeBSD only: GNU Make (required for building LuaJIT)
* LLVM and Clang (see suppport table below)
* LuaJIT (note this is downloaded and installed automatically be default)
* LuaJIT (note this is downloaded and installed automatically by default)
* *Optional:* CUDA
* *Note:* In addition to CUDA, Terra also supports AMD and Intel GPUs. However, Terra does not link their GPU toolkits directly so this is not a build requirement.

On recent versions of Ubuntu, you can get these dependencies with:

```
sudo apt-get install build-essential cmake git llvm-13-dev libclang-13-dev clang-13 libmlir-13-dev libedit-dev libncurses5-dev zlib1g-dev libpfm4-dev
sudo apt-get install build-essential cmake git llvm-18-dev libclang-18-dev clang-18 libmlir-18-dev libedit-dev libncurses5-dev zlib1g-dev libpfm4-dev
```

On macOS with Homebrew, the following should be sufficient:

```
brew install cmake llvm@13
brew install cmake llvm@18
```

On FreeBSD, use:

```
pkg install -y cmake llvm13
pkg install -y cmake gmake llvm18
```

### Supported LLVM Versions ###

The current recommended version of LLVM is **13**. The following versions are also supported:
The current recommended version of LLVM is **18** for most platforms, except Windows (x86) and Linux (ARM) where LLVM 11 is required. The following versions are also supported:

| Version | Linux | macOS | FreeBSD | Windows | CUDA | AMD GPU \* | Notes |
| ------- | ----- | ----- | ------- | ------- | ---- | ---------- | ----- |
| 11 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | |
| 12 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | | |
| 13 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark: | |
| 14 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark: | |
| 15 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark: | |
| 16 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark: | |
| 17 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark: | |
| Version | Linux | macOS | FreeBSD | Windows | NVIDIA/CUDA | AMD/HIP \* | Intel/SPIRV \*\* | Notes |
| ------- | ------------- | ------------- | ------------- | ------------- | ------------- | -------------- | ---------------- | ----- |
| 11 | :green_heart: | :green_heart: | :green_heart: | :green_heart: | :green_heart: | | | |
| 12 | :green_heart: | :green_heart: | :green_heart: | | :green_heart: | | | |
| 13 | :green_heart: | :green_heart: | :green_heart: | | :green_heart: | :yellow_heart: | | |
| 14 | :green_heart: | :green_heart: | :green_heart: | | :green_heart: | :yellow_heart: | | |
| 15 | :green_heart: | :green_heart: | :green_heart: | | :green_heart: | :yellow_heart: | :yellow_heart: | |
| 16 | :green_heart: | :green_heart: | :green_heart: | | :green_heart: | :yellow_heart: | :yellow_heart: | |
| 17 | :green_heart: | :green_heart: | :green_heart: | | :green_heart: | :yellow_heart: | :green_heart: | |
| 18 | :green_heart: | :green_heart: | :green_heart: | | :green_heart: | :green_heart: | :green_heart: | |

\* Please note that AMD GPU support is currently experimental.
\* AMD GPU support is currently experimental. LLVM 18 is **strongly** recommended.

\*\* Intel GPU (SPIR-V) support is currently experimental.

The following versions were previously supported by Terra:

Expand Down
12 changes: 10 additions & 2 deletions src/llvmheaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@

#include "llvm/IR/LegacyPassManager.h"

#if LLVM_VERSION < 170
#include "llvm/Support/Host.h"
#else
#include "llvm/TargetParser/Host.h"
#endif
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Scalar.h"
Expand All @@ -32,7 +36,9 @@
#include "llvm/Support/Program.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/IPO.h"
#if LLVM_VERSION < 180
#include "llvm/Transforms/Vectorize.h"
#endif
#if LLVM_VERSION < 170
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#else
Expand Down Expand Up @@ -62,11 +68,13 @@
#include "llvmheaders_160.h"
#elif LLVM_VERSION < 180
#include "llvmheaders_170.h"
#elif LLVM_VERSION < 190
#include "llvmheaders_180.h"
#else
#error "unsupported LLVM version"
// for OSX code completion
#define LLVM_VERSION 170
#include "llvmheaders_170.h"
#define LLVM_VERSION 180
#include "llvmheaders_180.h"
#endif

#define UNIQUEIFY(T, x) (std::unique_ptr<T>(x))
Expand Down
34 changes: 34 additions & 0 deletions src/llvmheaders_180.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/Analysis/CallGraphSCCPass.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/Mangler.h"
//#include "llvm/ExecutionEngine/ObjectImage.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Linker/Linker.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"

#include "llvm/Support/VirtualFileSystem.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "clang/Rewrite/Frontend/Rewriters.h"
#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Object/SymbolSize.h"

#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Support/Error.h"

#define LLVM_PATH_TYPE std::string
#define RAW_FD_OSTREAM_NONE sys::fs::OF_None
#define RAW_FD_OSTREAM_BINARY sys::fs::OF_None
Loading

0 comments on commit df66d4c

Please sign in to comment.