Skip to content

Commit

Permalink
Migrate to LLVM 15 (#181)
Browse files Browse the repository at this point in the history
* Update workflows to the new LLVM version

* Start migration

* Extend

* Update json dependency

* Extend

* Fix bugs

* Fix another bug

* Fix bug

* Fix more bugs

* Bring struct types in IR back

* Fix last bug

* Remove getPointerElementType from return type

* Remove more occurrences of getPointerElementType

* Remove more occurrences of getPointerElementType

* Fix bugs

* Fix last bugs

* Switch to LLVM 15.0.0-rc1 again

* Update test refs for LLVM 15

* Invalidate cache entry
  • Loading branch information
marcauberer authored Aug 8, 2022
1 parent 2a04e19 commit d6b0fd9
Show file tree
Hide file tree
Showing 127 changed files with 4,274 additions and 4,218 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/ci-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,23 @@ jobs:
uses: actions/cache@v3
with:
path: /home/runner/work/spice/llvm
key: llvm-14-0-6
key: llvm-15.0.0-rc1-invalidate

- name: Setup LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
cd ..
rm -rf llvm
git clone --depth 1 --branch llvmorg-14.0.6 https://github.com/llvm/llvm-project llvm
git clone --depth 1 --branch llvmorg-15.0.0-rc1 https://github.com/llvm/llvm-project llvm
mkdir ./llvm/build
cd ./llvm/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS_RELEASE="-O2" -GNinja ../llvm
cmake --build .
- name: Download Libs
run: |
mkdir ./lib
cd ./lib
git clone --depth 1 --branch 4.10.1 https://github.com/antlr/antlr4.git
mkdir json
curl -SsL "https://github.com/nlohmann/json/releases/download/v3.10.5/json.hpp" --output json/json.hpp
mkdir cli11
curl -SsL "https://github.com/spicelang/CLI11/releases/download/v2.2.0-spice/CLI11.hpp" --output cli11/CLI11.hpp
chmod +x setup-libs.sh
./setup-libs.sh
- name: Build Test target
env:
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,22 @@ jobs:
uses: actions/cache@v3
with:
path: /home/runner/work/spice/llvm
key: llvm-14-0-5
key: 15.0.0-rc1

- name: Setup LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
cd ..
git clone --depth 1 --branch llvmorg-14.0.5 https://github.com/llvm/llvm-project llvm
git clone --depth 1 --branch llvmorg-15.0.0-rc1 https://github.com/llvm/llvm-project llvm
mkdir ./llvm/build
cd ./llvm/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS_RELEASE="-O2" -GNinja ../llvm
cmake --build .
- name: Download Libs
run: |
mkdir ./lib
cd ./lib
git clone --depth 1 --branch 4.10.1 https://github.com/antlr/antlr4.git
mkdir json
curl -SsL "https://github.com/nlohmann/json/releases/download/v3.10.5/json.hpp" --output json/json.hpp
mkdir cli11
curl -SsL "https://github.com/spicelang/CLI11/releases/download/v2.2.0-spice/CLI11.hpp" --output cli11/CLI11.hpp
chmod +x setup-libs.sh
./setup-libs.sh
- name: Build Test target
env:
Expand Down
57 changes: 17 additions & 40 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,12 @@ jobs:
uses: actions/cache@v3
with:
path: /home/runner/work/spice/spice/llvm
key: llvm-14-0-6-linux-x64
key: llvm-15.0.0-rc1-linux-x64

- name: Clone LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: git clone --depth 1 --branch llvmorg-14.0.6 https://github.com/llvm/llvm-project.git llvm

- name: Setup LLVM - Configure
- name: Setup LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
git clone --depth 1 --branch llvmorg-15.0.0-rc1 https://github.com/llvm/llvm-project.git llvm
mkdir ./llvm/build
cd ./llvm/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS_RELEASE="-O2" -GNinja -Wno-dev -Wattributes ../llvm
Expand All @@ -65,13 +62,8 @@ jobs:
- name: Download Libs
run: |
mkdir -p ./lib
cd ./lib
git clone --branch 4.10.1 --depth 1 https://github.com/antlr/antlr4.git
mkdir json
curl -SsL "https://github.com/nlohmann/json/releases/download/v3.10.5/json.hpp" --output json/json.hpp
mkdir cli11
curl -SsL "https://github.com/spicelang/CLI11/releases/download/v2.2.0-spice/CLI11.hpp" --output cli11/CLI11.hpp
chmod +x setup-libs.sh
./setup-libs.sh
- name: Configure & compile project
env:
Expand Down Expand Up @@ -132,37 +124,22 @@ jobs:
uses: actions/cache@v3
with:
path: D:/a/spice/spice/llvm
key: llvm-14-0-6-win-x64
key: llvm-15.0.0-rc1-win-x64

- name: Clone LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: git clone --depth 1 --branch llvmorg-14.0.6 https://github.com/llvm/llvm-project.git llvm

- name: Setup LLVM - Configure
- name: Setup LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
git clone --depth 1 --branch llvmorg-15.0.0-rc1 https://github.com/llvm/llvm-project.git llvm
setx /M PATH "%PATH%;C:\mingw64\mingw64\bin"
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
echo "Adding MinGW to path done."
mkdir ./llvm/build
cd ./llvm/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS_RELEASE="-O2" -GNinja -Wno-dev -Wattributes ../llvm
- name: Setup LLVM - Build
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
cd ./llvm/build
cmake --build .
- name: Download Libs
run: |
mkdir -p ./lib
cd ./lib
git clone --branch 4.10.1 --depth 1 https://github.com/antlr/antlr4.git
mkdir json
curl -SsL "https://github.com/nlohmann/json/releases/download/v3.10.5/json.hpp" -o json/json.hpp
mkdir cli11
curl -SsL "https://github.com/spicelang/CLI11/releases/download/v2.2.0-spice/CLI11.hpp" --output cli11/CLI11.hpp
run: .\setup-libs.bat

- name: Configure & compile project
env:
Expand All @@ -188,7 +165,7 @@ jobs:

build-artifacts:
name: Build artifacts
needs: [build-compiler-linux, build-compiler-windows]
needs: [ build-compiler-linux, build-compiler-windows ]
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: enabled
Expand Down Expand Up @@ -245,7 +222,7 @@ jobs:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: v1.10.2
version: v1.10.3
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -305,9 +282,9 @@ jobs:
run: |
curl -sSf -u "${{ secrets.NEXUS_USERNAME }}:${{ secrets.NEXUS_PASSWORD }}" -H "Content-Type: multipart/form-data" --upload-file ./spice_${{ matrix.arch }}.rpm ${{ secrets.NEXUS_URL }}/fedora/spice/${{ steps.get_version.outputs.version }}/spice-${{ matrix.arch }}.rpm
# - name: Deploy to Alpine repo
# run: |
# curl -sSf -u "${{ secrets.NEXUS_USERNAME }}:${{ secrets.NEXUS_PASSWORD }}" -H "Content-Type: multipart/form-data" --data-binary "@./spice_${{ matrix.arch }}.apk" "${{ secrets.NEXUS_URL }}/alpine/spice/${{ steps.get_version.outputs.version }}/spice-${{ matrix.arch }}.apk"
# - name: Deploy to Alpine repo
# run: |
# curl -sSf -u "${{ secrets.NEXUS_USERNAME }}:${{ secrets.NEXUS_PASSWORD }}" -H "Content-Type: multipart/form-data" --data-binary "@./spice_${{ matrix.arch }}.apk" "${{ secrets.NEXUS_URL }}/alpine/spice/${{ steps.get_version.outputs.version }}/spice-${{ matrix.arch }}.apk"

build-win-installers:
name: Build Windows installers
Expand All @@ -317,9 +294,9 @@ jobs:
matrix:
config:
- {
arch: amd64,
label: x64
}
arch: amd64,
label: x64
}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ add_definitions(-DANTLR4CPP_STATIC)
include(ExternalAntlr4Cpp)
set(ANTLR_EXECUTABLE ${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/antlr-4.10.1-complete.jar)

# Find Google Test
add_subdirectory(lib/googletest)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})

# Find LLVM
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
Expand Down
2 changes: 1 addition & 1 deletion dev-setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ echo done.

REM - Clone LLVM
echo [Step 2] Cloning LLVM (Could take a while) ...
git clone --depth 1 --branch llvmorg-14.0.6 https://github.com/llvm/llvm-project llvm
git clone --depth 1 --branch llvmorg-15.0.0-rc1 https://github.com/llvm/llvm-project llvm
echo done.

REM - Build LLVM
Expand Down
2 changes: 1 addition & 1 deletion dev-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ colored_echo "done."

# Clone LLVM
colored_echo "[Step 2] Cloning LLVM (Could take a while) ... "
git clone --depth 1 --branch llvmorg-14.0.6 https://github.com/llvm/llvm-project llvm
git clone --depth 1 --branch llvmorg-15.0.0-rc1 https://github.com/llvm/llvm-project llvm
colored_echo "done."

# Build LLVM
Expand Down
12 changes: 7 additions & 5 deletions media/test-project/os-test.spice
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ f<int> main() {
}*/

f<int> main() {
int value0 = 2;
int[5] intArray = { value0, 7, 4 };
intArray[2] *= 11;
intArray[0] = 3;
printf("Item 0: %d, item 2: %d", intArray[0], intArray[2]);
int[10][10] a;
for int i = 0; i < 10; i++ {
for int j = 0; j < 10; j++ {
a[i][j] = i * j;
}
}
printf("Cell [1,3]: %d", a[1][3]);
}
4 changes: 3 additions & 1 deletion setup-libs.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ pushd lib

git clone --depth 1 --branch 4.10.1 https://github.com/antlr/antlr4.git

git clone --depth 1 --branch release-1.12.1 https://github.com/google/googletest.git

mkdir json
curl -SsL "https://github.com/nlohmann/json/releases/download/v3.10.5/json.hpp" --output json/json.hpp
curl -SsL "https://github.com/nlohmann/json/releases/download/v3.11.1/json.hpp" --output json/json.hpp

mkdir cli11
curl -SsL "https://github.com/spicelang/CLI11/releases/download/v2.2.0-spice/CLI11.hpp" --output cli11/CLI11.hpp
Expand Down
4 changes: 3 additions & 1 deletion setup-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ cd lib || exit

git clone --depth 1 --branch 4.10.1 https://github.com/antlr/antlr4.git

git clone --depth 1 --branch release-1.12.1 https://github.com/google/googletest.git

mkdir json
curl -SsL "https://github.com/nlohmann/json/releases/download/v3.10.5/json.hpp" --output json/json.hpp
curl -SsL "https://github.com/nlohmann/json/releases/download/v3.11.1/json.hpp" --output json/json.hpp

mkdir cli11
curl -SsL "https://github.com/spicelang/CLI11/releases/download/v2.2.0-spice/CLI11.hpp" --output cli11/CLI11.hpp
Expand Down
Loading

0 comments on commit d6b0fd9

Please sign in to comment.