-
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
[dnm,wip] *: bazel-ify attempt #52824
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.
@irfansharif I looked. I salute your bravery.
Reviewable status: complete! 0 of 0 LGTMs obtained
f7cfa0b
to
5be1da3
Compare
Not checking in the gazelle generated files just yet (just so the diffs here are understandable). I haven't quite figured out the right incantation to get bazel+gazelle to simply pick up what's present under vendor without generating BAZEL.build files for everything under vendor/. So far I got the simplest thing running. # clears out all the gazelle-generated BUILD files
make bazel-reset
# generates BUILD files, in one of two methods:
# - raw `gazelle`, or
# - through `bazelle` controlling gazelle behavior through directives
make {bazel,gazelle}-generate
# build and run pkg/cmd/uptodate
bazel run //pkg/cmd/uptodate:uptodate |
exciting to see you taking a swing at this @irfansharif ! |
905b681
to
f1711c1
Compare
Ok got the vendor thing figured out. Gonna check out for a bit, but trying to get the following running next (building roachtest/roachprod through bazel):
Which runs into:
|
Don't look, seeing what sticks. *: git ignore bazel symlinks + check in go.mod changes *: trying different flags for gazelle *: call gazelle directly (not all directives are implemented) *: get `bazel run //pkg/cmd/uptodate:uptodate` working *: let bazel pollute vendor *: let bazel pollute c-deps bazel run @cockroach//pkg/sql/opt/optgen/cmd/optgen:optgen bazel test @cockroach//pkg/kv/kvserver/tscache/... (I'm not checking in the generated bazel build files just yet.) Release note: None
Release note (<category, see below>): <what> <show> <why>
f1711c1
to
54cbb81
Compare
With some more gross hacks in I'm now about build cockroach (and everything else under bin) through bazel: # nuke everything
$ make maintainer-clean
# generate all the c-deps, and generated code (could also use `make c-deps;
# make generate` which are sufficient for `buildshort`).
$ make build
# need this to generate BUILD files for ui (there are better ways to do it -
# this is also how we generated all the BUILD files in the first place so it's
# nice and hermetic)
$ make bazel-generate
# basically `make buildshort`
$ bazel build @cockroach//pkg/cmd/cockroach-short
# basically `make build`
$ bazel build @cockroach//pkg/cmd/cockroach
# could also do this right away
$ bazel run @cockroach//pkg/cmd/cockroach -- start-single-node --insecure
INFO: Analyzed target //pkg/cmd/cockroach:cockroach (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //pkg/cmd/cockroach:cockroach up-to-date:
bazel-bin/pkg/cmd/cockroach/cockroach_/cockroach
INFO: Elapsed time: 0.144s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
*
* WARNING: RUNNING IN INSECURE MODE!
*
* - Your cluster is open for any client that can access <all your IP addresses>.
* - Any user, even root, can log in without providing a password.
* - Any user, connecting as root, can read or write any data in your cluster.
* - There is no network encryption nor authentication, and thus no confidentiality.
# ... (That was a bit of a lie, I'm not building the C++ deps or generating code, but they're doable). So what's "remaining" is getting all the c-dependency knowledge captured within bazel, and set up those custom build rules. Right now it just expects the find the artifacts to be present and will fail to link them if not. We'd also want to get the equivalent of There's some funkiness going on with how CGO flags get interpreted into the generated BUILD files. I had to hack in the right include paths, and but they should be relative to repo root which didn't seem to work. Right now they're pointing paths on my macbook, so there are just a few lines you'd have to adjust to get it working on yours. They are in:
Also our artifacts today get placed under $GOPATH/native/, which because it exists outside our repo root, might not play super well with Bazel's idea of a workspace (but I could be wrong). I think it wants everything to be addressable under the workspace/repo root. One other thing that I'm not so sure about is how bazel/gazelle should treat the vendor directory. Right now I've let it bazel-ify everything, and I think it wants to, but I'm not sure. I took precedence from https://github.com/paulbellamy/golanguk2017 and few other links online but this seems like a wart. I'm sure there's a better way. I think getting bazel to start working with the most common build paths our engineers use may not be as far away as we think. As a bonus, you can also run go tests through bazel now. Here's one of our more involved packages that makes use of
|
So, next steps here:
Given we're proposing having a dedicated hack-week to get all this out the
At all times we should be generating artifacts that are byte-by-byte identical @jordanlewis, @otan, @petermattis: thoughts? |
This seems messy given Makefile dependencies will probably have a bad time if you switch between them both. I'd rather the concept of |
That works for me, I guess the real motivation was to have eager folks try just one build system at a time and report badness as they come up. I'd be happy with just having the bazel equivalents as easy to remember shorthands. |
I think that's the correct philosophy long term. I haven't thought about this too deep.
But open to this as a first step, if it's possible. But if it's easier to do the above, I'd prefer it. In an ideal world, I envisioned we don't have |
@ajwerner, @miretskiy, @knz: word around the block is y'all have some prior experience with bazel. Mind sanity checking our plan above? We're thinking to work on moving crdb over the bazel later this month. +cc @jlinder. |
The Makefile fallback is important to keep around for more than just the eager folk - there will be enough combinations of build platforms, debug flags, testing commands etc which you won't have thought about and will need adjustments. |
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
54896: cli: add import pgdump/mysqldump CLI command r=miretskiy,knz a=adityamaru This change introduces a new CLI command to import locally saved PGDUMP or MYSQLDUMP files into a running cockroach cluster. The underlying logic relies on user scoped userfile storage to upload the local dump file to, and subsequently import data from. Most of the heavy lifting was already completed during the development of the userfile storage. We can only support bundle formats that have the table schemas to be imported, baked into the dump files. The newly added CLI commands support the same options as IMPORT PGDUMP and IMPORT MYSQLDUMP from the SQL shell do. These options are to be passed in as CLI flags. Following are the CLI examples: `./cockroach import db <format> <source>` `./cockroach import table <tablename> <format> <source>` Release note (cli change): Adds an import CLI command which allows users to upload and import local dump files into a running cockroach cluster. We currently support PGDUMP and MYSQLDUMP formats. 55687: *: bazel-ify cockroachdb r=irfansharif a=irfansharif 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: ``` new file: .bazelrc modified: .gitattributes modified: .gitignore new file: BUILD.bazel new file: DEPS.bzl modified: Makefile new file: WORKSPACE new file: pkg/ccl/gssapiccl/BUILD.bazel new file: pkg/ccl/storageccl/engineccl/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 modified: pkg/geo/geoproj/geoproj.go modified: pkg/geo/geoproj/proj.cc 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 modified: pkg/sql/colexec/and_or_projection_tmpl.go modified: pkg/sql/colexec/any_not_null_agg_tmpl.go modified: pkg/sql/colexec/avg_agg_tmpl.go modified: pkg/sql/colexec/bool_and_or_agg_tmpl.go modified: pkg/sql/colexec/cast_tmpl.go new file: pkg/sql/colexec/colbuilder/BUILD.bazel new file: pkg/sql/colexec/colexec.go modified: pkg/sql/colexec/concat_agg_tmpl.go modified: pkg/sql/colexec/const_tmpl.go modified: pkg/sql/colexec/count_agg_tmpl.go modified: pkg/sql/colexec/default_agg_tmpl.go modified: pkg/sql/colexec/default_cmp_expr_tmpl.go modified: pkg/sql/colexec/default_cmp_proj_ops_tmpl.go modified: pkg/sql/colexec/default_cmp_sel_ops_tmpl.go modified: pkg/sql/colexec/distinct_tmpl.go modified: pkg/sql/colexec/hash_aggregator_tmpl.go modified: pkg/sql/colexec/hash_utils_tmpl.go modified: pkg/sql/colexec/hashjoiner_tmpl.go modified: pkg/sql/colexec/hashtable_tmpl.go modified: pkg/sql/colexec/is_null_ops_tmpl.go modified: pkg/sql/colexec/mergejoinbase_tmpl.go modified: pkg/sql/colexec/mergejoiner_tmpl.go modified: pkg/sql/colexec/min_max_agg_tmpl.go modified: pkg/sql/colexec/ordered_synchronizer_tmpl.go modified: pkg/sql/colexec/proj_const_ops_tmpl.go modified: pkg/sql/colexec/proj_non_const_ops_tmpl.go modified: pkg/sql/colexec/quicksort_tmpl.go modified: pkg/sql/colexec/rank_tmpl.go modified: pkg/sql/colexec/relative_rank_tmpl.go modified: pkg/sql/colexec/row_number_tmpl.go modified: pkg/sql/colexec/rowstovec_tmpl.go modified: pkg/sql/colexec/select_in_tmpl.go modified: pkg/sql/colexec/selection_ops_tmpl.go modified: pkg/sql/colexec/sort_tmpl.go modified: pkg/sql/colexec/substring_tmpl.go modified: pkg/sql/colexec/sum_agg_tmpl.go modified: pkg/sql/colexec/utils_tmpl.go modified: pkg/sql/colexec/values_differ_tmpl.go modified: pkg/sql/colexec/vec_comparators_tmpl.go modified: pkg/sql/colexec/window_peer_grouper_tmpl.go 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 modified: pkg/sql/parser/sql.y 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 55827: sql: stub ALTER TABLE ... SET LOCALITY/AFFINITY related commands r=ajstorm a=otan Following the doc on proposed ideas and fleshed them all out. They default to displaying REGIONAL AFFINITY for now. Release note (sql change): Implemented ALTER TABLE ... SET LOCALITY/REGIONAL AFFINITY commands that allow users to configure multiregion properties of given tables. These may change later. Co-authored-by: Aditya Maru <[email protected]> Co-authored-by: irfan sharif <[email protected]> Co-authored-by: Oliver Tan <[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 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
55687: *: bazel-ify cockroachdb r=irfansharif a=irfansharif 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: ``` new file: .bazelrc modified: .gitattributes modified: .gitignore new file: BUILD.bazel new file: DEPS.bzl modified: Makefile new file: WORKSPACE new file: pkg/ccl/gssapiccl/BUILD.bazel new file: pkg/ccl/storageccl/engineccl/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 modified: pkg/geo/geoproj/geoproj.go modified: pkg/geo/geoproj/proj.cc 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 modified: pkg/sql/colexec/and_or_projection_tmpl.go modified: pkg/sql/colexec/any_not_null_agg_tmpl.go modified: pkg/sql/colexec/avg_agg_tmpl.go modified: pkg/sql/colexec/bool_and_or_agg_tmpl.go modified: pkg/sql/colexec/cast_tmpl.go new file: pkg/sql/colexec/colbuilder/BUILD.bazel new file: pkg/sql/colexec/colexec.go modified: pkg/sql/colexec/concat_agg_tmpl.go modified: pkg/sql/colexec/const_tmpl.go modified: pkg/sql/colexec/count_agg_tmpl.go modified: pkg/sql/colexec/default_agg_tmpl.go modified: pkg/sql/colexec/default_cmp_expr_tmpl.go modified: pkg/sql/colexec/default_cmp_proj_ops_tmpl.go modified: pkg/sql/colexec/default_cmp_sel_ops_tmpl.go modified: pkg/sql/colexec/distinct_tmpl.go modified: pkg/sql/colexec/hash_aggregator_tmpl.go modified: pkg/sql/colexec/hash_utils_tmpl.go modified: pkg/sql/colexec/hashjoiner_tmpl.go modified: pkg/sql/colexec/hashtable_tmpl.go modified: pkg/sql/colexec/is_null_ops_tmpl.go modified: pkg/sql/colexec/mergejoinbase_tmpl.go modified: pkg/sql/colexec/mergejoiner_tmpl.go modified: pkg/sql/colexec/min_max_agg_tmpl.go modified: pkg/sql/colexec/ordered_synchronizer_tmpl.go modified: pkg/sql/colexec/proj_const_ops_tmpl.go modified: pkg/sql/colexec/proj_non_const_ops_tmpl.go modified: pkg/sql/colexec/quicksort_tmpl.go modified: pkg/sql/colexec/rank_tmpl.go modified: pkg/sql/colexec/relative_rank_tmpl.go modified: pkg/sql/colexec/row_number_tmpl.go modified: pkg/sql/colexec/rowstovec_tmpl.go modified: pkg/sql/colexec/select_in_tmpl.go modified: pkg/sql/colexec/selection_ops_tmpl.go modified: pkg/sql/colexec/sort_tmpl.go modified: pkg/sql/colexec/substring_tmpl.go modified: pkg/sql/colexec/sum_agg_tmpl.go modified: pkg/sql/colexec/utils_tmpl.go modified: pkg/sql/colexec/values_differ_tmpl.go modified: pkg/sql/colexec/vec_comparators_tmpl.go modified: pkg/sql/colexec/window_peer_grouper_tmpl.go 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 modified: pkg/sql/parser/sql.y 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 Co-authored-by: irfan sharif <[email protected]>
Don't look, seeing what sticks.
Release note: None