Skip to content

Commit

Permalink
cockroach 22.1.5 (now with stdmalloc)
Browse files Browse the repository at this point in the history
  • Loading branch information
davepacheco authored Oct 26, 2022
1 parent c2de903 commit 7c127f7
Show file tree
Hide file tree
Showing 287 changed files with 305 additions and 39,673 deletions.
75 changes: 28 additions & 47 deletions cockroach/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,22 @@ WORKAROUND="$ROOT/cache/workaround"
rm -rf "$WORKAROUND"
mkdir -p "$WORKAROUND"

VER='21.2.9'
URL="https://binaries.cockroachdb.com/cockroach-v$VER.src.tgz"
VER='22.1.5'
COCKROACHDB_CLONE_REF="v$VER"

NODEVER="v16.3.0"
SYSNODEVER=$( node -v 2>&1 )
if [[ "$NODEVER" != "$SYSNODEVER" ]]; then
fatal "expected node $NODEVER, but found: $SYSNODEVER " \
"(see node-16 package)"
fi

GOVER='1.16.10'
SYSGOVER=$( (pkg info go-116 || true) | awk '/Version:/ { print $NF }')
GOVER='1.17.13'
SYSGOVER=$( (pkg info go-117 || true) | awk '/Version:/ { print $NF }')
if [[ "$SYSGOVER" != "$GOVER" ]]; then
fatal 'install or update go-116 package'
fatal 'install or update go-117 package'
fi
export GOROOT='/opt/ooce/go-1.16'
export GOROOT='/opt/ooce/go-1.17'
info "using $GOROOT/bin/go: $($GOROOT/bin/go version)"

YARNVER='1.22.5'
Expand All @@ -54,8 +61,21 @@ header 'downloading artefacts'
yarnfile="$ARTEFACT/yarn-v$YARNVER.tar.gz"
download_to yarn "$YARNURL" "$yarnfile"

file="$ARTEFACT/cockroach-v$VER.src.tgz"
download_to cockroach "$URL" "$file"
stamp="$ROOT/cache/cloned.stamp"
if [[ ! -f "$stamp" ]]; then
repo=https://github.com/cockroachdb/cockroach
info "cloning $repo branch $COCKROACHDB_CLONE_REF ..."
mkdir -p "$ROOT/cache/gopath/src/github.com/cockroachdb"
git clone \
--recurse-submodules \
--branch $COCKROACHDB_CLONE_REF \
--depth 1 \
$repo \
cache/gopath/src/github.com/cockroachdb/cockroach
touch "$stamp"
else
info 'already cloned'
fi

#
# Extract artefacts:
Expand All @@ -64,15 +84,6 @@ header 'extracting artefacts'

extract_to yarn "$yarnfile" "$YARNROOT" --strip-components=1

#
# The Cockroach DB source archive contains a wrapper Makefile at the top level
# which merely redirects one into the source that is set up, and sets GOPATH
# and BUILDCHANNEL='source-archive'. We'll just extract it into our expected
# GOPATH and ignore the rest.
#
#rm -rf "$GOPATH" # XXX
extract_to cockroach "$file" "$GOPATH" --strip-components=1

#
# Create workaround wrappers:
#
Expand Down Expand Up @@ -149,44 +160,14 @@ exit 1
EOF
chmod 0755 "$WORKAROUND/ps"

#
# The build will try to detect information about the git repository, but finds
# garbage-compactor.git, because the source archive we use to build Cockroach
# is not, itself, a git repository.
#
cat >"$WORKAROUND/git" <<'EOF'
#!/usr/bin/bash
exit 1
EOF
chmod 0755 "$WORKAROUND/git"

#
# Build Cockroach:
#
header 'patching cockroach source'

function vendor_replace {
local targ="$GOPATH/src/github.com/cockroachdb/cockroach/vendor/$1"
info "vendor replace $1"
rm -rf "$targ/"
cp -r "$ROOT/patches/$1/" "$targ/"
}

stamp="$ROOT/cache/patched.stamp"
if [[ ! -f "$stamp" ]]; then
apply_patches "$ROOT/patches" "$GOPATH"

info 'copying in extra files...'
cp $ROOT/patches/sysutil_illumos.go \
"$GOPATH/src/github.com/cockroachdb/cockroach/pkg/util/sysutil/"
cp $ROOT/patches/stderr_redirect_illumos.go \
"$GOPATH/src/github.com/cockroachdb/cockroach/pkg/util/log/"

vendor_replace "github.com/elastic/gosigar"
vendor_replace "github.com/knz/go-libedit"
vendor_replace "github.com/knz/strtime"
vendor_replace "github.com/cockroachdb/pebble/vfs"

touch "$stamp"
else
info 'already patched'
Expand Down
24 changes: 0 additions & 24 deletions cockroach/patches/03-sysutils.patch

This file was deleted.

12 changes: 0 additions & 12 deletions cockroach/patches/04-stderr.patch

This file was deleted.

10 changes: 0 additions & 10 deletions cockroach/patches/10-libpq.patch

This file was deleted.

11 changes: 11 additions & 0 deletions cockroach/patches/11-makefile-tags.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/src/github.com/cockroachdb/cockroach/Makefile
+++ b/src/github.com/cockroachdb/cockroach/Makefile
@@ -163,7 +163,7 @@ DESTDIR :=

DUPLFLAGS := -t 100
GOFLAGS :=
-TAGS :=
+TAGS := stdmalloc
ARCHIVE := cockroach.src.tgz
STARTFLAGS := -s type=mem,size=1GiB --logtostderr
BUILDTARGET := ./pkg/cmd/cockroach
41 changes: 41 additions & 0 deletions cockroach/patches/12-pebble-vfs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--- a/src/github.com/cockroachdb/cockroach/vendor/github.com/cockroachdb/pebble/vfs/errors_unix.go Fri Aug 19 10:55:44 2022
+++ b/src/github.com/cockroachdb/cockroach/vendor/github.com/cockroachdb/pebble/vfs/errors_unix.go Fri Aug 19 10:55:44 2022
@@ -2,8 +2,8 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

-//go:build darwin || dragonfly || freebsd || linux || openbsd
-// +build darwin dragonfly freebsd linux openbsd
+//go:build darwin || dragonfly || freebsd || linux || openbsd || illumos
+// +build darwin dragonfly freebsd linux openbsd illumos

package vfs

--- /dev/null Fri Aug 19 10:52:18 2022
+++ b/src/github.com/cockroachdb/cockroach/vendor/github.com/cockroachdb/pebble/vfs/disk_usage_illumos.go Wed Aug 17 15:09:39 2022
@@ -0,0 +1,25 @@
+// Copyright 2020 The LevelDB-Go and Pebble Authors. All rights reserved. Use
+// of this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+
+// +build illumos
+
+package vfs
+
+import "golang.org/x/sys/unix"
+
+func (defaultFS) GetDiskUsage(path string) (DiskUsage, error) {
+ stat := unix.Statvfs_t{}
+ if err := unix.Statvfs(path, &stat); err != nil {
+ return DiskUsage{}, err
+ }
+
+ freeBytes := uint64(stat.Bsize) * uint64(stat.Bfree)
+ availBytes := uint64(stat.Bsize) * uint64(stat.Bavail)
+ totalBytes := uint64(stat.Bsize) * uint64(stat.Blocks)
+ return DiskUsage{
+ AvailBytes: availBytes,
+ TotalBytes: totalBytes,
+ UsedBytes: totalBytes - freeBytes,
+ }, nil
+}
13 changes: 13 additions & 0 deletions cockroach/patches/13-strtime.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff -ur cache/gopath/src/github.com/cockroachdb/cockroach/vendor/github.com/knz/strtime/strptime.c patches/github.com/knz/strtime//strptime.c
--- a/src/github.com/cockroachdb/cockroach/vendor/github.com/knz/strtime/strptime.c Fri Aug 19 09:57:34 2022
+++ b/src/github.com/cockroachdb/cockroach/vendor/github.com/knz/strtime/strptime.c Fri Aug 19 09:57:34 2022
@@ -59,6 +59,9 @@
// #include "libc_private.h"
#include "timelocal.h"
// #include "tzfile.h"
+#ifdef __sun
+#include <alloca.h>
+#endif

static char * _strptime(const char *, const char *, struct mytm *, int *, locale_t);

36 changes: 36 additions & 0 deletions cockroach/patches/14-go-libedit.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--- a/src/github.com/cockroachdb/cockroach/vendor/github.com/knz/go-libedit/editline_other.go Fri Aug 19 11:16:49 2022
+++ b/src/github.com/cockroachdb/cockroach/vendor/github.com/knz/go-libedit/editline_other.go Fri Aug 19 11:16:49 2022
@@ -12,7 +12,7 @@
// implied. See the License for the specific language governing
// permissions and limitations under the License.

-// +build !darwin,!freebsd,!linux,!openbsd,!netbsd,!dragonfly
+// +build !darwin,!freebsd,!illumos,!linux,!openbsd,!netbsd,!dragonfly

package libedit

--- a/src/github.com/cockroachdb/cockroach/vendor/github.com/knz/go-libedit/editline_unix.go Fri Aug 19 11:16:49 2022
+++ b/src/github.com/cockroachdb/cockroach/vendor/github.com/knz/go-libedit/editline_unix.go Fri Aug 19 11:16:49 2022
@@ -12,7 +12,7 @@
// implied. See the License for the specific language governing
// permissions and limitations under the License.

-// +build darwin freebsd linux openbsd netbsd dragonfly
+// +build darwin freebsd illumos linux openbsd netbsd dragonfly

package libedit

--- a/src/github.com/cockroachdb/cockroach/vendor/github.com/knz/go-libedit/unix/editline_unix.go Fri Aug 19 11:16:49 2022
+++ b/src/github.com/cockroachdb/cockroach/vendor/github.com/knz/go-libedit/unix/editline_unix.go Fri Aug 19 11:16:49 2022
@@ -25,8 +25,8 @@
common "github.com/knz/go-libedit/common"
)

-// #cgo openbsd netbsd freebsd dragonfly darwin LDFLAGS: -ledit
-// #cgo openbsd netbsd freebsd dragonfly darwin CPPFLAGS: -Ishim
+// #cgo openbsd netbsd illumos freebsd dragonfly darwin LDFLAGS: -ledit
+// #cgo openbsd netbsd illumos freebsd dragonfly darwin CPPFLAGS: -Ishim
// #cgo linux LDFLAGS: -lncurses
// #cgo linux CFLAGS: -Wno-unused-result -Wno-pointer-sign
// #cgo linux CPPFLAGS: -Isrc -Isrc/c-libedit -Isrc/c-libedit/editline -Isrc/c-libedit/linux-build -D_GNU_SOURCE

Loading

0 comments on commit 7c127f7

Please sign in to comment.