Merge pull request #456 from aofei/llvm-18

llvm: default to LLVM 18
This commit is contained in:
xushiwei
2024-07-07 15:44:20 +08:00
committed by GitHub
11 changed files with 83 additions and 22 deletions

View File

@@ -15,14 +15,14 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
llvm: [17]
llvm: [18]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Update Homebrew
# needed as long as LLVM 17 is still fresh
if: matrix.llvm == 17 && startsWith(matrix.os, 'macos')
# needed as long as LLVM 18 is still fresh
if: matrix.llvm == 18 && startsWith(matrix.os, 'macos')
run: brew update
- name: Install LLVM ${{ matrix.llvm }} and bdw-gc
if: startsWith(matrix.os, 'macos')

View File

@@ -263,9 +263,9 @@ Here are the Go packages that can be imported correctly:
## Dependencies
- [Go 1.20+](https://go.dev) (build only)
- [LLVM 17](https://llvm.org)
- [LLD 17](https://lld.llvm.org)
- [Clang 17](https://clang.llvm.org)
- [LLVM 18](https://llvm.org)
- [LLD 18](https://lld.llvm.org)
- [Clang 18](https://clang.llvm.org)
- [pkg-config 0.29+](https://www.freedesktop.org/wiki/Software/pkg-config/)
- [bdwgc/libgc 8.0+](https://www.hboehm.info/gc/)
- [cJSON 1.7+](https://github.com/DaveGamble/cJSON) (optional, for [github.com/goplus/llgo/c/cjson](https://pkg.go.dev/github.com/goplus/llgo/c/cjson))
@@ -280,10 +280,9 @@ Follow these steps to generate the `llgo` command (its usage is the same as the
```sh
brew update # execute if needed
brew install llvm@17 pkg-config libgc
brew install llvm@18 pkg-config libgc
brew install cjson sqlite python@3.12 # optional
export PATH=$(brew --prefix llvm@17)/bin:$PATH # you may want to add this to your shell RC file, e.g. ~/.zshrc
export CC=clang CXX=clang++ # only for go build; optional if you have other compatible compilers
export PATH=$(brew --prefix llvm@18)/bin:$PATH # you may want to add this to your shell RC file, e.g. ~/.zshrc
git clone https://github.com/goplus/llgo.git
cd llgo
export LLGOROOT="/path/to/llgo" # Replace this with the root directory of the llgo project
@@ -293,13 +292,12 @@ go install -v ./...
### on Linux (Debian/Ubuntu)
```sh
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-17 main" | sudo tee /etc/apt/sources.list.d/llvm.list
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-18 main" | sudo tee /etc/apt/sources.list.d/llvm.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update # execute if needed
sudo apt-get install -y llvm-17-dev clang-17 lld-17 pkg-config libgc-dev
sudo apt-get install -y llvm-18-dev clang-18 lld-18 pkg-config libgc-dev
sudo apt-get install -y libcjson-dev libsqlite3-dev python3.12-dev # optional
export PATH=/usr/lib/llvm-17/bin:$PATH # you may want to add this to your shell RC file, e.g. ~/.bashrc
export CC=clang CXX=clang++ # only for go build; optional if you have other compatible compilers
export PATH=/usr/lib/llvm-18/bin:$PATH # you may want to add this to your shell RC file, e.g. ~/.bashrc
git clone https://github.com/goplus/llgo.git
cd llgo
export LLGOROOT="/path/to/llgo" # Replace this with the root directory of the llgo project

View File

@@ -86,9 +86,9 @@ _llgo_0:
%5 = getelementptr inbounds { ptr, ptr }, ptr %3, i32 0, i32 1
store ptr %1, ptr %5, align 8
%6 = load { ptr, ptr }, ptr %3, align 8
call void @main.assert(i1 true)
call void @main.assert(i1 true)
call void @main.assert(i1 true)
call void @main.assert(i1 icmp ne (ptr @main.test, { ptr, ptr } zeroinitializer))
call void @main.assert(i1 icmp ne (ptr @main.test, { ptr, ptr } zeroinitializer))
call void @main.assert(i1 icmp ne (ptr @"main.init#1$1", { ptr, ptr } zeroinitializer))
%7 = extractvalue { ptr, ptr } %6, 0
%8 = icmp ne ptr %7, null
call void @main.assert(i1 %8)

2
go.mod
View File

@@ -5,7 +5,7 @@ go 1.20
require (
github.com/aykevl/go-wasm v0.0.1
github.com/goplus/gogen v1.16.0
github.com/goplus/llvm v0.7.6
github.com/goplus/llvm v0.8.0
github.com/goplus/mod v0.13.10
github.com/json-iterator/go v1.1.12
github.com/qiniu/x v1.13.10

4
go.sum
View File

@@ -6,8 +6,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/goplus/gogen v1.16.0 h1:hAK2ZX8vCjH+Y2QoJl9viSZ8Gw9pzE0vCz5voYBYnv4=
github.com/goplus/gogen v1.16.0/go.mod h1:92qEzVgv7y8JEFICWG9GvYI5IzfEkxYdsA1DbmnTkqk=
github.com/goplus/llvm v0.7.6 h1:1yFRS0fLj/Jk9BNMMWGd9tuPP8nRclTaX48pWogVd5c=
github.com/goplus/llvm v0.7.6/go.mod h1:PeVK8GgzxwAYCiMiUAJb5wJR6xbhj989tu9oulKLLT4=
github.com/goplus/llvm v0.8.0 h1:9eFutGm3d0G7bAd8/e+Tuyva0tu1IPNPm0kVG4AgHwY=
github.com/goplus/llvm v0.8.0/go.mod h1:PeVK8GgzxwAYCiMiUAJb5wJR6xbhj989tu9oulKLLT4=
github.com/goplus/mod v0.13.10 h1:5Om6KOvo31daN7N30kWU1vC5zhsJPM+uPbcEN/FnlzE=
github.com/goplus/mod v0.13.10/go.mod h1:HDuPZgpWiaTp3PUolFgsiX+Q77cbUWB/mikVHfYND3c=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=

View File

@@ -1,4 +1,4 @@
//go:build !byollvm && darwin && amd64 && !llvm14 && !llvm15 && !llvm16
//go:build !byollvm && darwin && amd64 && llvm17
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.

View File

@@ -0,0 +1,21 @@
//go:build !byollvm && darwin && amd64 && !llvm14 && !llvm15 && !llvm16 && !llvm17
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package llvm
const ldLLVMConfigBin = "/usr/local/opt/llvm@18/bin/llvm-config"

View File

@@ -1,4 +1,4 @@
//go:build !byollvm && darwin && !amd64 && !llvm14 && !llvm15 && !llvm16
//go:build !byollvm && darwin && !amd64 && llvm17
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.

View File

@@ -0,0 +1,21 @@
//go:build !byollvm && darwin && !amd64 && !llvm14 && !llvm15 && !llvm16 && !llvm17
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package llvm
const ldLLVMConfigBin = "/opt/homebrew/opt/llvm@18/bin/llvm-config"

View File

@@ -1,4 +1,4 @@
//go:build !byollvm && linux && !llvm14 && !llvm15 && !llvm16
//go:build !byollvm && linux && llvm17
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.

View File

@@ -0,0 +1,21 @@
//go:build !byollvm && linux && !llvm14 && !llvm15 && !llvm16 && !llvm17
/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package llvm
const ldLLVMConfigBin = "/usr/lib/llvm-18/bin/llvm-config"