-
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
dev: add support for dev generate cgo
#79455
Conversation
87f5b6e
to
dc1d398
Compare
The contents of these files here is basically cargo-culted from the `Makefile`. I have verified that I can get a build working via the following steps: ./dev generate go cgo ./dev go -- build ./pkg/cmd/cockroach-short We don't exactly mirror the previous contents of the `zcgo_flags.go` files that `make` would create. One difference is that we don't populate the `zcgo_flags` files in `go-libedit` to configure how the C sources are built and linked, so we get the default behavior, which is fine, but means the `go build`-built binary and the Bazel-built binary will be using a different compiled archive (maybe compiled with different flags/ a different configuration/etc.) for the `libedit` sources. With `make`, we address this by putting a `zcgo_flags_extra.go` file in the sources for `go-libedit` right in `vendor`. Post-Bazel we have no reason for `vendor` and have no plans to keep it in the long-term so this is not really suitable. I'm punting on this for now -- the default behavior will probably be "good enough" for most people. Closes cockroachdb#77170. Release note: None
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.
Hum hum. Makes sense to me, and this change
Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @rickystewart)
bors r=mari-crl |
Build succeeded: |
@rickystewart can you explain this part:
It looks to me looking at libedit/BUILD.bazel that the bazel build would use the same flag as specified in zcgo_flag_extra.go:
and the various Would a non-vendored build still use the same BUILD.bazel? |
@knz We distinguish between three different "ways" to build Cockroach here.
You're correct to notice that our |
I wasn't aware that |
On the contrary, it is NOT generating libedit-related code. |
ok let me rephrase: where in the execution of (i.e., where in the entire chain of |
🤔 I'm not sure what that question means. Taking it at face value, no, |
Ok then if it doesn't, then the libedit zcgo flags would not matter. That's what I was checking ;) Would it be possible to extend the |
We can add a |
yes, that is implied by what i mean. Is the What I meant is that for all |
I agree the dependencies for |
hm ok thanks for explaining.
|
I don't think this is literally true. |
thanks |
gopls keeps complaining about
From what you're saying, we expect this to resolve itself when we get rid of (fwiw, |
I've never used |
@erikgrinaker i'll be curious if you can double-check what the behavior is of If confirmed, then I suspect a workaround would be for you to install a libedit system-wide which the link directive would pick up. If that workaround works, it would also confirm that there's a bit more work to do in this area. |
Sure, I'll give it a try when I get a chance. |
Seems like // #cgo CPPFLAGS: -I/home/erik/.cache/bazel/_bazel_erik/58b8816bb117734f0a0eaaef7fcef95b/execroot/com_github_cockroachdb_cockroach/bazel-out/k8-fastbuild/bin/c-deps/libjemalloc/include -I/home/erik/.cache/bazel/_bazel_erik/58b8816bb117734f0a0eaaef7fcef95b/execroot/com_github_cockroachdb_cockroach/bazel-out/k8-fastbuild/bin/c-deps/libkrb5/include
// #cgo LDFLAGS: -L/home/erik/.cache/bazel/_bazel_erik/58b8816bb117734f0a0eaaef7fcef95b/execroot/com_github_cockroachdb_cockroach/bazel-out/k8-fastbuild/bin/c-deps/libjemalloc/lib -L/home/erik/.cache/bazel/_bazel_erik/58b8816bb117734f0a0eaaef7fcef95b/execroot/com_github_cockroachdb_cockroach/bazel-out/k8-fastbuild/bin/c-deps/libproj/lib -L/home/erik/.cache/bazel/_bazel_erik/58b8816bb117734f0a0eaaef7fcef95b/execroot/com_github_cockroachdb_cockroach/bazel-out/k8-fastbuild/bin/c-deps/libkrb5/lib
import "C" However, these paths do not exist: $ ls -l /home/erik/.cache/bazel/_bazel_erik/58b8816bb117734f0a0eaaef7fcef95b/execroot/com_github_cockroachdb_cockroach/bazel-out/k8-fastbuild/bin/c-deps/libjemalloc/include
ls: cannot access '/home/erik/.cache/bazel/_bazel_erik/58b8816bb117734f0a0eaaef7fcef95b/execroot/com_github_cockroachdb_cockroach/bazel-out/k8-fastbuild/bin/c-deps/libjemalloc/include': No such file or directory
$ ls /home/erik/.cache/bazel/_bazel_erik/58b8816bb117734f0a0eaaef7fcef95b/execroot/com_github_cockroachdb_cockroach/bazel-out/k8-fastbuild/bin
build docs external gazelle gazelle.runfiles gazelle.runfiles_manifest gazelle-runner.bash pkg _solib_k8
# no c-deps ^ A week-old copy in that tree does exist if I replace $ ls -l /home/erik/.cache/bazel/_bazel_erik/58b8816bb117734f0a0eaaef7fcef95b/execroot/cockroach/bazel-out/k8-fastbuild/bin/c-deps/libjemalloc/include
total 4
dr-xr-xr-x 2 erik erik 4096 Apr 15 09:59 jemalloc |
@erikgrinaker -- Can you try |
|
Nvm, it worked when I did |
I'll push a quick change to bump the |
Problems with `dev generate cgo` have been [noticed](cockroachdb#79455 (comment)) that are resolved if you re-build. Release note: None
Yeah, can confirm that cgo stuff works after |
79967: kv/bulk: parallelize sending SSTs due to range bounds r=dt a=dt Previously the batcher, when it determined it needed to finish one SST and send it before starting another, would wait for it to be sent before moving one. When flushing a buffer that contained data that mapped to many ranges, this meant many serial flushes, e.g. flushing 512MB of data from a buffer that had keys uniformly distributed over a table which was split into 2000 ranges meant waiting for roughly 2000 sequential AddSSTable requests. When those requests were slow, for example sometimes taking as much as 1s each or more, this became a major bottleneck. This change switches the batcher to send files that are ended due to a round boundary asynchronously, queuing up the request to send and then starting the next file while it sends, as long as memory capacity in the monitor allows holding the extra file in memory (as these async sends could result in using an entire extra buffer's worth of memory if they all end up in-flight at once, which they easily could if the receivers are queuing). Release note (performance improvement): Bulk ingestion of unsorted data during IMPORT and schema changes uses a higher level of parallelism to send produced data to the storage layer. 79991: allocator: carve out a package boundary r=irfansharif a=irfansharif **allocator/storepool: carve out package from kvserver** This commit tries to pave the way for the allocator itself to be carved out (storepool probably being a direct dependency, but ideally through an interface). This commit shamelessly exports any and everything needed in order for StorePool to sit outside the kvserver package boundary. It's unfortunate how tangled up this component is, including in tests (some of which reach deep into inner mutexes and mutate state). We're not doing anything to improve the status quo other than moving it and maybe pointing to the awkwardness. **allocatorimpl: carve out an allocator package** Do the same for kvserver/replicastats, a type that's used as an input for the allocator at various points (needed to break the dependency between the allocatorimpl and kvserver). We take the same approach as the last commit, exporting anything and everything needed to introduce a hard package boundary. 80197: ui: move shared graph components to cluster-ui r=jocrl,maryliag a=xinhaoz Part of #74516 This commit moves shared graph functions and components to cluster-ui package. This is to enable the new bar chart component to share axes utilities and containers with the older line graph component in db-console. Release note: None 80335: evalctx: remove some redundant uses of Txn on ExtendedEvalContext r=otan a=RichardJCai evalctx: remove some redundant uses of Txn on ExtendedEvalContext Release note: None Part of series of effort to get rid of kv.Txn from EvalContext 80349: dev: add example of bench with profiling r=jordanlewis a=jordanlewis Release note: None 80379: dev: bump version r=dt,erikgrinaker a=rickystewart Problems with `dev generate cgo` have been [noticed](#79455 (comment)) that are resolved if you re-build. Release note: None Co-authored-by: David Taylor <[email protected]> Co-authored-by: irfan sharif <[email protected]> Co-authored-by: Xin Hao Zhang <[email protected]> Co-authored-by: richardjcai <[email protected]> Co-authored-by: Jordan Lewis <[email protected]> Co-authored-by: Ricky Stewart <[email protected]>
The contents of these files here is basically cargo-culted from the
Makefile
. I have verified that I can get a build working via thefollowing steps:
We don't exactly mirror the previous contents of the
zcgo_flags.go
files that
make
would create. One difference is that we don't populatethe
zcgo_flags
files ingo-libedit
to configure how the C sourcesare built and linked, so we get the default behavior, which is fine, but
means the
go build
-built binary and the Bazel-built binary will beusing a different compiled archive (maybe compiled with different flags/
a different configuration/etc.) for the
libedit
sources.With
make
, we address this by putting azcgo_flags_extra.go
file inthe sources for
go-libedit
right invendor
. Post-Bazel we have noreason for
vendor
and have no plans to keep it in the long-term sothis is not really suitable. I'm punting on this for now -- the default
behavior will probably be "good enough" for most people.
Closes #77170.
Release note: None