Skip to content

Commit

Permalink
bump: LLVM 11.0.1 & inkwell beta.2
Browse files Browse the repository at this point in the history
  • Loading branch information
baszalmstra committed Feb 28, 2021
1 parent d0d7afe commit 72ea35b
Show file tree
Hide file tree
Showing 129 changed files with 601 additions and 577 deletions.
8 changes: 0 additions & 8 deletions .github/actions-rs/grcov.yml

This file was deleted.

11 changes: 6 additions & 5 deletions .github/actions/install-llvm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1182,14 +1182,15 @@ async function execute(cmd) {
(async () => {
try {
if(isLinux) {
await exec.exec("sudo apt install llvm-8 llvm-8-* liblld-8*");
const installScript = path.join(__dirname, "../../../../scripts/install-llvm.sh");
await exec.exec(`sudo ${installScript}`);
} else if(isMacOS) {
await exec.exec("brew install llvm@8")
let llvmPath = await execute("brew --prefix llvm@8");
await exec.exec("brew install llvm@11")
let llvmPath = await execute("brew --prefix llvm@11");
core.addPath(`${llvmPath}/bin`)
} else if(isWindows) {
const downloadUrl = "https://github.com/mun-lang/llvm-package-windows/releases/download/v8.0.1/llvm-8.0.1-windows-x64-msvc16.7z"
core.info(`Downloading LLVM from '${downloadUrl}'`)
const downloadUrl = "https://github.com/mun-lang/llvm-package-windows/releases/download/v11.0.1/llvm-11.0.1-windows-x64-msvc16.7z"
core.info(`downloading LLVM from '${downloadUrl}'`)
const downloadLocation = await tc.downloadTool(downloadUrl);

core.info("Succesfully downloaded LLVM release, extracting...")
Expand Down
11 changes: 6 additions & 5 deletions .github/actions/install-llvm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ export async function execute(cmd) {
(async () => {
try {
if(isLinux) {
await exec.exec("sudo apt install llvm-8 llvm-8-* liblld-8*");
const installScript = path.join(__dirname, "../../../../scripts/install-llvm.sh");
await exec.exec(`sudo ${installScript}`);
} else if(isMacOS) {
await exec.exec("brew install llvm@8")
let llvmPath = await execute("brew --prefix llvm@8");
await exec.exec("brew install llvm@11")
let llvmPath = await execute("brew --prefix llvm@11");
core.addPath(`${llvmPath}/bin`)
} else if(isWindows) {
const downloadUrl = "https://github.com/mun-lang/llvm-package-windows/releases/download/v8.0.1/llvm-8.0.1-windows-x64-msvc16.7z"
core.info(`Downloading LLVM from '${downloadUrl}'`)
const downloadUrl = "https://github.com/mun-lang/llvm-package-windows/releases/download/v11.0.1/llvm-11.0.1-windows-x64-msvc16.7z"
core.info(`downloading LLVM from '${downloadUrl}'`)
const downloadLocation = await tc.downloadTool(downloadUrl);

core.info("Succesfully downloaded LLVM release, extracting...")
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
artifacts: "mun libmun_runtime.so"
}
- {
os: "windows-2016",
os: "windows-latest",
dir: win64,
artifacts: "mun.exe mun_runtime.dll mun_runtime.dll.lib"
}
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
- **Cross compilation** - The Mun compiler is able to compile to all supported
target platforms from any supported compiler platform.

- **Powerful IDE integration** *not implemented yet* - The Mun language and
compiler framework are designed to support source code queries, allowing for
powerful IDE integrations such as code completion and refactoring tools.
- **Powerful IDE integration** - The Mun language and compiler framework are
designed to support source code queries, allowing for powerful IDE
integrations such as code completion and refactoring tools.

## Example

Expand Down Expand Up @@ -145,7 +145,7 @@ Windows (64-bit only).
Make sure you have the following dependencies installed on you machine:

* [Rust](https://www.rust-lang.org/tools/install)
* [LLVM 8](https://docs.mun-lang.org/ch04-02-building-llvm.html)
* [LLVM 11](https://docs.mun-lang.org/ch04-02-building-llvm.html)

Clone the source code, including all submodules:

Expand Down
22 changes: 11 additions & 11 deletions book/src/ch04-02-building-llvm.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The Mun compiler makes heavy use of LLVM for all code-generation capabilities.
Installing it, however, can be tricky.
This document is a short guide on how to install LLVM on your machine so you can build Mun yourself.

Currently, Mun targets LLVM 8 so everything in this document refers to that version.
Currently, Mun targets LLVM 11 so everything in this document refers to that version.
However, these instructions should also hold for newer versions.

## Prebuild binaries
Expand All @@ -21,7 +21,7 @@ For Windows, [we maintain a repository](https://github.com/mun-lang/llvm-package
These releases are also used on our CI runners.

To use a release, download and extract it to your machine.
To make sure the build pipeline can find the binaries, add an environment variable called `LLVM_SYS_80_PREFIX` that points to the folder where you extracted the release.
To make sure the build pipeline can find the binaries, add an environment variable called `LLVM_SYS_110_PREFIX` that points to the folder where you extracted the release.
It is also possible to add the `bin` folder of the release to your path but using the environment variables allows you to have multiple LLVM releases on your machine.

> For LLVM 8 you should add the `LLVM_SYS_80_PREFIX` environment variable, for LLVM 11 add `LLVM_SYS_110_PREFIX`.
Expand All @@ -38,7 +38,7 @@ wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -

# Add the repository
# ${REPO_NAME} should be something like:
# deb http://apt.llvm.org/focal/ llvm-toolchain-focal-8 main
# deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main
#
# The `add-apt-repository` command is installed by the `software-properties-common` package:
# sudo apt install software-properties-common
Expand All @@ -48,24 +48,24 @@ add-apt-repository "${REPO_NAME}"
Once you have the proper APT repository configured you can install the required LLVM binaries with:

```bash
apt install llvm-8 llvm-8-* liblld-8*
apt install llvm-11 llvm-11-* liblld-11*
```

### MacOS

[Brew](https://brew.sh/) contains a cask for LLVM that can be used to build Mun:

```bash
brew install llvm@8
brew install llvm@11
```

After installing LLVM, you can either add the `bin` folder of the release to your path; or you can add a release-specific environment variable called `LLVM_SYS_80_PREFIX` that points to the release:
After installing LLVM, you can either add the `bin` folder of the release to your path; or you can add a release-specific environment variable called `LLVM_SYS_110_PREFIX` that points to the release:

```bash
export LLVM_SYS_80_PREFIX=$(brew --prefix llvm@8)
export LLVM_SYS_110_PREFIX=$(brew --prefix llvm@11)
```

Adding the `LLVM_SYS_80_PREFIX` variable is usually easier because the LLVM binaries will not conflict with any preinstalled version of LLVM and it allows you to easily install another version of LLVM side-by-side.
Adding the `LLVM_SYS_110_PREFIX` variable is usually easier because the LLVM binaries will not conflict with any preinstalled version of LLVM and it allows you to easily install another version of LLVM side-by-side.

> For LLVM 8 you should add the `LLVM_SYS_80_PREFIX` environment variable, for LLVM 11 add `LLVM_SYS_110_PREFIX`.
Expand All @@ -83,18 +83,18 @@ Download a dump of the LLVM repository from the [LLVM github repository](https:/

```bash
wget -qO- \
https://github.com/llvm/llvm-project/archive/llvmorg-8.0.1.tar.gz | \
https://github.com/llvm/llvm-project/archive/llvmorg-11.0.1.tar.gz | \
tar xzf -
```

Then build the required components and install them to `~/local`.

```bash
cd llvm-project-llvmorg-8.0.1/llvm
cd llvm-project-llvmorg-11.0.1/llvm
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="lld;clang" -DCMAKE_INSTALL_PREFIX=$HOME/local -DCMAKE_INSTALL_PREFIX=$HOME/local -DLLVM_ENABLE_LIBXML2=OFF
make install -j
```

After LLVM is build, make sure to add the `$HOME/local/bin` to you path or add an environment variable `LLVM_SYS_80_PREFIX` (or `LLVM_SYS_110_PREFIX` depending on the LLVM version you installed) that points to `$HOME/local`.
After LLVM is build, make sure to add the `$HOME/local/bin` to you path or add an environment variable `LLVM_SYS_110_PREFIX` (or `LLVM_SYS_110_PREFIX` depending on the LLVM version you installed) that points to `$HOME/local`.
4 changes: 2 additions & 2 deletions crates/mun_codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ hir = { version = "=0.2.0", path = "../mun_hir", package = "mun_hir" }
itertools = "0.9.0"
mun_codegen_macros = { path = "../mun_codegen_macros", package = "mun_codegen_macros" }
mun_target = { version = "=0.2.0", path = "../mun_target" }
mun_lld = { version = "=80.0.0", path = "../mun_lld" }
mun_lld = { path = "../mun_lld" }
anyhow = "1.0.31"
thiserror = "1.0.19"
salsa = "0.15.0"
Expand All @@ -28,7 +28,7 @@ array-init="0.1.0"
tempfile = "3"
paste = "0.1.6"
parking_lot = "0.10"
inkwell = { version = "=0.1.0-beta.2", features = ["llvm8-0", "no-libffi-linking"]}
inkwell = { version = "=0.1.0-beta.2", features = ["llvm11-0", "no-libffi-linking"]}
by_address = "1.0.4"

[dev-dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ source_filename = "main.mun"

@global_type_table = external global [1 x %"mun_codegen::ir::types::TypeInfo"*]

define float @add(float, float) {
define float @add(float %0, float %1) {
body:
%add = fadd float %0, %1
ret float %add
}

define float @subtract(float, float) {
define float @subtract(float %0, float %1) {
body:
%sub = fsub float %0, %1
ret float %sub
}

define float @multiply(float, float) {
define float @multiply(float %0, float %1) {
body:
%mul = fmul float %0, %1
ret float %mul
}

define float @divide(float, float) {
define float @divide(float %0, float %1) {
body:
%div = fdiv float %0, %1
ret float %div
}

define float @remainder(float, float) {
define float @remainder(float %0, float %1) {
body:
%rem = frem float %0, %1
ret float %rem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ source_filename = "main.mun"

@global_type_table = external global [1 x %"mun_codegen::ir::types::TypeInfo"*]

define double @add(double, double) {
define double @add(double %0, double %1) {
body:
%add = fadd double %0, %1
ret double %add
}

define double @subtract(double, double) {
define double @subtract(double %0, double %1) {
body:
%sub = fsub double %0, %1
ret double %sub
}

define double @multiply(double, double) {
define double @multiply(double %0, double %1) {
body:
%mul = fmul double %0, %1
ret double %mul
}

define double @divide(double, double) {
define double @divide(double %0, double %1) {
body:
%div = fdiv double %0, %1
ret double %div
}

define double @remainder(double, double) {
define double @remainder(double %0, double %1) {
body:
%rem = frem double %0, %1
ret double %rem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ source_filename = "main.mun"

@global_type_table = external global [1 x %"mun_codegen::ir::types::TypeInfo"*]

define i128 @add(i128, i128) {
define i128 @add(i128 %0, i128 %1) {
body:
%add = add i128 %0, %1
ret i128 %add
}

define i128 @subtract(i128, i128) {
define i128 @subtract(i128 %0, i128 %1) {
body:
%sub = sub i128 %0, %1
ret i128 %sub
}

define i128 @multiply(i128, i128) {
define i128 @multiply(i128 %0, i128 %1) {
body:
%mul = mul i128 %0, %1
ret i128 %mul
}

define i128 @divide(i128, i128) {
define i128 @divide(i128 %0, i128 %1) {
body:
%div = sdiv i128 %0, %1
ret i128 %div
}

define i128 @remainder(i128, i128) {
define i128 @remainder(i128 %0, i128 %1) {
body:
%rem = srem i128 %0, %1
ret i128 %rem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ source_filename = "main.mun"

@global_type_table = external global [1 x %"mun_codegen::ir::types::TypeInfo"*]

define i16 @add(i16, i16) {
define i16 @add(i16 %0, i16 %1) {
body:
%add = add i16 %0, %1
ret i16 %add
}

define i16 @subtract(i16, i16) {
define i16 @subtract(i16 %0, i16 %1) {
body:
%sub = sub i16 %0, %1
ret i16 %sub
}

define i16 @multiply(i16, i16) {
define i16 @multiply(i16 %0, i16 %1) {
body:
%mul = mul i16 %0, %1
ret i16 %mul
}

define i16 @divide(i16, i16) {
define i16 @divide(i16 %0, i16 %1) {
body:
%div = sdiv i16 %0, %1
ret i16 %div
}

define i16 @remainder(i16, i16) {
define i16 @remainder(i16 %0, i16 %1) {
body:
%rem = srem i16 %0, %1
ret i16 %rem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ source_filename = "main.mun"

@global_type_table = external global [1 x %"mun_codegen::ir::types::TypeInfo"*]

define i32 @add(i32, i32) {
define i32 @add(i32 %0, i32 %1) {
body:
%add = add i32 %0, %1
ret i32 %add
}

define i32 @subtract(i32, i32) {
define i32 @subtract(i32 %0, i32 %1) {
body:
%sub = sub i32 %0, %1
ret i32 %sub
}

define i32 @multiply(i32, i32) {
define i32 @multiply(i32 %0, i32 %1) {
body:
%mul = mul i32 %0, %1
ret i32 %mul
}

define i32 @divide(i32, i32) {
define i32 @divide(i32 %0, i32 %1) {
body:
%div = sdiv i32 %0, %1
ret i32 %div
}

define i32 @remainder(i32, i32) {
define i32 @remainder(i32 %0, i32 %1) {
body:
%rem = srem i32 %0, %1
ret i32 %rem
Expand Down
Loading

0 comments on commit 72ea35b

Please sign in to comment.