-
Notifications
You must be signed in to change notification settings - Fork 64
kernel: distribute darwin/arm64 lib as nested per-platform module (go get, no build step) #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
msrathore-db
wants to merge
4
commits into
main
Choose a base branch
from
kernel-nested-modules
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a9c3e8a
kernel: distribute darwin/arm64 lib as nested per-platform module
msrathore-db a11b8e2
ci: sync committed kernel C-ABI libs from kernel release
msrathore-db d743db3
ci: drop pull-model sync workflow in favor of kernel push
msrathore-db 5957419
kernel: version nested modules for consumer go get (real versions + r…
msrathore-db 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
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,114 @@ | ||
| # Releasing the driver (with the kernel/SEA backend) | ||
|
|
||
| This repo ships the kernel/SEA backend as **committed, per-platform, prebuilt | ||
| static archives** carried by `go get` — no `make kernel-lib` step for consumers, | ||
| no Rust toolchain. This document explains how those archives are versioned and | ||
| published so that a `go get github.com/databricks/databricks-sql-go@vX.Y.Z` | ||
| resolves the matching kernel archive automatically. | ||
|
|
||
| ## The module layout | ||
|
|
||
| The driver is a multi-module repository: | ||
|
|
||
| ``` | ||
| github.com/databricks/databricks-sql-go (the driver module) | ||
| └── internal/backend/kernel/kernellib/<platform>/ (one NESTED module per platform) | ||
| ├── go.mod → github.com/databricks/databricks-sql-go/internal/backend/kernel/kernellib/<platform> | ||
| ├── link.go → //go:build cgo && databricks_kernel && <os> && <arch> (+ #cgo LDFLAGS) | ||
| └── libdatabricks_sql_kernel.a (the committed prebuilt archive for this platform) | ||
| ``` | ||
|
|
||
| Each `kernellib/<platform>` directory is **its own Go module** (it has a | ||
| `go.mod`). This is deliberate: Go downloads a module's zip only when a build | ||
| compiles a file from it, and each `link.go` is build-tag-gated to one platform + | ||
| `databricks_kernel`. So: | ||
|
|
||
| - a **Thrift build** (`CGO_ENABLED=0`, no tag) downloads **none** of them; | ||
| - a **kernel build** for, say, darwin/arm64 downloads **only** the | ||
| `darwin_arm64` module — never the other platforms' archives. | ||
|
|
||
| ## How versioning works | ||
|
|
||
| The driver's `go.mod` `require`s each platform module at a **real version**, and | ||
| also carries a `replace` pointing at the in-tree source: | ||
|
|
||
| ``` | ||
| require github.com/databricks/databricks-sql-go/internal/backend/kernel/kernellib/darwin_arm64 v1.2.3 | ||
|
|
||
| replace github.com/databricks/databricks-sql-go/internal/backend/kernel/kernellib/darwin_arm64 => ./internal/backend/kernel/kernellib/darwin_arm64 | ||
| ``` | ||
|
|
||
| - The **`require` version pins the kernel**. `go get .../databricks-sql-go@v1.2.3` | ||
| reads that tag's `go.mod`, sees `require .../darwin_arm64 v1.2.3`, and resolves | ||
| that exact archive version from the module proxy. **Upgrading the driver is what | ||
| moves the kernel version** — deterministic, per-driver-version pinning. | ||
| - The **`replace` is local-only and consumer-invisible.** Per the | ||
| [Go module spec](https://go.dev/ref/mod#go-mod-file-replace), a `replace` in a | ||
| *dependency's* `go.mod` is ignored — it applies only when this repo is the main | ||
| module. So it lets THIS repo build against the committed archive during | ||
| development, while a downstream `go get` always resolves the published version | ||
| from the proxy. (Verified: a consumer building against a published module sees | ||
| the proxy copy, not the replace target.) | ||
|
|
||
| ## Publishing: path-prefixed tags | ||
|
|
||
| Go publishes a nested module using a **tag whose name is the module's | ||
| subdirectory path plus the version**. To release the darwin/arm64 kernel module | ||
| at `v1.2.3`: | ||
|
|
||
| ``` | ||
| git tag internal/backend/kernel/kernellib/darwin_arm64/v1.2.3 | ||
| git tag internal/backend/kernel/kernellib/linux_amd64/v1.2.3 | ||
| # ... one tag per platform module ... | ||
| git tag v1.2.3 # the driver module itself | ||
| git push origin --tags | ||
| ``` | ||
|
|
||
| The module proxy serves each nested module's zip **excluding** any nested-module | ||
| subtree, and serves it at the version from its path-prefixed tag. The driver | ||
| module's own zip (tag `v1.2.3`) excludes the `kernellib/*` subtrees — consumers | ||
| pull those separately at the versions the driver `require`s. | ||
|
|
||
| ## Release steps | ||
|
|
||
| 1. **Build the archives.** The kernel repo's `build-c-abi-libs` workflow builds | ||
| `libdatabricks_sql_kernel.a` per platform on native runners and pushes them | ||
| into the `kernellib/<platform>/` directories here (see that repo's workflow; | ||
| it opens a sync PR against this repo). Alternatively, drop a locally built | ||
| archive in for a single platform during development. | ||
| 2. **Bump the `require` versions** in the driver `go.mod` to the new release | ||
| version (keep the matching `replace` lines). | ||
| 3. **Tag every module** at the new version using the path-prefixed tags above, | ||
| plus the plain `vX.Y.Z` for the driver. | ||
| 4. **Push tags.** The proxy indexes each module at its tag; `go get @vX.Y.Z` | ||
| now resolves the driver and, transitively, the matching per-platform kernel | ||
| archive. | ||
| 5. **Refresh `go.sum`.** While developing, the `replace` points at the in-tree | ||
| source so no `go.sum` hash is needed for the nested modules. Once they are | ||
| published and the driver `require`s the real versions *without* relying on the | ||
| replace for resolution (i.e. for the tagged release consumers fetch), run | ||
| `GOFLAGS=-mod=mod GOWORK=off go mod tidy` against the published versions so the | ||
| nested-module checksums land in `go.sum`. Consumers verify against these. | ||
| (The committed `replace` still shadows the download in THIS repo's own builds; | ||
| the `go.sum` entries are what a downstream `go get` verifies.) | ||
|
|
||
| ## Adding a new platform | ||
|
|
||
| 1. Create `internal/backend/kernel/kernellib/<platform>/` with its own `go.mod`, | ||
| a build-tag-gated `link.go` (matching `//go:build` + `#cgo LDFLAGS`), and the | ||
| committed archive. | ||
| 2. Add a `require` + `replace` pair for it in the driver `go.mod`. | ||
| 3. Add a build-tagged shim (`cgo_<os>_<arch>.go`) in the `kernel` package that | ||
| blank-imports the new module (so its `#cgo LDFLAGS` are collected at link). | ||
| 4. Tag it alongside the others at release. | ||
|
|
||
| ## Consumer experience (for reference) | ||
|
|
||
| - **Thrift (default):** `go get ...` + `go build` — pure Go, no cgo, no archive | ||
| downloaded. | ||
| - **Kernel/SEA:** `go get ...` + `CGO_ENABLED=1 go build -tags databricks_kernel` | ||
| — pulls only the target platform's archive at the driver-pinned version; no | ||
| `make kernel-lib`, no Rust. | ||
| - **Cloning this repo directly** (contributors/CI): use | ||
| `git clone --filter=blob:none` to skip the committed-archive history. See the | ||
| README "Cloning the repository" section. |
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
Oops, something went wrong.
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.
🔵 Low — The
requirepins the nested module atv0.0.1, but the adjacent comment (and docs/RELEASING.md) assert these versions are "REAL published versions ... bumped in lockstep with each driver release," so thatgo get databricks-sql-go@vX.Y.Ztransitively pins the matching kernel archive and "upgrading the driver is what moves the kernel version."Right now
v0.0.1is a placeholder that only builds because the localreplaceshadows it in this repo. That's fine for this development-phase PR, but the code contradicts the documented model, and it is load-bearing at release time: if a driver release tag ships thisgo.modverbatim, a downstream-tags databricks_kernelbuild on darwin/arm64 will (a) require a publishedinternal/backend/kernel/kernellib/darwin_arm64/v0.0.1tag to exist on the proxy, and (b) freeze the kernel atv0.0.1regardless of driver version — defeating the lockstep pinning the comment promises. Worth aTODO/note that this must be bumped and tagged (RELEASING.md steps 2–3) before it goes out in a tagged release, so the placeholder isn't shipped by accident.