mirror of
https://github.com/infiniteCable2/opendbc.git
synced 2026-02-18 04:54:06 +08:00
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
This commit is contained in:
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@@ -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: |
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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/*
|
||||
mull-runner-18 --debug --ld-search-path /lib/x86_64-linux-gnu/ ./libsafety/libsafety.so -test-program=pytest -- -n8 --ignore-glob=misra/*
|
||||
@@ -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
|
||||
|
||||
14
setup.sh
14
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"
|
||||
|
||||
Reference in New Issue
Block a user