From 796ece26acd8b9255810ca71941ed72626589ee7 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Mon, 19 Jan 2026 15:30:32 -0800 Subject: [PATCH] libsafety: switch to clang 18 and only build mull in standalone mode (#3044) * just switch to 18 * try this * just clang * rm that * try this --- .github/workflows/tests.yml | 2 +- opendbc/safety/tests/libsafety/SConscript | 28 +++++++++++------------ opendbc/safety/tests/mutation.sh | 2 +- opendbc/safety/tests/test.sh | 4 ++-- setup.sh | 14 ++++++------ 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5ebeceed..4328ffd2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -138,7 +138,7 @@ jobs: path: .ci_cache/comma_download_cache key: car_models-${{ hashFiles('selfdrive/car/tests/test_models.py', 'opendbc/car/tests/routes.py') }}-${{ matrix.job }} - name: Build openpilot - run: ${{ env.RUN }} "VIRTUAL_ENV= opendbc_repo/setup.sh && scons -j$(nproc) common/ cereal/ selfdrive/pandad/ msgq_repo/ opendbc_repo" + run: ${{ env.RUN }} "scons -j$(nproc) common/ cereal/ selfdrive/pandad/ msgq_repo/ opendbc_repo" - name: Test car models timeout-minutes: ${{ contains(runner.name, 'nsc') && (steps.routes-cache.outputs.cache-hit == 'true') && ((steps.setup-step.outputs.duration < 18) && 1 || 2) || 6 }} run: | diff --git a/opendbc/safety/tests/libsafety/SConscript b/opendbc/safety/tests/libsafety/SConscript index a8cb50cc..78c2ad65 100644 --- a/opendbc/safety/tests/libsafety/SConscript +++ b/opendbc/safety/tests/libsafety/SConscript @@ -1,16 +1,10 @@ +import os import platform system = platform.system() -# Use clang-17 for both normal tests and mutation testing -# The Mull plugin injects mutations that are dormant unless run with mull-runner -if system == "Darwin": - mull_plugin = Dir('#').abspath + '/.mull/lib/mull-ir-frontend-17' -else: - mull_plugin = '/usr/lib/mull-ir-frontend-17' - env = Environment( - CC='clang-17', + CC='clang', CFLAGS=[ '-Wall', "-Wextra", @@ -23,23 +17,29 @@ env = Environment( '-g', '-O0', '-fno-omit-frame-pointer', - '-fprofile-arcs', - '-ftest-coverage', - f'-fpass-plugin={mull_plugin}', '-grecord-command-line', '-DALLOW_DEBUG', ], LINKFLAGS=[ - '-fprofile-arcs', - '-ftest-coverage', '-fsanitize=undefined', '-fno-sanitize-recover=undefined', ], CPPPATH=["#"], tools=["default", "compilation_db"], ) + +# The Mull plugin injects mutations that are dormant unless run with mull-runner if system == "Darwin": - env.PrependENVPath('PATH', '/opt/homebrew/opt/llvm@17/bin') + mull_plugin = Dir('#').abspath + '/.mull/lib/mull-ir-frontend-18' +else: + mull_plugin = '/usr/lib/mull-ir-frontend-18' +if os.path.exists(mull_plugin): + # Only use mull plugin if it exists + env['CC'] = 'clang-18' + env.Append(CFLAGS=['-fprofile-arcs', '-ftest-coverage', f'-fpass-plugin={mull_plugin}']) + env.Append(LINKFLAGS=['-fprofile-arcs', '-ftest-coverage']) + if system == "Darwin": + env.PrependENVPath('PATH', '/opt/homebrew/opt/llvm@18/bin') safety = env.SharedObject("safety.os", "safety.c") libsafety = env.SharedLibrary("libsafety.so", [safety]) diff --git a/opendbc/safety/tests/mutation.sh b/opendbc/safety/tests/mutation.sh index 411bab35..3a46b005 100755 --- a/opendbc/safety/tests/mutation.sh +++ b/opendbc/safety/tests/mutation.sh @@ -17,4 +17,4 @@ EOF scons -j4 -D -mull-runner-17 --debug --ld-search-path /lib/x86_64-linux-gnu/ ./libsafety/libsafety.so -test-program=pytest -- -n8 --ignore-glob=misra/* \ No newline at end of file +mull-runner-18 --debug --ld-search-path /lib/x86_64-linux-gnu/ ./libsafety/libsafety.so -test-program=pytest -- -n8 --ignore-glob=misra/* \ No newline at end of file diff --git a/opendbc/safety/tests/test.sh b/opendbc/safety/tests/test.sh index e121721b..1ff4ee82 100755 --- a/opendbc/safety/tests/test.sh +++ b/opendbc/safety/tests/test.sh @@ -14,9 +14,9 @@ scons -j$(nproc) -D pytest -n8 --ignore-glob=misra/* if [ "$(uname)" = "Darwin" ]; then - GCOV_EXEC="/opt/homebrew/opt/llvm@17/bin/llvm-cov gcov" + GCOV_EXEC="/opt/homebrew/opt/llvm@18/bin/llvm-cov gcov" else - GCOV_EXEC="llvm-cov-17 gcov" + GCOV_EXEC="llvm-cov-18 gcov" fi # generate and open report diff --git a/setup.sh b/setup.sh index 4aee2d16..8e243493 100755 --- a/setup.sh +++ b/setup.sh @@ -8,18 +8,18 @@ export PYTHONPATH=$BASEDIR # *** dependencies install *** if [ "$(uname -s)" = "Linux" ]; then - if ! command -v "mull-runner-17" > /dev/null 2>&1; then + if ! command -v "mull-runner-18" > /dev/null 2>&1; then curl -1sLf 'https://dl.cloudsmith.io/public/mull-project/mull-stable/setup.deb.sh' | sudo -E bash - sudo apt-get update && sudo apt-get install -y clang-17 mull-17 + sudo apt-get update && sudo apt-get install -y clang-18 mull-18 fi elif [ "$(uname -s)" = "Darwin" ]; then - if ! brew list llvm@17 &>/dev/null; then - brew install llvm@17 + if ! brew list llvm@18 &>/dev/null; then + brew install llvm@18 fi - if [ ! -f "$BASEDIR/.mull/bin/mull-runner-17" ]; then + if [ ! -f "$BASEDIR/.mull/bin/mull-runner-18" ]; then MULL_VERSION="0.26.1" - MULL_ZIP="Mull-17-${MULL_VERSION}-LLVM-17.0-macOS-arm64-14.7.4.zip" - MULL_DIR="Mull-17-${MULL_VERSION}-LLVM-17.0-macOS-arm64-14.7.4" + MULL_ZIP="Mull-18-${MULL_VERSION}-LLVM-18.1-macOS-arm64-14.7.4.zip" + MULL_DIR="Mull-18-${MULL_VERSION}-LLVM-18.1-macOS-arm64-14.7.4" curl -LO "https://github.com/mull-project/mull/releases/download/${MULL_VERSION}/${MULL_ZIP}" unzip -o "$MULL_ZIP" mv "$MULL_DIR" "$BASEDIR/.mull"