Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Upgrade llvm-sys to 17.0.1 #435

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/acquire-solana-tools/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
shell: bash
run: |
mkdir ../llvm
curl -L https://github.com/solana-labs/platform-tools/releases/download/v1.39/move-dev-linux-x86_64.tar.bz2 \
curl -L https://github.com/solana-labs/platform-tools/releases/download/v1.41/move-dev-linux-x86_64.tar.bz2 \
-o ../llvm/move-dev-linux-x86_64.tar.bz2
ls -lh ../llvm
(cd ../llvm && tar xjf move-dev-linux-x86_64.tar.bz2)
Expand All @@ -22,7 +22,7 @@ runs:
shell: bash
run: |
mkdir ../platform-tools
curl -L https://github.com/solana-labs/platform-tools/releases/download/v1.39/platform-tools-linux-x86_64.tar.bz2 \
curl -L https://github.com/solana-labs/platform-tools/releases/download/v1.41/platform-tools-linux-x86_64.tar.bz2 \
-o ../platform-tools/platform-tools.tar.bz2
ls -lh ../platform-tools
(cd ../platform-tools && tar xjf platform-tools.tar.bz2)
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/llvm-ci-pre-land.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- name: cargo clippy
run: cargo xclippy --workspace --all-targets
env:
LLVM_SYS_150_PREFIX: ${{ env.MOVE_DEV_PATH }}
LLVM_SYS_170_PREFIX: ${{ env.MOVE_DEV_PATH }}
PLATFORM_TOOLS_ROOT: ${{ env.PLATFORM_TOOLS_PATH }}
- name: cargo fmt
run: cargo xfmt --check
Expand All @@ -85,7 +85,7 @@ jobs:
- name: run Solana-based move cli tests
run: "cargo test --features solana-backend -p move-cli --test build_testsuite_solana --test move_unit_tests_solana -- --test-threads 1"
env:
LLVM_SYS_150_PREFIX: ${{ env.MOVE_DEV_PATH }}
LLVM_SYS_170_PREFIX: ${{ env.MOVE_DEV_PATH }}
MOVE_NATIVE: ${{ env.MOVE_NATIVE_PATH }}
PLATFORM_TOOLS_ROOT: ${{ env.PLATFORM_TOOLS_PATH }}

Expand All @@ -107,7 +107,7 @@ jobs:
- name: run Solana-based move stdlib tests
run: "cargo run --features solana-backend -p move-cli --bin move -- test --solana -p language/move-stdlib"
env:
LLVM_SYS_150_PREFIX: ${{ env.MOVE_DEV_PATH }}
LLVM_SYS_170_PREFIX: ${{ env.MOVE_DEV_PATH }}
MOVE_NATIVE: ${{ env.MOVE_NATIVE_PATH }}
PLATFORM_TOOLS_ROOT: ${{ env.PLATFORM_TOOLS_PATH }}

Expand All @@ -129,6 +129,6 @@ jobs:
- name: run Solana-based move unit test framework tests
run: "cargo test --features solana-backend -p move-unit-test --test move_unit_test_testsuite -- --test-threads 1"
env:
LLVM_SYS_150_PREFIX: ${{ env.MOVE_DEV_PATH }}
LLVM_SYS_170_PREFIX: ${{ env.MOVE_DEV_PATH }}
MOVE_NATIVE: ${{ env.MOVE_NATIVE_PATH }}
PLATFORM_TOOLS_ROOT: ${{ env.PLATFORM_TOOLS_PATH }}
4 changes: 2 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
LLVM_SYS_150_PREFIX: ${{ env.MOVE_DEV_PATH }}
LLVM_SYS_170_PREFIX: ${{ env.MOVE_DEV_PATH }}
PLATFORM_TOOLS_ROOT: ${{ env.PLATFORM_TOOLS_PATH }}

- name: build move-ir-compiler
Expand All @@ -60,5 +60,5 @@ jobs:
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
LLVM_SYS_150_PREFIX: ${{ env.MOVE_DEV_PATH }}
LLVM_SYS_170_PREFIX: ${{ env.MOVE_DEV_PATH }}
PLATFORM_TOOLS_ROOT: ${{ env.PLATFORM_TOOLS_PATH }}
13 changes: 10 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion language/solana/llvm-extra-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"

[dependencies]
libc = "0.2"
llvm-sys = "150.0.3"
llvm-sys = "170.0.1"

[build-dependencies]
cc = "1.0.78"
Expand Down
4 changes: 2 additions & 2 deletions language/solana/llvm-extra-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::{path::PathBuf, process::Command};

fn main() -> anyhow::Result<()> {
// Get the path to llvm-config from the llvm-sys crate
let llvm_config_path = std::env::var("DEP_LLVM_15_CONFIG_PATH")
.context("DEP_LLVM_15_CONFIG_PATH not set")
let llvm_config_path = std::env::var("DEP_LLVM_17_CONFIG_PATH")
.context("DEP_LLVM_17_CONFIG_PATH not set")
.context("this probably means the llvm-sys build failed")?;
let llvm_config_path = PathBuf::from(llvm_config_path);
let llvm_config = LlvmConfig::new(llvm_config_path);
Expand Down
2 changes: 1 addition & 1 deletion language/solana/move-to-solana/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension-trait = "1.0.1"
itertools = "0.10"
libc = "0.2"
llvm-extra-sys = { path = "../llvm-extra-sys" }
llvm-sys = "150.0.3"
llvm-sys = "170.0.1"
log = "0.4.14"
move-binary-format = { path = "../../move-binary-format" }
move-bytecode-source-map = { path = "../../move-ir-compiler/move-bytecode-source-map" }
Expand Down
14 changes: 9 additions & 5 deletions language/solana/move-to-solana/src/stackless/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl Context {
}

pub fn array_type(&self, ll_elt_ty: Type, len: usize) -> Type {
unsafe { Type(LLVMArrayType(ll_elt_ty.0, len as libc::c_uint)) }
unsafe { Type(LLVMArrayType2(ll_elt_ty.0, len as u64)) }
}

pub fn vector_type(&self, ll_elt_ty: Type, len: usize) -> Type {
Expand Down Expand Up @@ -205,17 +205,21 @@ impl Context {
.iter()
.map(|x| Constant::int(llty, u256::U256::from((*x).to_u128().unwrap())).0)
.collect();
ArrayValue(LLVMConstArray(llty.0, vals.as_mut_ptr(), vals.len() as u32))
ArrayValue(LLVMConstArray2(
llty.0,
vals.as_mut_ptr(),
vals.len() as u64,
))
}
}

pub fn const_array(&self, vals: &Vec<Constant>, llty: Type) -> ArrayValue {
let mut llvals: Vec<_> = vals.iter().map(|v| v.get0()).collect();
unsafe {
ArrayValue(LLVMConstArray(
ArrayValue(LLVMConstArray2(
llty.0,
llvals.as_mut_ptr(),
vals.len() as u32,
vals.len() as u64,
))
}
}
Expand Down Expand Up @@ -1078,7 +1082,7 @@ impl Type {
}

pub fn get_array_length(&self) -> usize {
unsafe { LLVMGetArrayLength(self.0) as usize }
unsafe { LLVMGetArrayLength2(self.0) as usize }
}

pub fn get_element_type(&self) -> Type {
Expand Down
2 changes: 1 addition & 1 deletion language/tools/move-mv-llvm-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ move-to-solana = { path = "../../solana/move-to-solana" }
clap = { version = "3.1.8", features = ["derive"] }
#inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "master", features = ["llvm14-0"] }
semver = "1.0.13"
llvm-sys = "150.0.3"
llvm-sys = "170.0.1"
llvm-extra-sys = { path = "../../solana/llvm-extra-sys" }
extension-trait = "1.0.1"
num = "0.4.0"
Expand Down
17 changes: 17 additions & 0 deletions language/tools/move-mv-llvm-compiler/docs/Administration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,20 @@ to link issue with their PR.
[Frequently] Visit relevant move-language, sui, and aptos discord channels.

[As needed] Update solana-labs/#proj-move of major updates.

## Migration
### Toolchain migration to keep up with solana platform tools and move-dev tools
1. Update toolchain versions in scripts/acquire_solana_tools.sh, .github/actions/acquire-solana-tools/action.yml
1. Update LLVM_SYS_{VER}_PREFIX to the correct version
1. Update the versions in documents
1. Fix all build errors
1. Fix all tests
1. Announce in discord

### Upgrading llvm-sys
1. Create a github issue to track the progress
1. `grep` for all llvm-sys deps and migrate all of them at once (e.g. Cargo.lock files)
1. Fix build errors
1. Update the documentation
1. Update the ci scripts
1. Announce in discord
30 changes: 15 additions & 15 deletions language/tools/move-mv-llvm-compiler/docs/Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ First, follow the setup instructions for the [move-language/move](https://github
Testing requires an installation of the Solana [platform-tools](https://github.com/solana-labs/platform-tools). Platform-tools releases provide a build of llvm (packaged as move-dev tools) that supports the Solana variant of eBPF.

Known working revision:
- platform-tools: version `1.39`
- move-dev: version `1.39`
- platform-tools: version `1.41`
- move-dev: version `1.41`

`platform-tools` can be extracted from the binary release.

Export two environment variables:

- `PLATFORM_TOOLS_ROOT` - the path at which `platform-tools` was extracted
- `LLVM_SYS_150_PREFIX` - the path at which `move-dev` tools was extracted (as it has llvm binaries, including llvm-config that llvm-sys can use)
- `LLVM_SYS_170_PREFIX` - the path at which `move-dev` tools was extracted (as it has llvm binaries, including llvm-config that llvm-sys can use)

### After a toolchain update

Expand All @@ -45,25 +45,25 @@ rustup toolchain install 1.69.0
$ cd /path/to/platform-tools/releases/
# For OSX download (platform-tools-osx-x86_64.tar.bz2, move-dev-osx-x86_64.tar.bz2) for X86, or (move-dev-osx-x86_64.tar.bz2, move-dev-osx-aarch64.tar.bz2) for arm64 devices.

$ wget https://github.com/solana-labs/platform-tools/releases/download/v1.39/move-dev-linux-x86_64.tar.bz2
$ mkdir v1.39 && cd v1.39
$ wget https://github.com/solana-labs/platform-tools/releases/download/v1.41/move-dev-linux-x86_64.tar.bz2
$ mkdir v1.41 && cd v1.41
$ tar -xf ../platform-tools-linux-x86_64.tar.bz2
$ ls /path/to/platform-tools/releases/v1.39/move-dev
$ ls /path/to/platform-tools/releases/v1.41/move-dev
bin include lib
$ wget https://github.com/solana-labs/platform-tools/releases/download/v1.39/platform-tools-linux-x86_64.tar.bz2
$ wget https://github.com/solana-labs/platform-tools/releases/download/v1.41/platform-tools-linux-x86_64.tar.bz2
$ tar -xf platform-tools-linux-x86_64.tar.bz2
$ ls /path/to/platform-tools/releases/v1.39/platform-tools
$ ls /path/to/platform-tools/releases/v1.41/platform-tools
llvm rust version.md
$ export PLATFORM_TOOLS_ROOT=/path/to/platform-tools/releases/v1.39/platform-tools
$ LLVM_SYS_150_PREFIX=/path/to/platform-tools/releases/v1.39/move-dev
$ export PLATFORM_TOOLS_ROOT=/path/to/platform-tools/releases/v1.41/platform-tools
$ LLVM_SYS_170_PREFIX=/path/to/platform-tools/releases/v1.41/move-dev
```

## Building

```sh
# export LLVM_SYS_150_PREFIX (See Instructions to get move-dev tools)
# export LLVM_SYS_170_PREFIX (See Instructions to get move-dev tools)
# export PLATFORM_TOOLS_ROOT (See Instructions to get solana-labs/platform-tools)
cargo build -p move-ir-compiler -p move-compiler -p move-stdlib
cargo build -p move-mv-llvm-compiler -p move-ir-compiler -p move-compiler -p move-stdlib -p move-cli
```

## Testing
Expand All @@ -80,7 +80,7 @@ These test require the `move-ir-compiler` and `move-build` tools (See: [Build in
Run the tests with any of these commands:

```sh
# export LLVM_SYS_150_PREFIX (See Instructions to build solana-labs/llvm-project)
# export LLVM_SYS_170_PREFIX (See Instructions to build solana-labs/llvm-project)
# export PLATFORM_TOOLS_ROOT (See Instructions to get solana-labs/platform-tools)
cargo test -p move-mv-llvm-compiler --test ir-tests
cargo test -p move-mv-llvm-compiler --test move-ir-tests
Expand Down Expand Up @@ -111,7 +111,7 @@ locally if you make changes to move-stdlib for example.
- `move-unit-test-framework-tests-solana` - Solana-based move unit test framework tests

```sh
# export LLVM_SYS_150_PREFIX (See Instructions to build solana-labs/llvm-project)
# export LLVM_SYS_170_PREFIX (See Instructions to build solana-labs/llvm-project)
# export PLATFORM_TOOLS_ROOT (See Instructions to get solana-labs/platform-tools)
# export MOVE_NATIVE=/path/to/move-repo/language/move-native
cargo test --features solana-backend -p move-cli --test build_testsuite_solana --test move_unit_tests_solana -- --test-threads 1
Expand Down Expand Up @@ -193,7 +193,7 @@ To debug in VS Code add this config:
"RUST_BACKTRACE": "all",
"RUST_LOG": "debug",
"CARGO_MANIFEST_DIR": "something like /home/sol/work/git/move/language/tools/move-mv-llvm-compiler",
"LLVM_SYS_150_PREFIX": "something like /home/sol/work/git/platform-tools/out/rust/build/x86_64-unknown-linux-gnu/llvm",
"LLVM_SYS_170_PREFIX": "something like /home/sol/work/git/platform-tools/out/rust/build/x86_64-unknown-linux-gnu/llvm",
"PLATFORM_TOOLS_ROOT": "something like /home/sol/work/git/platform-tools/out/deploy"
},
"program": "something like /home/sol/work/git/move/target/debug/deps/dwarf_tests-XXXXXXXXXXXXXXXX",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ entry:

!0 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !1, producer: "move-mv-llvm-compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, sysroot: "/")
!1 = !DIFile(filename: "dwarf-struct-2-modules.move", directory: "/language/tools/move-mv-llvm-compiler/tests/dwarf-tests")
!2 = distinct !DISubprogram(name: "fun_1", linkageName: "fun_1", scope: !1, file: !1, line: 33, type: !3, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !4)
!2 = distinct !DISubprogram(name: "fun_1", linkageName: "fun_1", scope: !1, file: !1, line: 33, type: !3, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0)
!3 = !DISubroutineType(types: !4)
!4 = !{}
!5 = distinct !DILexicalBlock(scope: !2, file: !1, line: 5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ declare %struct.M__MyStruct @"0000000000000101_M_fun_1_AcLtMspYikxikv"()

!0 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !1, producer: "move-mv-llvm-compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, sysroot: "/")
!1 = !DIFile(filename: "dwarf-struct-2-modules.move", directory: "/language/tools/move-mv-llvm-compiler/tests/dwarf-tests")
!2 = distinct !DISubprogram(name: "fun_2", linkageName: "fun_2", scope: !1, file: !1, line: 7, type: !3, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !4)
!2 = distinct !DISubprogram(name: "fun_2", linkageName: "fun_2", scope: !1, file: !1, line: 7, type: !3, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0)
!3 = !DISubroutineType(types: !4)
!4 = !{}
!5 = distinct !DILexicalBlock(scope: !2, file: !1, line: 5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ entry:

!0 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !1, producer: "move-mv-llvm-compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, sysroot: "/")
!1 = !DIFile(filename: "dwarf-struct.move", directory: "/language/tools/move-mv-llvm-compiler/tests/dwarf-tests")
!2 = distinct !DISubprogram(name: "fun_1", linkageName: "fun_1", scope: !1, file: !1, line: 16, type: !3, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !4)
!2 = distinct !DISubprogram(name: "fun_1", linkageName: "fun_1", scope: !1, file: !1, line: 16, type: !3, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0)
!3 = !DISubroutineType(types: !4)
!4 = !{}
!5 = distinct !DILexicalBlock(scope: !2, file: !1, line: 5)
Expand Down
2 changes: 1 addition & 1 deletion scripts/acquire_solana_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export MOVE_DEV_PATH
export PLATFORM_TOOLS_PATH

# platform tools version
version=v1.39
version=v1.41

# check os and arch
OS=$(uname -s)
Expand Down