Makefile: support overriding of CC and CARGO for catching unintended builds.
What changed, and why it matters
This commit is a build-system maintenance change. It lets the project’s Makefiles accept custom values for the C compiler (CC) and Rust tool (CARGO) variables, and adds a small helper script used only in CI to detect accidental rebuilds. There is no change to the actual Lightning node software, no bug fix, and no security-related behavior.
No security action required. Treat as normal build/CI tooling improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch parameterizes hard-coded cargo invocations as $(CARGO) in cln-rpc/Makefile and plugins/Makefile, defines a default CARGO := cargo in the top-level Makefile, and introduces devtools/cc-nobuild. The helper script only permits cc -dumpmachine (reading the real CC from config.vars) and exits with failure for any other invocation, so CI can set CC=devtools/cc-nobuild CARGO=false to verify that a target does not trigger compilation. No source code, protocol logic, cryptography, or runtime configuration is modified.
Changed components
Makefilecln-rpc/Makefileplugins/Makefiledevtools/cc-nobuildInspect captured patch +20 / −10
diff --git a/Makefile b/Makefile
index b6f28825..fb9bd911 100644
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,7 @@ ECHO := echo
SUPPRESS_OUTPUT :=
endif
+CARGO := cargo
DISTRO=$(shell lsb_release -is 2>/dev/null || echo unknown)-$(shell lsb_release -rs 2>/dev/null || echo unknown)
OS=$(shell uname -s)
ARCH=$(shell uname -m)
diff --git a/cln-rpc/Makefile b/cln-rpc/Makefile
index c43467ab..808dd71c 100644
--- a/cln-rpc/Makefile
+++ b/cln-rpc/Makefile
@@ -9,13 +9,13 @@ DEFAULT_TARGETS += $(CLN_RPC_EXAMPLES) $(CLN_RPC_GENALL)
MSGGEN_GENALL += $(CLN_RPC_GENALL)
target/${RUST_PROFILE}/examples/cln-rpc-getinfo: ${CLN_RPC_SOURCES} cln-rpc/examples/getinfo.rs
- cargo build ${CARGO_OPTS} --example cln-rpc-getinfo
+ $(CARGO) build ${CARGO_OPTS} --example cln-rpc-getinfo
target/${RUST_PROFILE}/examples/cln-plugin-startup: ${CLN_RPC_SOURCES} plugins/examples/cln-plugin-startup.rs
- cargo build ${CARGO_OPTS} --example cln-plugin-startup
+ $(CARGO) build ${CARGO_OPTS} --example cln-plugin-startup
target/${RUST_PROFILE}/examples/cln-plugin-reentrant: ${CLN_RPC_SOURCES} plugins/examples/cln-plugin-reentrant.rs
- cargo build ${CARGO_OPTS} --example cln-plugin-reentrant
+ $(CARGO) build ${CARGO_OPTS} --example cln-plugin-reentrant
cln-rpc-all: ${CLN_RPC_GENALL} ${CLN_RPC_EXAMPLES}
diff --git a/devtools/cc-nobuild b/devtools/cc-nobuild
new file mode 100755
index 00000000..11838558
--- /dev/null
+++ b/devtools/cc-nobuild
@@ -0,0 +1,9 @@
+#! /bin/sh
+# Version of CC which only supports -dumpmachine (for external/Makefile), and fails otherwise
+set -e
+
+if [ x"$*" = x"-dumpmachine" ]; then
+ CC="$(grep ^CC= config.vars | cut -d= -f2-)"
+ exec ${CC:=cc} "$@"
+fi
+exit 1
diff --git a/plugins/Makefile b/plugins/Makefile
index cda322ac..9dd006cb 100644
--- a/plugins/Makefile
+++ b/plugins/Makefile
@@ -237,7 +237,7 @@ plugins/list_of_builtin_plugins_gen.h: plugins/Makefile Makefile config.vars
@$(call VERBOSE,GEN $@,echo "static const char *list_of_builtin_plugins[] = { $(PLUGIN_BASES:%=\"%\",) NULL };" > $@)
$(RUST_TARGET_DIR)/examples/cln-subscribe-wildcard: ${CLN_PLUGIN_SRC} plugins/examples/cln-subscribe-wildcard.rs
- cargo build ${CARGO_OPTS} --example cln-subscribe-wildcard
+ $(CARGO) build ${CARGO_OPTS} --example cln-subscribe-wildcard
CLN_PLUGIN_EXAMPLES := \
$(RUST_TARGET_DIR)/examples/cln-plugin-startup \
@@ -253,17 +253,17 @@ CLN_WSS_PROXY_PLUGIN_SRC = $(shell find plugins/wss-proxy-plugin/src -name "*.rs
CLN_BIP353_PLUGIN_SRC = $(shell find plugins/bip353-plugin/src -name "*.rs")
$(RUST_TARGET_DIR)/cln-grpc: ${CLN_PLUGIN_SRC} ${CLN_GRPC_PLUGIN_SRC} $(MSGGEN_GENALL) $(MSGGEN_GEN_ALL)
- cargo build ${CARGO_OPTS} --bin cln-grpc
+ $(CARGO) build ${CARGO_OPTS} --bin cln-grpc
$(RUST_TARGET_DIR)/clnrest: ${CLN_REST_PLUGIN_SRC}
- cargo build ${CARGO_OPTS} --bin clnrest
+ $(CARGO) build ${CARGO_OPTS} --bin clnrest
$(RUST_TARGET_DIR)/cln-lsps-client: ${CLN_LSPS_PLUGIN_SRC}
- cargo build ${CARGO_OPTS} --bin cln-lsps-client
+ $(CARGO) build ${CARGO_OPTS} --bin cln-lsps-client
$(RUST_TARGET_DIR)/cln-lsps-service: ${CLN_LSPS_PLUGIN_SRC}
- cargo build ${CARGO_OPTS} --bin cln-lsps-service
+ $(CARGO) build ${CARGO_OPTS} --bin cln-lsps-service
$(RUST_TARGET_DIR)/wss-proxy: ${CLN_WSS_PROXY_PLUGIN_SRC}
- cargo build ${CARGO_OPTS} --bin wss-proxy
+ $(CARGO) build ${CARGO_OPTS} --bin wss-proxy
$(RUST_TARGET_DIR)/cln-bip353: ${CLN_BIP353_PLUGIN_SRC}
- cargo build ${CARGO_OPTS} --bin cln-bip353
+ $(CARGO) build ${CARGO_OPTS} --bin cln-bip353
ifneq ($(RUST),0)
include plugins/rest-plugin/Makefile
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.