Skip to content

Commit

Permalink
bedrockdb: fix nondeterminism
Browse files Browse the repository at this point in the history
  • Loading branch information
42LoCo42 committed Jun 2, 2024
1 parent 466f805 commit 989959d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
10 changes: 5 additions & 5 deletions packages/bedrockdb/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{ fetchFromGitHub
, git
, pcre-cpp
, pkg-config
, runCommand
Expand All @@ -16,8 +15,7 @@ stdenv.mkDerivation rec {
owner = "expensify";
repo = "bedrock";
rev = version;
leaveDotGit = true;
hash = "sha256-g2zJs/5S+8qevk3rGJnp1P8VsCRj4q1nBsQ7pKoftDk=";
hash = "sha256-NzKC7RdsoU9Uz+RhqDLIbpnyg4TcWoLk7y96ftEzCBY=";
};

mbedtls = fetchFromGitHub {
Expand All @@ -37,7 +35,9 @@ stdenv.mkDerivation rec {
patches = [ ./nixify.patch ];
enableParallelBuilding = true;

nativeBuildInputs = [ git pkg-config ];
GIT_REVISION = "-DGIT_REVISION=${version}";

nativeBuildInputs = [ pkg-config ];
buildInputs = [ pcre-cpp zlib ];
buildFlags = "bedrock";

Expand All @@ -48,6 +48,6 @@ stdenv.mkDerivation rec {
meta = {
description = "Rock solid distributed database specializing in active/active automatic failover and WAN replication";
homepage = "https://bedrockdb.com";
mainProgram = "bedrockdb";
mainProgram = "bedrock";
};
}
20 changes: 12 additions & 8 deletions packages/bedrockdb/nixify.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/Makefile b/Makefile
index fae0f898..f8d43b70 100644
index fae0f898..6239661a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,3 @@
@@ -1,29 +1,17 @@
-# If $CC and $CXX are defined as environment variables, those will be used here. However, if they aren't then GNU make
-# automatically defines them as `cc` and `g++`. Ultimately, we'd like those names to work, or the environment variables
-# to be set, but for the time being we need to override the defaults so that our existing dev environment works. This
Expand All @@ -17,12 +17,16 @@ index fae0f898..f8d43b70 100644
# Set the optimization level from the environment, or default to -O2.
ifndef BEDROCK_OPTIM_COMPILE_FLAG
BEDROCK_OPTIM_COMPILE_FLAG = -O2
@@ -19,11 +8,13 @@ endif
GIT_REVISION = -DGIT_REVISION=$(shell git rev-parse HEAD | grep -o '^.\{10\}')
PROJECT = $(shell git rev-parse --show-toplevel)
endif

+DEPS := libpcrecpp zlib
-# Pull some variables from the git repo itself. Note that this means this build does not work if Bedrock isn't
-# contained in a git repo.
-GIT_REVISION = -DGIT_REVISION=$(shell git rev-parse HEAD | grep -o '^.\{10\}')
-PROJECT = $(shell git rev-parse --show-toplevel)
+PROJECT = .
+
+DEPS := libpcrecpp zlib

# Set our include paths. We need this for the pre-processor to use to generate dependencies.
-INCLUDE = -I$(PROJECT) -I$(PROJECT)/mbedtls/include
+INCLUDE = -I$(PROJECT) -I$(PROJECT)/mbedtls/include $(shell pkg-config --cflags $(DEPS))
Expand All @@ -33,7 +37,7 @@ index fae0f898..f8d43b70 100644

# Amalgamation flags
AMALGAMATION_FLAGS = -Wno-unused-but-set-variable -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT -DSQLITE_ENABLE_NOOP_UPDATE -DSQLITE_MUTEX_ALERT_MILLISECONDS=20 -DHAVE_USLEEP=1 -DSQLITE_MAX_MMAP_SIZE=17592186044416ull -DSQLITE_SHARED_MAPPING -DSQLITE_ENABLE_NORMALIZE -DSQLITE_MAX_PAGE_COUNT=4294967294 -DSQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
@@ -32,7 +23,7 @@ AMALGAMATION_FLAGS = -Wno-unused-but-set-variable -DSQLITE_ENABLE_FTS5 -DSQLITE_
@@ -32,7 +20,7 @@ AMALGAMATION_FLAGS = -Wno-unused-but-set-variable -DSQLITE_ENABLE_FTS5 -DSQLITE_
INTERMEDIATEDIR = .build

# We use the same library paths and required libraries for all binaries.
Expand All @@ -42,7 +46,7 @@ index fae0f898..f8d43b70 100644
LIBRARIES =-Wl,--start-group -lbedrock -lstuff -Wl,--end-group -ldl -lpcrecpp -lpthread -lmbedtls -lmbedx509 -lmbedcrypto -lz -lm

# These targets aren't actual files.
@@ -61,9 +52,6 @@ clean:
@@ -61,9 +49,6 @@ clean:

# Rule to build mbedtls.
mbedtls/library/libmbedcrypto.a mbedtls/library/libmbedtls.a mbedtls/library/libmbedx509.a:
Expand Down

0 comments on commit 989959d

Please sign in to comment.