This repository was archived by the owner on Aug 5, 2026. It is now read-only.
forked from wlav/cppyy-backend
-
Notifications
You must be signed in to change notification settings - Fork 13
Add an experimental Bazel build #212
Merged
aaronj0
merged 3 commits into
compiler-research:master
from
conrade-ctc:bazel-build-upstream
Jul 3, 2026
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| common --enable_bzlmod | ||
| test --test_output=errors | ||
|
|
||
| # The C++ toolchain (clang from the LLVM tree) and all ABI-critical flags are | ||
| # centralized in the cppyy_bazel module, which registers @llvm//:cc_toolchain. | ||
| # No per-repo compiler wiring needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 8.3.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Best-effort, NON-GATING Bazel build. CMake is the supported build for | ||
| # cppyy-backend; this job is informational only and must never gate CI | ||
| # (continue-on-error). The build step runs for real and surfaces a regression as | ||
| # a warning, not a false green. | ||
| # | ||
| # TEMPORARY fork coupling: the Bazel infra (cppyy/bazel/ = the cppyy_bazel | ||
| # module, plus the MODULE.bazel files) currently lives ONLY on the conrade-ctc | ||
| # forks @ bazel-build-upstream, not on the compiler-research default branches. | ||
| # Until it merges upstream, the sibling repos are cloned from the fork | ||
| # (FORK_OWNER / FORK_BRANCH below). After the merge, repoint those two variables. | ||
| name: bazel | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| bazel-build: | ||
| name: bazel (best-effort) llvm${{ matrix.llvm }} | ||
| runs-on: ubuntu-24.04 | ||
| continue-on-error: true | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| llvm: ["22"] | ||
| steps: | ||
| # No `path:` -> cppyy-backend is $GITHUB_WORKSPACE; siblings are cloned | ||
| # alongside it so the local_path_overrides (../cppyy/bazel, ../CppInterOp) | ||
| # resolve. | ||
| - name: Checkout cppyy-backend | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Clone sibling repos (fork carries the Bazel infra) | ||
| run: | | ||
| set -eux | ||
| FORK_OWNER="conrade-ctc" # TODO: compiler-research after infra merges | ||
| FORK_BRANCH="bazel-build-upstream" # TODO: default branch after infra merges | ||
| cd "$GITHUB_WORKSPACE/.." | ||
| for repo in cppyy CppInterOp; do | ||
| git clone --depth=1 -b "$FORK_BRANCH" \ | ||
| "https://github.com/${FORK_OWNER}/${repo}.git" | ||
| done | ||
|
|
||
| - name: Setup LLVM ${{ matrix.llvm }} | ||
| uses: compiler-research/ci-workflows/actions/setup-llvm@main | ||
| with: | ||
| version: ${{ matrix.llvm }} | ||
| os: ubuntu-24.04 | ||
|
|
||
| - name: Point LLVM_DIR at the tree root for the @llvm Bazel extension | ||
| run: | | ||
| # setup-llvm sets LLVM_DIR=<prefix>/lib/cmake/llvm (CMake convention); | ||
| # the @llvm Bazel extension needs the tree root holding bin/llvm-config. | ||
| echo "LLVM_DIR=${GITHUB_WORKSPACE}/install" >> "$GITHUB_ENV" | ||
|
|
||
| - name: bazel build //:solib //:pylib | ||
| run: | | ||
| bazelisk build //:solib //:pylib \ | ||
| || echo "::warning::bazel build failed (best-effort, non-gating)" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| load("@cppyy_bazel//:defs.bzl", "BASE_COPTS", "repo_loc", "repo_rloc") | ||
| load("@rules_python//python:packaging.bzl", "py_wheel") | ||
|
|
||
| # cppyy-backend is a sanitizer boundary: libcppyy-backend.so is dlopen'd by a | ||
| # (possibly non-instrumented) host interpreter and works directly with the | ||
| # non-sanitized LLVM/clang runtime, so an asan/ubsan-instrumented build would die | ||
| # on undefined __asan_* symbols at load. Opt the package out; harmless when the | ||
| # consumer build isn't sanitized. | ||
| package( | ||
| default_visibility = ["//visibility:public"], | ||
| features = [ | ||
| "-asan", | ||
| "-ubsan", | ||
| ], | ||
| ) | ||
|
|
||
| # CppInterOp headers (incl. the generated CppInterOpAPI.inc) live in the | ||
| # @cppinterop tree, not an install prefix. Build-time includes resolve against | ||
| # the external path; the runtime CPPINTEROP_DIR/{lib,include} the source dlopen's | ||
| # resolve against the runfiles path. | ||
| _CPPINTEROP_RLOC = repo_rloc("@cppinterop") | ||
|
|
||
| cc_library( | ||
| name = "lib", | ||
| srcs = glob(["clingwrapper/src/*.cxx"]), | ||
| hdrs = glob(["clingwrapper/src/*.h"]) + ["@cppinterop//:headers"], | ||
| copts = BASE_COPTS + [ | ||
| # BASE_COPTS sets -fno-exceptions/-fno-rtti; clingwrapper needs both | ||
| # (throw std::runtime_error, typeid for AutoCastRTTI). | ||
| "-fexceptions", | ||
| "-frtti", | ||
| # CppInterOp headers are <CppInterOp/...>; include root is the source | ||
| # tree plus the genfiles tree where the tblgen'd .inc headers land. | ||
| "-I" + repo_loc("@cppinterop") + "/include", | ||
| "-I$(GENDIR)/" + repo_loc("@cppinterop") + "/include", | ||
| # CMAKE: CPPINTEROP_DIR drives the runtime dlopen path | ||
| # CPPINTEROP_DIR "/lib/libclangCppInterOp" CMAKE_SHARED_LIBRARY_SUFFIX. | ||
| "-DCPPINTEROP_DIR='\"" + _CPPINTEROP_RLOC + "\"'", | ||
| # CMAKE: CMAKE_SHARED_LIBRARY_SUFFIX, .so on Linux. | ||
| "-DCMAKE_SHARED_LIBRARY_SUFFIX='\".so\"'", | ||
| # clingwrapper has an unused var and a non-canonical dtor name; demote | ||
| # so a consumer toolchain with -Werror (e.g. nebula) doesn't fail. | ||
| "-Wno-error=unused-variable", | ||
| "-Wno-unused-variable", | ||
| "-Wno-error=dtor-name", | ||
| "-Wno-dtor-name", | ||
| "-Wno-error=unused-parameter", | ||
| "-Wno-unused-parameter", | ||
| ], | ||
| data = ["@cppinterop//:headers"], | ||
| # CMAKE: target_include_directories PRIVATE clingwrapper/src. | ||
| includes = ["clingwrapper/src"], | ||
| ) | ||
|
|
||
| cc_shared_library( | ||
| name = "solib", | ||
| additional_linker_inputs = ["@llvm//:lib_files"], | ||
| dynamic_deps = ["@cppinterop//:solib"], | ||
| shared_lib_name = "python/cppyy_backend/lib/libcppyy-backend.so", | ||
| deps = [":lib"], | ||
| ) | ||
|
|
||
| py_library( | ||
| name = "pylib", | ||
| srcs = glob(["python/cppyy_backend/**/*.py"]), | ||
| # Carry the runtime libs so anything depending on the python package (e.g. | ||
| # cppyy -> @cppyy//:lib) gets libcppyy-backend.so + libclangCppInterOp.so in | ||
| # its runfiles, not just the headers. | ||
| data = [ | ||
| ":solib", | ||
| "@cppinterop//:headers", | ||
| "@cppinterop//:solib", | ||
| ], | ||
| imports = ["python"], | ||
| ) | ||
|
|
||
| # strip_path_prefixes drops the python/ source root and the solib's python/ | ||
| # wrapper so both land under cppyy_backend/ (the .so at cppyy_backend/lib/), | ||
| # matching where setup.py ships them. | ||
| py_wheel( | ||
| name = "cppyy_backend_wheel", | ||
| distribution = "cppyy-backend", | ||
| python_tag = "py3", | ||
| strip_path_prefixes = ["python"], | ||
| version = "0.1.0.dev0", | ||
| deps = [ | ||
| ":pylib", | ||
| ":solib", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| module( | ||
| name = "cppyy_backend", | ||
| version = "0.1.0", | ||
| ) | ||
|
|
||
| bazel_dep(name = "cppyy_bazel", version = "0.1.0") | ||
| local_path_override( | ||
| module_name = "cppyy_bazel", | ||
| path = "../cppyy/bazel", | ||
| ) | ||
|
|
||
| bazel_dep(name = "cppinterop", version = "0.1.0") | ||
| local_path_override( | ||
| module_name = "cppinterop", | ||
| path = "../CppInterOp", | ||
| ) | ||
|
|
||
| bazel_dep(name = "rules_python", version = "1.5.1") | ||
|
|
||
| llvm = use_extension("@cppyy_bazel//:llvm.bzl", "llvm") | ||
| use_repo(llvm, llvm = "cppjit_llvm") | ||
|
|
||
| # Opt in to the centralized clang toolchain from cppyy_bazel (standalone build). | ||
| register_toolchains("@llvm//:cc_toolchain") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the CppInterOp PR is in, can we update this to no longer clone the fork?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, I'll update all PRs... whatever order they end up merging in, i'll just keep updating appropriately, then a final clean up PR may be needed depending on the order they merged :) I think if we do cppy first, that cleans with this one all the way, but CppInterOp will need another cleanup...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is your preferred order of merging? I see we still point to the forks on the CppInterOp patch, so I'm not sure what the easiest way to test this is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, best is that i update all the PRs to ref head since its best-effort, and we already know it works. I'll open another for CppInterOp to get it back to head, then you can merge in any order. I'll hit this later today when i'm back at desk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is now done