Skip to content

Commit c1776da

Browse files
Update to LLVM 16 (ballerina-platform#1205)
* Update JNI.LLVM * Update MakeFiles * Add temperory workaround to make decQuad work * Update github workflows * Update the doc * Add fix to decNumber * Fix buffer * Update the nightly build to use llvm16
1 parent 0450ad1 commit c1776da

File tree

13 files changed

+38
-40
lines changed

13 files changed

+38
-40
lines changed

.github/workflows/make-test.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
matrix:
17-
os: [ubuntu-22.04, macos-latest]
17+
os: [ubuntu-latest, macos-latest]
1818
steps:
1919
- uses: actions/checkout@v2
2020
- name: Cache brew for LLVM (macOS)
@@ -28,16 +28,16 @@ jobs:
2828
- name: Install LLVM (macOS)
2929
if: runner.os == 'macOS'
3030
run: |
31-
brew install llvm@15
32-
echo "/usr/local/opt/llvm@15/bin" >> $GITHUB_PATH
31+
brew install llvm@16
32+
echo "/usr/local/opt/llvm@16/bin" >> $GITHUB_PATH
3333
echo "LLVM_SUFFIX=" >> $GITHUB_ENV
3434
- name: Install LLVM (linux)
3535
if: runner.os == 'Linux'
3636
run: |
3737
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
38-
sudo add-apt-repository deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main
38+
sudo add-apt-repository deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main
3939
sudo apt-get update
40-
sudo apt-get install -y clang-15 llvm-15
40+
sudo apt-get install -y clang-16 llvm-16
4141
- name: Cache jBallerina
4242
id: cache-jbal
4343
uses: actions/cache@v2

.github/workflows/validate-jballerina-nightly.yml

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ jobs:
1818
echo 'LATEST_RUN_ID<<EOF' >> $GITHUB_ENV
1919
gh run list --workflow main.yml --repo ballerina-platform/ballerina-distribution | grep success | head -n 1 | awk '{print $(NF-2)}' >> $GITHUB_ENV
2020
echo 'EOF' >> $GITHUB_ENV
21+
- name: Install LLVM 16
22+
run: |
23+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
24+
sudo add-apt-repository deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main
25+
sudo apt-get update
26+
sudo apt-get install -y clang-16 llvm-16
2127
- name: Download jBallerina
2228
env:
2329
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BAL?=bal
2-
LLVM_SUFFIX?=-15
2+
LLVM_SUFFIX?=-16
33
CLANG?=clang$(LLVM_SUFFIX)
44
CFLAGS=-O2
55
JAVA?=$(shell test/findJava.sh)

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ The compiler has not yet got to a stage where it is useful. But if you want to p
7979
2. [Download](https://ballerina.io/downloads/) and [install](https://ballerina.io/learn/user-guide/getting-started/installation-options/) the latest Ballerina distribution (Swan Lake not 1.2.x)
8080
3. You can build the compiler by using the command `bal build` in the `compiler` directory; this will generate a file `target/bin/nballerina.jar`. This should work on any system that Ballerina works on.
8181
4. You can use `java -jar nballerina.jar example.bal` to compile a Ballerina module into an LLVM assembly file `example.ll` (note that only a tiny subset of the language is currently implemented, as described in the Status section).
82-
5. If you want to be able to turn the LLVM assembly file into something you can execute, there are additional requirements: Linux or OS X, LLVM 15 and GNU make. With these, you can build the runtime and run the tests by running `make test` in the top-level directory. This compiles and executes all the test cases and checks that they produce the right outputs. You can use e.g. `make -j8` to make it run tests in parallel.
82+
5. If you want to be able to turn the LLVM assembly file into something you can execute, there are additional requirements: Linux or OS X, LLVM 16 and GNU make. With these, you can build the runtime and run the tests by running `make test` in the top-level directory. This compiles and executes all the test cases and checks that they produce the right outputs. You can use e.g. `make -j8` to make it run tests in parallel.
8383

8484
If you want to turn the LLVM assembly into an executable, you can use the [test/run.sh](test/run.sh) command.
8585

llvm_jni/Ballerina.toml

+13-13
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,40 @@ observabilityIncluded = false
99
path = "target/platform-libs/javacpp-platform-1.5.9-SNAPSHOT.jar"
1010

1111
[[platform.java11.dependency]]
12-
path = "target/platform-libs/llvm-platform-15.0.7-1.5.9-SNAPSHOT.jar"
12+
path = "target/platform-libs/llvm-platform-16.0.1-1.5.9-SNAPSHOT.jar"
1313

1414
[[platform.java11.dependency]]
15-
path = "target/platform-libs/javacpp-1.5.9-20230222.151859-137-linux-x86_64.jar"
15+
path = "target/platform-libs/javacpp-1.5.9-SNAPSHOT-linux-x86_64.jar"
1616

1717
[[platform.java11.dependency]]
18-
path = "target/platform-libs/javacpp-1.5.9-20230222.151859-137-linux-arm64.jar"
18+
path = "target/platform-libs/javacpp-1.5.9-SNAPSHOT-linux-arm64.jar"
1919

2020
[[platform.java11.dependency]]
21-
path = "target/platform-libs/javacpp-1.5.9-20230222.151859-137-macosx-arm64.jar"
21+
path = "target/platform-libs/javacpp-1.5.9-SNAPSHOT-macosx-arm64.jar"
2222

2323
[[platform.java11.dependency]]
24-
path = "target/platform-libs/javacpp-1.5.9-20230222.151859-137-macosx-x86_64.jar"
24+
path = "target/platform-libs/javacpp-1.5.9-SNAPSHOT-macosx-x86_64.jar"
2525

2626
[[platform.java11.dependency]]
27-
path = "target/platform-libs/javacpp-1.5.9-20230222.151859-137-windows-x86_64.jar"
27+
path = "target/platform-libs/javacpp-1.5.9-SNAPSHOT-windows-x86_64.jar"
2828

2929
[[platform.java11.dependency]]
30-
path = "target/platform-libs/javacpp-1.5.9-20230222.151859-137.jar"
30+
path = "target/platform-libs/javacpp-1.5.9-SNAPSHOT.jar"
3131

3232
[[platform.java11.dependency]]
33-
path = "target/platform-libs/llvm-15.0.7-1.5.9-SNAPSHOT-linux-arm64.jar"
33+
path = "target/platform-libs/llvm-16.0.1-1.5.9-SNAPSHOT-linux-arm64.jar"
3434

3535
[[platform.java11.dependency]]
36-
path = "target/platform-libs/llvm-15.0.7-1.5.9-SNAPSHOT-linux-x86_64.jar"
36+
path = "target/platform-libs/llvm-16.0.1-1.5.9-SNAPSHOT-linux-x86_64.jar"
3737

3838
[[platform.java11.dependency]]
39-
path = "target/platform-libs/llvm-15.0.7-1.5.9-SNAPSHOT-macosx-x86_64.jar"
39+
path = "target/platform-libs/llvm-16.0.1-1.5.9-SNAPSHOT-macosx-x86_64.jar"
4040

4141
[[platform.java11.dependency]]
42-
path = "target/platform-libs/llvm-15.0.7-1.5.9-SNAPSHOT-macosx-arm64.jar"
42+
path = "target/platform-libs/llvm-16.0.1-1.5.9-SNAPSHOT-macosx-arm64.jar"
4343

4444
[[platform.java11.dependency]]
45-
path = "target/platform-libs/llvm-15.0.7-1.5.9-SNAPSHOT-windows-x86_64.jar"
45+
path = "target/platform-libs/llvm-16.0.1-1.5.9-SNAPSHOT-windows-x86_64.jar"
4646

4747
[[platform.java11.dependency]]
48-
path = "target/platform-libs/llvm-15.0.7-1.5.9-SNAPSHOT.jar"
48+
path = "target/platform-libs/llvm-16.0.1-1.5.9-SNAPSHOT.jar"

llvm_jni/BallerinaLinuxX86_64.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ version = "0.1.0"
66
observabilityIncluded = false
77

88
[[platform.java11.dependency]]
9-
path = "target/platform-libs/javacpp-1.5.9-20230222.151859-137.jar"
9+
path = "target/platform-libs/javacpp-1.5.9-SNAPSHOT.jar"
1010

1111
[[platform.java11.dependency]]
1212
path = "target/platform-libs/javacpp-platform-1.5.9-SNAPSHOT.jar"
1313

1414
[[platform.java11.dependency]]
15-
path = "target/platform-libs/javacpp-1.5.9-20230222.151859-137-linux-x86_64.jar"
15+
path = "target/platform-libs/javacpp-1.5.9-SNAPSHOT-linux-x86_64.jar"
1616

1717
[[platform.java11.dependency]]
18-
path = "target/platform-libs/llvm-15.0.7-1.5.9-SNAPSHOT.jar"
18+
path = "target/platform-libs/llvm-16.0.1-1.5.9-SNAPSHOT.jar"
1919

2020
[[platform.java11.dependency]]
21-
path = "target/platform-libs/llvm-platform-15.0.7-1.5.9-SNAPSHOT.jar"
21+
path = "target/platform-libs/llvm-platform-16.0.1-1.5.9-SNAPSHOT.jar"
2222

2323
[[platform.java11.dependency]]
24-
path = "target/platform-libs/llvm-15.0.7-1.5.9-SNAPSHOT-linux-x86_64.jar"
24+
path = "target/platform-libs/llvm-16.0.1-1.5.9-SNAPSHOT-linux-x86_64.jar"

llvm_jni/build.gradle

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ repositories {
1616

1717
dependencies {
1818
// This is a workaround for missing javacpp in the latest snapshot build
19-
implementation 'org.bytedeco:javacpp:1.5.9-20230222.151859-137'
20-
implementation 'org.bytedeco:llvm-platform:15.0.7-1.5.9-SNAPSHOT'
19+
implementation 'org.bytedeco:llvm-platform:16.0.1-1.5.9-SNAPSHOT'
2120
}
2221

2322
ext {

llvm_jni/modules/jni.llvm/Module.bal

-7
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ public distinct class Module {
186186
jLLVMAddInstructionCombiningPass(modulePassesManager);
187187
jLLVMAddCFGSimplificationPass(modulePassesManager);
188188

189-
jLLVMAddPruneEHPass(modulePassesManager);
190189
jLLVMAddLowerConstantIntrinsicsPass(modulePassesManager);
191190

192191
jLLVMAddStripDeadPrototypesPass(modulePassesManager);
@@ -586,12 +585,6 @@ function jLLVMAddInstructionCombiningPass(handle passManagerRef) = @java:Method
586585
paramTypes: ["org.bytedeco.llvm.LLVM.LLVMPassManagerRef"]
587586
} external;
588587

589-
function jLLVMAddPruneEHPass(handle passManagerRef) = @java:Method {
590-
name: "LLVMAddPruneEHPass",
591-
'class: "org.bytedeco.llvm.global.LLVM",
592-
paramTypes: ["org.bytedeco.llvm.LLVM.LLVMPassManagerRef"]
593-
} external;
594-
595588
function jLLVMAddLowerConstantIntrinsicsPass(handle passManagerRef) = @java:Method {
596589
name: "LLVMAddLowerConstantIntrinsicsPass",
597590
'class: "org.bytedeco.llvm.global.LLVM",

runtime/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LLVM_SUFFIX?=-15
1+
LLVM_SUFFIX?=-16
22
export CLANG ?= clang$(LLVM_SUFFIX)
33
LLVM_AS ?= llvm-as$(LLVM_SUFFIX)
44
OPT ?= opt$(LLVM_SUFFIX)

runtime/third-party/decNumber/decCommon.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ static decFloat * decFinalize(decFloat *df, bcdnum *num,
258258
// coefficient < DECPMAX
259259
length=(uInt)(ulsd-umsd+1); // coefficient length
260260

261+
uByte buffer[ROUNDUP(DECPMAX+3, 4)]; // [+3 allows uInt padding]
261262
if (!NUMISSPECIAL(num)) {
262263
Int drop; // digits to be dropped
263264
// skip leading insignificant zeros to calculate an exact length
@@ -456,7 +457,6 @@ static decFloat * decFinalize(decFloat *df, bcdnum *num,
456457
// fold down needed; must copy to buffer in order to pad
457458
// with zeros safely; fortunately this is not the worst case
458459
// path because cannot have had a round
459-
uByte buffer[ROUNDUP(DECPMAX+3, 4)]; // [+3 allows uInt padding]
460460
uByte *s=umsd; // source
461461
uByte *t=buffer; // safe target
462462
uByte *tlsd=buffer+(ulsd-umsd)+shift; // target LSD

test/balt-sub.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
COMPILER_JAR=../../../build/compiler/bin/nballerina.jar
22
JAVA ?= $(shell ../../../test/findJava.sh)
33
TARGETS=all test testll compile
4-
LLVM_SUFFIX ?=-15
4+
LLVM_SUFFIX ?=-16
55
CLANG ?= clang$(LLVM_SUFFIX)
66
LLVM_LINK ?= llvm-link$(LLVM_SUFFIX)
77
CFLAGS ?= -O2

test/run.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
set -e
3-
LLVM_LINK="llvm-link${LLVM_SUFFIX--15}"
4-
CLANG="clang${LLVM_SUFFIX--15}"
3+
LLVM_LINK="llvm-link${LLVM_SUFFIX--16}"
4+
CLANG="clang${LLVM_SUFFIX--16}"
55
b=`basename $1 .ll`
66
$LLVM_LINK $1 ../runtime/balrt_inline.bc -o $b.bc
77
$LLVM_LINK $b._init.ll ../runtime/balrt_inline.bc -o $b._init.bc

test/sub.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ else
2929
endif
3030
bal_files = $(wildcard ../../../compiler/testSuite/$(tdir)/*-[vpo].bal)
3131
# These are usd in phase 3
32-
LLVM_SUFFIX ?=-15
32+
LLVM_SUFFIX ?=-16
3333
CLANG ?= clang$(LLVM_SUFFIX)
3434
LLVM_LINK ?= llvm-link$(LLVM_SUFFIX)
3535
CFLAGS ?= -O2

0 commit comments

Comments
 (0)