Skip to content
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

Closed
wants to merge 9 commits into from

Conversation

irfansharif
Copy link
Contributor

Don't look, seeing what sticks.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@irfansharif irfansharif added the do-not-merge bors won't merge a PR with this label. label Aug 14, 2020
Copy link
Collaborator

@petermattis petermattis left a 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: :shipit: complete! 0 of 0 LGTMs obtained

@irfansharif irfansharif force-pushed the 200814.bazel branch 2 times, most recently from f7cfa0b to 5be1da3 Compare August 14, 2020 21:21
@irfansharif
Copy link
Contributor Author

irfansharif commented Aug 14, 2020

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

@kenliu
Copy link

kenliu commented Aug 14, 2020

exciting to see you taking a swing at this @irfansharif !

@kenliu kenliu requested a review from jlinder August 14, 2020 21:37
@irfansharif irfansharif force-pushed the 200814.bazel branch 2 times, most recently from 905b681 to f1711c1 Compare August 14, 2020 22:14
@irfansharif
Copy link
Contributor Author

irfansharif commented Aug 14, 2020

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):

make bazel-clean; make gazelle-generate; bazel run //pkg/cmd/roachtest:roachtest -- -h

Which runs into:

ERROR: /Users/irfansharif/Software/src/github.com/cockroachdb/cockroach/pkg/server/BUILD.bazel:3:11: no such package '@io_etcd_go_etcd//raft': BUILD file not found in directory 'raft' of external repository @io_etcd_go_etcd. Add a BUILD file to a directory to mark it as a package. and referenced by '//pkg/server:go_default_library'
ERROR: Analysis of target '//pkg/cmd/roachtest:roachtest' failed; build aborted: Analysis failed
INFO: Elapsed time: 2.012s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (306 packages loaded, 1180 targets configured)
FAILED: Build did NOT complete successfully (306 packages loaded, 1180 targets configured)

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>
@irfansharif
Copy link
Contributor Author

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 make generate (protos and other random generated code things we do today) into bazel by writing custom genrules: https://docs.bazel.build/versions/3.4.0/be/general.html#genrule.cmd. These two things should let us start stubbing out our makefile targets with bazel underneath the hood.

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:

pkg/storage/BUILD.bazel
pkg/ccl/storageccl/engineccl/BUILD.bazel
pkg/geo/geos/BUILD.bazel
pkg/geo/geoproj/BUILD.bazel
vendor/github.com/knz/go-libedit/BUILD.bazel

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 datadriven.

$ bazel test @cockroach//pkg/kv/kvserver/concurrency/...
INFO: Analyzed 4 targets (19 packages loaded, 170 targets configured).
INFO: Found 3 targets and 1 test target...
INFO: Elapsed time: 40.434s, Critical Path: 40.16s
INFO: 32 processes: 32 darwin-sandbox.
INFO: Build completed successfully, 37 total actions
@cockroach//pkg/kv/kvserver/concurrency:go_default_test                  PASSED in 31.1s

INFO: Build completed successfully, 37 total actions

@irfansharif
Copy link
Contributor Author

So, next steps here:

  • For each of the c-dependencies, we're going to need to construct a BUILD file
    for it to represent the dependency. This should be able to shell out and run
    cmake or whatever else it is that we do today to compile those artifacts.
    We have various cgo linking directives today in our go code that expect to
    find these artifacts generated and placed in certain directories. These were
    used when auto-generating the BUILD.bazel files per directory. As long as
    we set up these per-pkg BUILD files to include the aforementioned
    c-depedencies as dependencies (which would hopefully generate the artifacts
    and place them at the right directories), it should just work.
  • For every "codegen" facility we have today (optgen, execgen, protobuf), we're
    going to need to write custom build rules to generate those files and then
    depend against those targets before compiling CRDB. See genrule.
  • In the branch above we let bazel take over the vendor directory and bazel-ify
    each dependency. I'm not sure that that's the best way to do it. What we want
    is to tell bazel to treat the vendor directory as an artifact of sorts
    (perhaps we we want to write custom build rules to check out the right
    submodule SHA), and just have the go compiler (as run through bazel) to look
    towards there without expecting everything to be similarly bazel-ified.
  • Write custom build files to generate our UI assets.
  • See comment above about the manual BUILD.bazel include path changes I had to
    make. I think they should be relative to repo root, but I couldn't get that
    to work. I hacked in an absolute path on my machine, but that'll need to get
    changed.
  • Gazelle auto-generated the dependencies.bzl file from go.mod. We should make
    sure our process for bumping dependencies also appropriately update this file (or
    check that they're in-sync, something like teamcity-assert-clean.

Given we're proposing having a dedicated hack-week to get all this out the
door, we should first aim for the developer experience around our current
Makefile. We can invoke bazel underneath our Makefile targets (gated by an env
var USE_BAZEL=1) and aim for the following targets (roughly in the order we
should want to do them):

  • make {generate,protobuf}
  • make bin/{...}
  • make build{,oss,short} (the latter is easiest)
  • make clean{,short}, ui-{,maintainer-}clean, unsafe-clean
  • make install
  • make test (including supporting PKG=... TESTS=... TESTFLAGS=...)
  • make bench (including supporting PKG=... BENCHES=...)
  • make stress (including
  • make testlogic
  • ...everything else

At all times we should be generating artifacts that are byte-by-byte identical
with those we would otherwise generate through our current make-based system.

@jordanlewis, @otan, @petermattis: thoughts?

@otan
Copy link
Contributor

otan commented Sep 1, 2020

We can invoke bazel underneath our Makefile targets (gated by an env var USE_BAZEL=1)

This seems messy given Makefile dependencies will probably have a bad time if you switch between them both. I'd rather the concept of make be gone when this ends -- instead of make commands, we run something like bazel tool //build:lint, or something of the ilk work (face it, who wants to maintain a Makefile :P).

@irfansharif
Copy link
Contributor Author

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.

@otan
Copy link
Contributor

otan commented Sep 1, 2020

In the branch above we let bazel take over the vendor directory and bazel-ify
each dependency.

I think that's the correct philosophy long term. I haven't thought about this too deep.

I'm not sure that that's the best way to do it. What we want
is to tell bazel to treat the vendor directory as an artifact of sorts
(perhaps we we want to write custom build rules to check out the right
submodule SHA), and just have the go compiler (as run through bazel) to look
towards there without expecting everything to be similarly bazel-ified.

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 vendor directories at all, and bazel will pull these down at build time. Ideally we can get rid of submodules entirely :P but I'm not familiar with bazel vendoring.

@irfansharif
Copy link
Contributor Author

irfansharif commented Sep 2, 2020

@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.

@knz
Copy link
Contributor

knz commented Sep 4, 2020

have eager folks try just one build system at a time and report badness as they come up.

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.

@irfansharif
Copy link
Contributor Author

Subsumed by #55258 and then #55687.

irfansharif added a commit to irfansharif/cockroach that referenced this pull request Oct 26, 2020
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
craig bot pushed a commit that referenced this pull request Oct 26, 2020
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]>
irfansharif added a commit to irfansharif/cockroach that referenced this pull request Oct 26, 2020
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
craig bot pushed a commit that referenced this pull request Oct 26, 2020
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]>
@irfansharif irfansharif deleted the 200814.bazel branch February 26, 2021 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge bors won't merge a PR with this label.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants