-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
*: bazel-ify cockroachdb #55687
*: bazel-ify cockroachdb #55687
Conversation
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.
Very exciting!
What is the expectation for how engineers will use bazel
? Will we change the various make
targets to using bazel
rather than go
? Or will engineers run bazel
directly?
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @jlinder, @jordanlewis, and @otan)
One thing I didn't mention above is that the current plan here is to have these two separate build systems sitting side-by-side in our codebase for a while. With this PR we think we've done 90% of the work, we only have the remaining 90% left. We'll only know what that is once folks start trying it out in earnest (i.e. after merge), and falling back to
In my view I think we should all want to use bazel directly. I don't think it's too bad, and we can write usable shorthands for the most common things. I also think that Bazel is a bit more teachable to engineers here than our Makefile is/was, so the more exposure everyone has the better. |
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.
In my view I think we should all want to use bazel directly. I don't think it's too bad, and we can write usable shorthands for the most common things. I also think that Bazel is a bit more teachable to engineers here than our Makefile is/was, so the more exposure everyone has the better.
I agree on using bazel
directly. We can also add command aliases for common actions.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @jlinder, @jordanlewis, and @otan)
can we break this up, so we can start committing stuff? happy to take over doing that if you so wish. ideas:
should stop the rebase hell, and be isolated by themselves? |
I did try this above: c-dep changes + picking up go-libedit + everything else (it's all supposed to get reviewed anyway, so yolo, and not like we're expecting to check out individual SHAs in between in the future). I was ok with committing this as is, but I'm also happy to have you take over from here and change it to your liking. |
If you're worried about rebasing, it's not an issue. Rebasing + |
Since this is creating a parallel build system and not affecting the make-based build system, I'm ok with merging this PR as-is. It won't disrupt anyone's work, and if we find some fatal flaw we can always revert it. |
heh, ok. are we waiting for rocksdb to go away? |
🤷 That is in progress as well. I'd expect it to land sometime next week. |
i think this PR can't merge unless we fix rocksdb or wait for it to be deleted. |
bfa518c
to
55fb73a
Compare
bors r- |
Canceled. |
This was being batched with PRs that added new files. Hm. I'll have to bors it during quiet hours after quickly rebasing off latest, and making sure it's a single PR batch. |
337592c
to
706ab1e
Compare
We'll need these changes in future commits. jemalloc: fix JEMALLOC_MUTEX_INIT_CB to only be set if OSS_PINLOCK is false Release note: None
Specifically pick up Oliver's changes in otan-cockroach/go-libedit@gazelle_it_2: go mod edit -replace=github.com/knz/go-libedit=github.com/otan-cockroach/go-libedit@gazelle_it_2 make vendor_rebuild Release note: None
The changes to the _tmpl.go files are needed for bazel to compile auto-generated code in its sandbox. We currently rely on goimports to fill in the dependencies in the eg.go files, as needed, but that does not do the right thing in bazel. This diff may ultimately turn out to be unnecessary, but was quicker to do it this way than to figure out why goimports in the bazel sandbox doesn't fill in dependencies appropriately. Hopefully the diff is uncontroversial. Release note: None
We need this diff to get bazel to compile auto-generated sql.go in its sandbox. We currently rely on goimports to fill in the dependency as needed, but bazel is unable to resolve it as expected. This is in the same spirit as the last commit, this diff may ultimately turn out to be unnecessary, but was quicker to do it this way than to figure out why goimports in the bazel sandbox doesn't fill in dependencies appropriately. Release note: None
This commit introduces a new build system to cockroachdb: Bazel. The hope here is to eventually replace our current Makefile. It sets the foundation for introducing Bazel in our CI systems for parallelized builds/test runs, artifact caching, remote builds, and many other such profits (literally, it could reduce infra spend). We originally prototyped a pseudo bazel-ified cockroachdb in cockroachdb#52824, which resulted in a week long effort (with otan@, jamesl@, and myself) to wrap it up in earnest in cockroachdb#55258. This is the polished version of the resulting work, the write up for which can be found at go.crdb.dev/bazel-hackweek. --- Most of the BUILD files here were auto-generated through Gazelle (see doc). Some of these auto-generated files required further manual tweaking to get just right (see doc). These were mostly around the packages that link into c-dependencies, but also the few packages that rely on auto-generated code (again, see doc). These specific files are the ones intended for review (they're also the ones responsible for auto-generation), among a few others. I've listed them out here: ``` modified: .gitattributes modified: Makefile new file: BUILD.bazel new file: DEPS.bzl new file: WORKSPACE new file: pkg/ccl/gssapiccl/BUILD.bazel new file: pkg/cli/BUILD.bazel new file: pkg/cmd/cockroach-oss/BUILD.bazel new file: pkg/cmd/cockroach-short/BUILD.bazel new file: pkg/cmd/cockroach/BUILD.bazel new file: pkg/col/coldata/BUILD.bazel new file: pkg/geo/geoproj/BUILD.bazel new file: pkg/geo/geos/BUILD.bazel new file: pkg/sql/colconv/BUILD.bazel new file: pkg/sql/colexec/BUILD.bazel new file: pkg/sql/colexec/COLEXEC.bzl new file: pkg/sql/colexec/colbuilder/BUILD.bazel new file: pkg/sql/colexec/colexec.go new file: pkg/sql/colexec/colexecagg/BUILD.bazel new file: pkg/sql/colflow/BUILD.bazel new file: pkg/sql/opt/BUILD.bazel new file: pkg/sql/opt/exec/BUILD.bazel new file: pkg/sql/opt/exec/execbuilder/BUILD.bazel new file: pkg/sql/opt/exec/explain/BUILD.bazel new file: pkg/sql/opt/memo/BUILD.bazel new file: pkg/sql/opt/norm/BUILD.bazel new file: pkg/sql/opt/optgen/lang/BUILD.bazel new file: pkg/sql/opt/xform/BUILD.bazel new file: pkg/sql/parser/BUILD.bazel new file: pkg/sql/parser/sql-gen.sh new file: pkg/storage/BUILD.bazel modified: vendor ``` The changes to all the _tmpl.go files were needed to include necessary import analysis/compilation for bazel when generating the .eg.go files (also summarized in doc up above), and should be uncontroversial. I think it's easiest to pull the branch down locally and to click around to see what works, and what doesn't. I would start at the top-level BUILD.bazel and WORSPACE file. I've added comments to explain what most of added machinery does. Release note: None
706ab1e
to
1cd90b0
Compare
bors single on |
bors r+ p=9999 |
Build succeeded: |
It's an auto-generated file that bazel doesn't yet know how to construct within the sandbox. Before this PR `make bazel-generate` would show spurious diffs on a clean checkout without this file present. Now it no longer will. Unfortunately it also means that successful bazel builds require `reserved_keywords.go` being pre-generated ahead of time (it's not checked-in into the repo). Once Bazel is taught to generate this file however, this will no longer be the case. It was just something that I missed in cockroachdb#55687. Release note: None
55560: backupccl: avoid div-by-zero crash on failed node count r=dt a=dt We've seen a report of a node that crashed due to a divide-by-zero hit during metrics collection, specifically when computing the throughput-per-node by dividing the backup size by node count. Since this is only now used for that metric, make a failure to count nodes a warning only for release builds (and fallback to 1), and make any error while counting, or not counting to more than 0, a returned error in non-release builds. Release note (bug fix): avoid crashing when BACKUP is unable to count the total nodes in the cluster. 55809: roachtest: fix decommission/randomize r=irfansharif a=tbg The test could end up using fully decommissioned nodes for cli commands, which does not work as of #55286. Fixes #55581. Release note: None 56019: lexbase: pin `reserved_keywords.go` within Bazel r=irfansharif a=irfansharif It's an auto-generated file that bazel doesn't yet know how to construct within the sandbox. Before this PR `make bazel-generate` would show spurious diffs on a clean checkout without this file present. Now it no longer will. Unfortunately it also means that successful bazel builds require `reserved_keywords.go` being pre-generated ahead of time (it's not checked-in into the repo). Once Bazel is taught to generate this file however, this will no longer be the case. It was just something that I missed in #55687. Release note: None Co-authored-by: David Taylor <[email protected]> Co-authored-by: Tobias Grieger <[email protected]> Co-authored-by: irfan sharif <[email protected]>
# | ||
# $(error $(yellow)'bazel' not found (`brew install bazel` for macs)$(term-reset)) | ||
ifeq (, $(shell which bazel)) | ||
$(info $(yellow)Warning: 'bazel' not found (`brew install bazel` for macs)$(term-reset)) |
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.
Just passing by! Consider recommending the usage of github.com/bazelbuild/bazelisk and a .bazelversion
file to ensure your contributors are using the same version.
Great to see CockroachDB using Bazel!
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.
Our Makefile UX has grown organically over the last six years, and is now home to various scripts that are orthogonal to simply building the crdb binary. These include the ability to run linters, building various useful binaries (such as roachprod, roachtest), running different kinds of tests (unit tests, logic tests, acceptance tests), and much more. Now that we're exploring a move towards Bazel for our build system (cockroachdb#55687), we have a chance to tuck away Bazel specific under a general purpose dev-tool. The intent here is to house all day-to-day dev operations under this tool, written in Go. This will be the component that actually replaces our Makefile in its entirety. It'll be (predictably) powered by bazel underneath, but with much nicer UX. It should capturing all common usage patterns in high-level docs. This diff only introduces the scaffolding for this CLI. Release note: None
Our Makefile UX has grown organically over the last six years, and is now home to various scripts that are orthogonal to simply building the crdb binary. These include the ability to run linters, building various useful binaries (such as roachprod, roachtest), running different kinds of tests (unit tests, logic tests, acceptance tests), and much more. Now that we're exploring a move towards Bazel for our build system (cockroachdb#55687), we have a chance to tuck away Bazel specific under a general purpose dev-tool. The intent here is to house all day-to-day dev operations under this tool, written in Go. This will be the component that actually replaces our Makefile in its entirety. It'll be (predictably) powered by bazel underneath, but with much nicer UX. It should capturing all common usage patterns in high-level docs. This diff only introduces the scaffolding for this CLI. Release note: None
56965: dev: introduce a general purpose dev-tool for crdb engineers r=irfansharif a=irfansharif Our Makefile UX has grown organically over the last six years, and is now home to various scripts that are orthogonal to simply building the crdb binary. These include the ability to run linters, building various useful binaries (such as roachprod, roachtest), running different kinds of tests (unit tests, logic tests, acceptance tests), and much more. Now that we're exploring a move towards Bazel for our build system (#55687), we have a chance to tuck away Bazel specific under a general purpose dev-tool, larva. The intent here is to house all day-to-day dev operations under this tool, written in Go. This will be the component that actually replaces our Makefile in its entirety. It'll be (predictably) powered by bazel underneath, but with much nicer UX. It should capturing all common usage patterns in high-level docs. Strawman UX (I've only really deliberated on the `test` subcommand): ``` larva test --pkg=kv/kvserver --filter=TestReplicaGC* -v -show-logs --timeout=1m larva test --stress --race ... larva test --logic --files=prepare|fk --subtests=20042 --config=local larva test --fuzz --pkg=... --filter=Decimal` larva bench --pkg=sql/parser --filter=BenchmarkParse larva build cockroach --tags=deadlock larva build cockroach-oss larva build {opt,exec}gen larva generate bazel larva generate protobuf larva generate {opt,exec}gen larva lint --filter=TestLowercaseFunctionNames --short --timeout=1m ``` --- Aside: The naming here is cause of this tool's infancy, relation to cockroaches, and it starting with the letter "l" (which is featured prominently in "bazel"/"blaze"). Whatever. Release note: None Co-authored-by: irfan sharif <[email protected]>
This commit introduces a new build system to cockroachdb: Bazel.
The hope here is to eventually replace our current Makefile. It sets the
foundation for introducing Bazel in our CI systems for parallelized
builds/test runs, artifact caching, remote builds, and many other such
profits (literally, it could reduce infra spend).
We originally prototyped a pseudo bazel-ified cockroachdb in #52824,
which resulted in a week long effort (with otan@, jamesl@, and myself) to
wrap it up in earnest in #55258. This is the polished version of the
resulting work, the write up for which can be found at
http://go.crdb.dev/bazel-hackweek.
Most of the BUILD files here were auto-generated through Gazelle (see
doc). Some of these auto-generated files required further manual
tweaking to get just right (see doc). These were mostly around the packages that
link into c-dependencies, but also the few packages that rely on
auto-generated code (again, see doc). These specific files are the ones
intended for review (they're also the ones responsible for
auto-generation), among a few others. I've listed them out here:
The changes to all the _tmpl.go files were needed to include necessary
import analysis/compilation for bazel when generating the .eg.go files
(also summarized in doc up above), and should be uncontroversial.
I think it's easiest to pull the branch down locally and to click around
to see what works, and what doesn't. I would start at the top-level
BUILD.bazel and WORSPACE file. I've added comments to explain what most
of added machinery does.
Release note: None