Skip to content

Replace scons with direct clang++ build#680

Open
mpurnell1 wants to merge 2 commits intocommaai:masterfrom
mpurnell1:noscons
Open

Replace scons with direct clang++ build#680
mpurnell1 wants to merge 2 commits intocommaai:masterfrom
mpurnell1:noscons

Conversation

@mpurnell1
Copy link

@mpurnell1 mpurnell1 commented Mar 13, 2026

Summary

  • Remove scons dependency and replace with build.py that compiles C++/Cython extensions using direct clang++/cythonize subprocess calls
  • Supports parallel compilation via subprocess.Popen and incremental builds via -MMD dependency tracking
  • Build triggers lazily on first import msgq / import msgq.visionipc (no-op if already built)

Build performance

Clean build No-op rebuild
scons -j8 34.5s ~1s
build.py 38.6s 0.18s

Clean builds are comparable (~4s gap is the two sequential Cython compile+link steps). No-op rebuilds are faster since it's just stat checks vs scons' dependency database.

What changed

  • Deleted: SConstruct, SConscript, site_scons/ (custom Cython SCons tool)
  • Added: build.py — standalone build module with build_msgq(), build_visionipc(), build_test_runners()
  • Modified: msgq/__init__.py, msgq/visionipc/__init__.py — call build functions before importing Cython extensions
  • Modified: test.shscons -j8python build.py
  • Modified: pyproject.toml — removed scons dependency and site_scons exclusion
  • Modified: .gitignore — swapped .sconsign.dblite for *.d (clang dependency files)

Follows the same pattern as commaai/opendbc#3194

Test plan

  • ./test.sh passes (build + lefthook lint + pytest + C++ test runners)
  • Incremental builds work (mtime + .d depfile checking)
  • Clean builds produce identical artifacts
  • CI passes on Linux and macOS

Remove scons dependency and replace with build.py that compiles
C++/Cython extensions using direct clang++ calls via subprocess.
Supports parallel compilation and incremental builds via -MMD
dependency tracking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mpurnell1 mpurnell1 marked this pull request as ready for review March 13, 2026 04:41
Allows callers (e.g. openpilot's scons) to pass additional compiler
flags like -DSWAGLOG for swaglog integration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant