From f39673e3ce40d9d4851da4424f8f86e28336f25d Mon Sep 17 00:00:00 2001 From: Arthur Mazeau Date: Thu, 27 Nov 2025 16:36:23 +0000 Subject: [PATCH 1/4] [test]: workflow --- .github/workflows/ci.yml | 84 +++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb61f3a..18d95ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,30 +1,70 @@ -name: CI +name: Build on: push: - branches: [ main, feature/stack-buffer-bounds-check ] + branches: [ main, feat/*, 3-feat-ci-add-build-workflow ] pull_request: + branches: [ main ] + workflow_dispatch: jobs: - build-and-test: - runs-on: ubuntu-latest + build: + name: Build on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install build dependencies - run: | - sudo apt-get update - sudo apt-get install -y cmake ninja-build build-essential python3 - - - name: Configure and build (CMake) - run: | - mkdir -p build - cd build - cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release - ninja stack_usage_analyzer - - - name: Run analyzer tests (Python framework) - run: | - python3 run_tests.py + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install dependencies (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake + # Install LLVM and Clang 19 + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main" + sudo apt-get update + sudo apt-get install -y llvm-19 llvm-19-dev clang-19 libclang-19-dev + echo "LLVM_DIR=/usr/lib/llvm-19/lib/cmake/llvm" >> $GITHUB_ENV + echo "Clang_DIR=/usr/lib/llvm-19/lib/cmake/clang" >> $GITHUB_ENV + + - name: Install dependencies (macOS) + if: runner.os == 'macOS' + run: | + brew install cmake llvm@19 + echo "LLVM_DIR=$(brew --prefix llvm@19)/lib/cmake/llvm" >> $GITHUB_ENV + echo "Clang_DIR=$(brew --prefix llvm@19)/lib/cmake/clang" >> $GITHUB_ENV + echo "$(brew --prefix llvm@19)/bin" >> $GITHUB_PATH + + - name: Configure and Build (Linux/macOS) + if: runner.os == 'Linux' || runner.os == 'macOS' + run: | + mkdir -p build && cd build + cmake .. -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_DIR=${{ env.LLVM_DIR }} \ + -DClang_DIR=${{ env.Clang_DIR }} \ + -DUSE_SHARED_LIB=OFF \ + -DBUILD_TESTS=OFF + cmake --build . --config Release + + - name: Test compiler (Linux/macOS) + if: runner.os == 'Linux' || runner.os == 'macOS' + run: | + cd build + echo 'int main() { return 0; }' > test.cc + ./cc -S -emit-llvm test.cc + + # Vérifier que le fichier LLVM IR a été généré + if [ -f "test.ll" ]; then + echo "Test réussi: Fichier LLVM IR généré avec succès" + cat test.ll | head -n 10 + else + echo "Test échoué: Fichier LLVM IR non généré" + exit 1 + fi From acb4d494f28ed94458869642726e87c643b8a3c2 Mon Sep 17 00:00:00 2001 From: Arthur Mazeau Date: Thu, 27 Nov 2025 16:42:01 +0000 Subject: [PATCH 2/4] [test]: workflow --- .github/workflows/ci.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18d95ab..af81089 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,21 +26,21 @@ jobs: run: | sudo apt-get update sudo apt-get install -y build-essential cmake - # Install LLVM and Clang 19 + # Install LLVM and Clang 20 wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main" + sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main" sudo apt-get update - sudo apt-get install -y llvm-19 llvm-19-dev clang-19 libclang-19-dev - echo "LLVM_DIR=/usr/lib/llvm-19/lib/cmake/llvm" >> $GITHUB_ENV - echo "Clang_DIR=/usr/lib/llvm-19/lib/cmake/clang" >> $GITHUB_ENV + sudo apt-get install -y llvm-20 llvm-20-dev clang-20 libclang-20-dev + echo "LLVM_DIR=/usr/lib/llvm-20/lib/cmake/llvm" >> $GITHUB_ENV + echo "Clang_DIR=/usr/lib/llvm-20/lib/cmake/clang" >> $GITHUB_ENV - name: Install dependencies (macOS) if: runner.os == 'macOS' run: | - brew install cmake llvm@19 - echo "LLVM_DIR=$(brew --prefix llvm@19)/lib/cmake/llvm" >> $GITHUB_ENV - echo "Clang_DIR=$(brew --prefix llvm@19)/lib/cmake/clang" >> $GITHUB_ENV - echo "$(brew --prefix llvm@19)/bin" >> $GITHUB_PATH + brew install cmake llvm@20 + echo "LLVM_DIR=$(brew --prefix llvm@20)/lib/cmake/llvm" >> $GITHUB_ENV + echo "Clang_DIR=$(brew --prefix llvm@20)/lib/cmake/clang" >> $GITHUB_ENV + echo "$(brew --prefix llvm@20)/bin" >> $GITHUB_PATH - name: Configure and Build (Linux/macOS) if: runner.os == 'Linux' || runner.os == 'macOS' @@ -51,6 +51,10 @@ jobs: -DClang_DIR=${{ env.Clang_DIR }} \ -DUSE_SHARED_LIB=OFF \ -DBUILD_TESTS=OFF + + # Patch coretrace-compiler for LLVM 19/20 compatibility + perl -pi -e 's/ci->createDiagnostics\(\*fs, &dc, false\);/ci->createDiagnostics(&dc, false);/g' _deps/cc-src/src/compilerlib/compiler.cpp + cmake --build . --config Release - name: Test compiler (Linux/macOS) From 73dc31030697c5b161d33ddbb5fa522fd27d41fb Mon Sep 17 00:00:00 2001 From: Arthur Mazeau Date: Thu, 27 Nov 2025 16:45:11 +0000 Subject: [PATCH 3/4] [test]: workflow --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af81089..67d5983 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,9 +51,6 @@ jobs: -DClang_DIR=${{ env.Clang_DIR }} \ -DUSE_SHARED_LIB=OFF \ -DBUILD_TESTS=OFF - - # Patch coretrace-compiler for LLVM 19/20 compatibility - perl -pi -e 's/ci->createDiagnostics\(\*fs, &dc, false\);/ci->createDiagnostics(&dc, false);/g' _deps/cc-src/src/compilerlib/compiler.cpp cmake --build . --config Release From 2884a9f0cc8d98bafe3d884d277a8e8553a0f1bc Mon Sep 17 00:00:00 2001 From: Arthur Mazeau Date: Thu, 27 Nov 2025 16:50:00 +0000 Subject: [PATCH 4/4] [test]: workflow --- .github/workflows/ci.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67d5983..b14a870 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,18 +54,18 @@ jobs: cmake --build . --config Release - - name: Test compiler (Linux/macOS) + - name: Test Stack Usage Analyzer (Linux/macOS) if: runner.os == 'Linux' || runner.os == 'macOS' run: | cd build - echo 'int main() { return 0; }' > test.cc - ./cc -S -emit-llvm test.cc - - # Vérifier que le fichier LLVM IR a été généré - if [ -f "test.ll" ]; then - echo "Test réussi: Fichier LLVM IR généré avec succès" - cat test.ll | head -n 10 - else - echo "Test échoué: Fichier LLVM IR non généré" - exit 1 - fi + # Create a test file with some stack usage + cat < test_stack.c + #define SIZE_LARGE 1024 + int main(void) { + char test[SIZE_LARGE]; + return 0; + } + EOF + + # Run the analyzer + ./stack_usage_analyzer --mode=ir test_stack.c \ No newline at end of file