From 6ceb5cb87b7a471a38b6476db0502cb038c346cd Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Fri, 5 Jul 2024 08:42:24 +0530 Subject: [PATCH 1/8] CI tests for LLVM 10, 14, 15 and 16 by default we test LLVM 11 --- .github/workflows/CI.yml | 50 +++++++++++++++++++++++++++++++++++ ci/environment_linux_llvm.yml | 21 +++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 ci/environment_linux_llvm.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4a321f00e7..6e43c57ab9 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -496,6 +496,56 @@ jobs: cd integration_tests ./run_tests.py -b cpython c_py + test_llvm: + name: Test LLVM ${{ matrix.llvm-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + llvm-version: ["10", "14", "15", "16"] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: mamba-org/setup-micromamba@v1.8.0 + with: + environment-file: ci/environment_linux_llvm.yml + create-args: >- + llvmdev=${{ matrix.llvm-version }} + python=3.10 + bison=3.4 + + - uses: hendrikmuhs/ccache-action@main + with: + variant: sccache + key: ${{ github.job }}-${{ matrix.llvm-version }} + + - name: Build Linux + shell: bash -e -l {0} + run: | + ./build0.sh + export CXXFLAGS="-Werror" + cmake . -GNinja \ + -DCMAKE_BUILD_TYPE=Debug \ + -DWITH_LLVM=yes \ + -DLFORTRAN_BUILD_ALL=yes \ + -DWITH_STACKTRACE=no \ + -DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \ + -DCMAKE_INSTALL_PREFIX=`pwd`/inst \ + -DCMAKE_C_COMPILER_LAUNCHER=sccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + + cmake --build . -j16 --target install + + - name: Test Linux LLVM 10-16 + shell: bash -e -l {0} + run: | + ctest --output-on-failure + cd integration_tests + ./run_tests.py -b llvm llvm_jit + ./run_tests.py -b llvm llvm_jit -f + build_jupyter_kernel: name: Build Jupyter Kernel runs-on: ubuntu-latest diff --git a/ci/environment_linux_llvm.yml b/ci/environment_linux_llvm.yml new file mode 100644 index 0000000000..d6f36a6543 --- /dev/null +++ b/ci/environment_linux_llvm.yml @@ -0,0 +1,21 @@ +name: lp +channels: + - conda-forge + - defaults +dependencies: + - toml + - pytest + - jupyter + - xeus=1.0.1 + - xtl + - nlohmann_json + - cppzmq + - jupyter_kernel_test + - xonsh + - re2c + - numpy + - zlib + - ninja + - rapidjson +# - bison=3.4 [not win] +# - m2-bison=3.4 [win] From 986cbd7f7239231910c7f0d699dcda12e3d94a3c Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Fri, 5 Jul 2024 08:48:32 +0530 Subject: [PATCH 2/8] add sympy dependency for LLVM tests --- .github/workflows/CI.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 6e43c57ab9..ee18d889e0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -515,6 +515,8 @@ jobs: llvmdev=${{ matrix.llvm-version }} python=3.10 bison=3.4 + symengine=0.12.0 + sympy=1.11.1 - uses: hendrikmuhs/ccache-action@main with: From 333ccedf2197846228645aab1a53abf65e78af06 Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Fri, 5 Jul 2024 09:10:21 +0530 Subject: [PATCH 3/8] changed dependencies according to my local machine, where tests pass --- .github/workflows/CI.yml | 4 ---- ci/environment_linux_llvm.yml | 27 +++++++++++++-------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ee18d889e0..ebb7636ac8 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -513,10 +513,6 @@ jobs: environment-file: ci/environment_linux_llvm.yml create-args: >- llvmdev=${{ matrix.llvm-version }} - python=3.10 - bison=3.4 - symengine=0.12.0 - sympy=1.11.1 - uses: hendrikmuhs/ccache-action@main with: diff --git a/ci/environment_linux_llvm.yml b/ci/environment_linux_llvm.yml index d6f36a6543..ffe4ddd2a9 100644 --- a/ci/environment_linux_llvm.yml +++ b/ci/environment_linux_llvm.yml @@ -3,19 +3,18 @@ channels: - conda-forge - defaults dependencies: - - toml - - pytest - - jupyter - - xeus=1.0.1 - - xtl - - nlohmann_json - - cppzmq - - jupyter_kernel_test - - xonsh + - git + - pip + - make - re2c - - numpy + - toml - zlib - - ninja - - rapidjson -# - bison=3.4 [not win] -# - m2-bison=3.4 [win] + - cmake + - numpy + - flake8 + - setuptools + - bison=3.4 + - python=3.10.2 + - zstd-static=1.5 + - symengine=0.12.0 + - sympy=1.11.1 From c192c49cc06382353e7a008c3d881b5744b4200f Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Fri, 5 Jul 2024 09:13:44 +0530 Subject: [PATCH 4/8] fix . --- .github/workflows/CI.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ebb7636ac8..a43c163467 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -524,11 +524,12 @@ jobs: run: | ./build0.sh export CXXFLAGS="-Werror" - cmake . -GNinja \ + cmake . -G"Unix Makefiles" \ -DCMAKE_BUILD_TYPE=Debug \ -DWITH_LLVM=yes \ -DLFORTRAN_BUILD_ALL=yes \ -DWITH_STACKTRACE=no \ + -DWITH_RUNTIME_STACKTRACE=yes \ -DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \ -DCMAKE_INSTALL_PREFIX=`pwd`/inst \ -DCMAKE_C_COMPILER_LAUNCHER=sccache \ From f28ef0c0e48df7fa5933f782caefdadeb709ff2a Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Tue, 9 Jul 2024 16:20:13 +0530 Subject: [PATCH 5/8] Update .github/workflows/CI.yml Co-authored-by: Shaikh Ubaid --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a43c163467..cda1faddf1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -537,7 +537,7 @@ jobs: cmake --build . -j16 --target install - - name: Test Linux LLVM 10-16 + - name: Test Linux LLVM ${{ matrix.llvm-version }} shell: bash -e -l {0} run: | ctest --output-on-failure From f2aa76e90b9b616b270d610cd97809c2bd885e1e Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Tue, 23 Jul 2024 18:59:01 +0530 Subject: [PATCH 6/8] figuring out cause of error Commenting out tests that throw LLVM exceptions --- src/lpython/tests/test_llvm.cpp | 106 ++++++++++++++++---------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/src/lpython/tests/test_llvm.cpp b/src/lpython/tests/test_llvm.cpp index 22a185bd1d..8a4d4a6e9d 100644 --- a/src/lpython/tests/test_llvm.cpp +++ b/src/lpython/tests/test_llvm.cpp @@ -41,59 +41,59 @@ define i64 @f2() //CHECK(e.execfn("f2") == 5); } -TEST_CASE("llvm 1 fail") { - LCompilers::LLVMEvaluator e; - CHECK_THROWS_AS(e.add_module(R"""( -define i64 @f1() -{ - ; FAIL: "=x" is incorrect syntax - %1 =x alloca i64 -} - )"""), LCompilers::LCompilersException); - CHECK_THROWS_WITH(e.add_module(R"""( -define i64 @f1() -{ - ; FAIL: "=x" is incorrect syntax - %1 =x alloca i64 -} - )"""), "parse_module(): Invalid LLVM IR"); -} - - -TEST_CASE("llvm 2") { - LCompilers::LLVMEvaluator e; - e.add_module(R"""( -@count = global i64 0 - -define i64 @f1() -{ - store i64 4, i64* @count - %1 = load i64, i64* @count - ret i64 %1 -} - )"""); - CHECK(e.execfn("f1") == 4); - - e.add_module(R"""( -@count = external global i64 - -define i64 @f2() -{ - %1 = load i64, i64* @count - ret i64 %1 -} - )"""); - CHECK(e.execfn("f2") == 4); - - CHECK_THROWS_AS(e.add_module(R"""( -define i64 @f3() -{ - ; FAIL: @count is not defined - %1 = load i64, i64* @count - ret i64 %1 -} - )"""), LCompilers::LCompilersException); -} +// TEST_CASE("llvm 1 fail") { +// LCompilers::LLVMEvaluator e; +// CHECK_THROWS_AS(e.add_module(R"""( +// define i64 @f1() +// { +// ; FAIL: "=x" is incorrect syntax +// %1 =x alloca i64 +// } +// )"""), LCompilers::LCompilersException); +// CHECK_THROWS_WITH(e.add_module(R"""( +// define i64 @f1() +// { +// ; FAIL: "=x" is incorrect syntax +// %1 =x alloca i64 +// } +// )"""), "parse_module(): Invalid LLVM IR"); +// } + + +// TEST_CASE("llvm 2") { +// LCompilers::LLVMEvaluator e; +// e.add_module(R"""( +// @count = global i64 0 + +// define i64 @f1() +// { +// store i64 4, i64* @count +// %1 = load i64, i64* @count +// ret i64 %1 +// } +// )"""); +// CHECK(e.execfn("f1") == 4); + +// e.add_module(R"""( +// @count = external global i64 + +// define i64 @f2() +// { +// %1 = load i64, i64* @count +// ret i64 %1 +// } +// )"""); +// CHECK(e.execfn("f2") == 4); + +// CHECK_THROWS_AS(e.add_module(R"""( +// define i64 @f3() +// { +// ; FAIL: @count is not defined +// %1 = load i64, i64* @count +// ret i64 %1 +// } +// )"""), LCompilers::LCompilersException); +// } TEST_CASE("llvm 3") { LCompilers::LLVMEvaluator e; From fa7b40c155e5b25884f433059c4b8f0722ffd385 Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Tue, 23 Jul 2024 19:07:44 +0530 Subject: [PATCH 7/8] figuring out cause of error skipping ctest, checking if integration tests pass --- .github/workflows/CI.yml | 2 +- src/lpython/tests/test_llvm.cpp | 106 ++++++++++++++++---------------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index cda1faddf1..9c0ba24522 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -540,7 +540,7 @@ jobs: - name: Test Linux LLVM ${{ matrix.llvm-version }} shell: bash -e -l {0} run: | - ctest --output-on-failure + # ctest --output-on-failure cd integration_tests ./run_tests.py -b llvm llvm_jit ./run_tests.py -b llvm llvm_jit -f diff --git a/src/lpython/tests/test_llvm.cpp b/src/lpython/tests/test_llvm.cpp index 8a4d4a6e9d..22a185bd1d 100644 --- a/src/lpython/tests/test_llvm.cpp +++ b/src/lpython/tests/test_llvm.cpp @@ -41,59 +41,59 @@ define i64 @f2() //CHECK(e.execfn("f2") == 5); } -// TEST_CASE("llvm 1 fail") { -// LCompilers::LLVMEvaluator e; -// CHECK_THROWS_AS(e.add_module(R"""( -// define i64 @f1() -// { -// ; FAIL: "=x" is incorrect syntax -// %1 =x alloca i64 -// } -// )"""), LCompilers::LCompilersException); -// CHECK_THROWS_WITH(e.add_module(R"""( -// define i64 @f1() -// { -// ; FAIL: "=x" is incorrect syntax -// %1 =x alloca i64 -// } -// )"""), "parse_module(): Invalid LLVM IR"); -// } - - -// TEST_CASE("llvm 2") { -// LCompilers::LLVMEvaluator e; -// e.add_module(R"""( -// @count = global i64 0 - -// define i64 @f1() -// { -// store i64 4, i64* @count -// %1 = load i64, i64* @count -// ret i64 %1 -// } -// )"""); -// CHECK(e.execfn("f1") == 4); - -// e.add_module(R"""( -// @count = external global i64 - -// define i64 @f2() -// { -// %1 = load i64, i64* @count -// ret i64 %1 -// } -// )"""); -// CHECK(e.execfn("f2") == 4); - -// CHECK_THROWS_AS(e.add_module(R"""( -// define i64 @f3() -// { -// ; FAIL: @count is not defined -// %1 = load i64, i64* @count -// ret i64 %1 -// } -// )"""), LCompilers::LCompilersException); -// } +TEST_CASE("llvm 1 fail") { + LCompilers::LLVMEvaluator e; + CHECK_THROWS_AS(e.add_module(R"""( +define i64 @f1() +{ + ; FAIL: "=x" is incorrect syntax + %1 =x alloca i64 +} + )"""), LCompilers::LCompilersException); + CHECK_THROWS_WITH(e.add_module(R"""( +define i64 @f1() +{ + ; FAIL: "=x" is incorrect syntax + %1 =x alloca i64 +} + )"""), "parse_module(): Invalid LLVM IR"); +} + + +TEST_CASE("llvm 2") { + LCompilers::LLVMEvaluator e; + e.add_module(R"""( +@count = global i64 0 + +define i64 @f1() +{ + store i64 4, i64* @count + %1 = load i64, i64* @count + ret i64 %1 +} + )"""); + CHECK(e.execfn("f1") == 4); + + e.add_module(R"""( +@count = external global i64 + +define i64 @f2() +{ + %1 = load i64, i64* @count + ret i64 %1 +} + )"""); + CHECK(e.execfn("f2") == 4); + + CHECK_THROWS_AS(e.add_module(R"""( +define i64 @f3() +{ + ; FAIL: @count is not defined + %1 = load i64, i64* @count + ret i64 %1 +} + )"""), LCompilers::LCompilersException); +} TEST_CASE("llvm 3") { LCompilers::LLVMEvaluator e; From f09409fe674112b1cdd579f3c9fa1b008b59e350 Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Fri, 26 Jul 2024 20:52:36 +0530 Subject: [PATCH 8/8] remove LLVM 14 test --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9c0ba24522..362159b5a7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -502,7 +502,7 @@ jobs: strategy: fail-fast: false matrix: - llvm-version: ["10", "14", "15", "16"] + llvm-version: ["10", "15", "16"] steps: - uses: actions/checkout@v4 with: @@ -540,7 +540,7 @@ jobs: - name: Test Linux LLVM ${{ matrix.llvm-version }} shell: bash -e -l {0} run: | - # ctest --output-on-failure + ctest --output-on-failure cd integration_tests ./run_tests.py -b llvm llvm_jit ./run_tests.py -b llvm llvm_jit -f