upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbitflash-maintainer <noreply@bitflash.invalid>2026-09-02 05:22:36 +0000
committerbitflash-maintainer <noreply@bitflash.invalid>2026-09-02 05:22:36 +0000
commitfd627b134c686e7c9afb646dc37c573c5d36fd4a (patch)
tree4ebf97a159074dfb478056b4deee40ea575bf6a5
parente4f898c4a6b9900553c64b9804889b5fdae3e55f (diff)
build: stop rm -rf'ing a RandomX tree the build did not create
deps-randomx built into $(HOME)/RandomX and deleted that path whenever the library was missing, taking out hand-managed checkouts the build never owned. Default the build to the in-tree $(ROOT)/randomx-build, like secp256k1-build, overridable via RANDOMX_DIR and exported so src/Makefile's own fallback resolves to the same tree. As a backstop, the recipe writes a .bitflash-built marker after a successful build and refuses to delete any directory that lacks it, so a user-supplied RANDOMX_DIR pointing at a pre-existing tree is never removed. Closes #27
-rw-r--r--Makefile31
-rw-r--r--src/Makefile4
2 files changed, 27 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 9f97b73..83a2c73 100644
--- a/Makefile
+++ b/Makefile
@@ -59,6 +59,17 @@ APPIMAGETOOL_SHA256 := ed4ce84f0d9caff66f50bcca6ff6f35aae54ce8135408b3fa33abfc3c
59 59
60# ---- Linux ---------------------------------------------------------------- 60# ---- Linux ----------------------------------------------------------------
61 61
62# RandomX used to build in $(HOME)/RandomX, and deps-randomx would rm -rf that
63# path whenever the library was missing -- deleting a tree the build did not
64# create and does not own (issue #27; a hand-managed pinned checkout there is
65# what this machine's miners build against). The default is now in-tree, like
66# secp256k1-build. A host that deliberately keeps RandomX elsewhere can set
67# RANDOMX_DIR=... explicitly; the recipe below will still never delete a
68# directory that lacks the marker file this build writes after a successful
69# build. Exported so src/Makefile's own RANDOMX_DIR ?= picks the same tree.
70RANDOMX_DIR ?= $(ROOT)/randomx-build
71export RANDOMX_DIR
72
62linux: deps-linux 73linux: deps-linux
63 $(MAKE) -C src -f Makefile -j$(NPROC) 74 $(MAKE) -C src -f Makefile -j$(NPROC)
64 strip src/bitflash 75 strip src/bitflash
@@ -109,19 +120,25 @@ deps-secp256k1:
109 fi 120 fi
110 121
111deps-randomx: 122deps-randomx:
112 @if [ ! -f $(HOME)/RandomX/build/librandomx.a ]; then \ 123 @if [ ! -f $(RANDOMX_DIR)/build/librandomx.a ]; then \
124 if [ -d $(RANDOMX_DIR) ] && [ ! -f $(RANDOMX_DIR)/.bitflash-built ]; then \
125 echo "ERROR: $(RANDOMX_DIR) exists but was not created by this build"; \
126 echo " refusing to rm -rf it -- remove it yourself or set RANDOMX_DIR"; \
127 exit 1; \
128 fi; \
113 echo "==> building RandomX"; \ 129 echo "==> building RandomX"; \
114 rm -rf $(HOME)/RandomX; \ 130 rm -rf $(RANDOMX_DIR); \
115 git init -q $(HOME)/RandomX; \ 131 git init -q $(RANDOMX_DIR); \
116 cd $(HOME)/RandomX && \ 132 cd $(RANDOMX_DIR) && \
117 git remote add origin $(RANDOMX_REPO) && \ 133 git remote add origin $(RANDOMX_REPO) && \
118 git fetch -q --depth 1 origin $(RANDOMX_COMMIT) && \ 134 git fetch -q --depth 1 origin $(RANDOMX_COMMIT) && \
119 git checkout -q --detach FETCH_HEAD && \ 135 git checkout -q --detach FETCH_HEAD && \
120 test "$$(git rev-parse HEAD)" = "$(RANDOMX_COMMIT)" && \ 136 test "$$(git rev-parse HEAD)" = "$(RANDOMX_COMMIT)" && \
121 echo "==> RandomX pinned at $(RANDOMX_COMMIT)" && \ 137 echo "==> RandomX pinned at $(RANDOMX_COMMIT)" && \
122 mkdir -p $(HOME)/RandomX/build; \ 138 mkdir -p $(RANDOMX_DIR)/build && \
123 cd $(HOME)/RandomX/build && cmake .. -DCMAKE_BUILD_TYPE=Release && \ 139 cd $(RANDOMX_DIR)/build && cmake .. -DCMAKE_BUILD_TYPE=Release && \
124 make -j$(NPROC) randomx; \ 140 make -j$(NPROC) randomx && \
141 touch $(RANDOMX_DIR)/.bitflash-built && \
125 echo "==> RandomX done"; \ 142 echo "==> RandomX done"; \
126 else \ 143 else \
127 echo "==> RandomX already built"; \ 144 echo "==> RandomX already built"; \
diff --git a/src/Makefile b/src/Makefile
index 1bc3ae8..2c6d304 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -6,7 +6,9 @@ FUZZ_CXX ?= clang++
6 6
7SECP_INC ?= /usr/local/include 7SECP_INC ?= /usr/local/include
8SECP_LIB ?= /usr/local/lib 8SECP_LIB ?= /usr/local/lib
9RANDOMX_DIR ?= $(HOME)/RandomX 9# The root Makefile exports RANDOMX_DIR (default: <repo>/randomx-build, built
10# by deps-randomx). This fallback only applies when src/ is built standalone.
11RANDOMX_DIR ?= $(abspath $(CURDIR)/..)/randomx-build
10 12
11IMGUI_DIR = imgui 13IMGUI_DIR = imgui
12 14