Skip to content

Commit c17d990

Browse files
author
Claudio Raimondi
committed
Fix cargo cross compilation [skip ci]
1 parent db51a09 commit c17d990

File tree

2 files changed

+32
-33
lines changed

2 files changed

+32
-33
lines changed

Dockerfile

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,7 @@ ARG TARGET=${target_arch_rust}
139139
ARG COPTFLAGS="-O2 ${COPTFLAGS}"
140140
ARG RUST_PROFILE=release
141141

142-
WORKDIR /opt
143-
144-
RUN ./install-uv.sh -q
145-
RUN ./install-rust.sh -y -q --profile minimal --component rustfmt --target ${target_arch_rust}
146-
147-
ENV PATH="/root/.cargo/bin:/root/.local/bin:${PATH}"
148-
149-
#TODO: set them all via ENV vars
142+
#TODO: set via env
150143
RUN mkdir -p .cargo && tee .cargo/config.toml <<EOF
151144

152145
[build]
@@ -158,21 +151,27 @@ linker = "${CC}"
158151

159152
EOF
160153

161-
WORKDIR /opt/lightningd
154+
WORKDIR /opt
162155

163-
#TODO: Fix unaligned access on armv7
164-
RUN ./configure --prefix=/tmp/lightning_install --enable-static --disable-compat --disable-valgrind
156+
RUN ./install-uv.sh -q
157+
RUN ./install-rust.sh -y -q --profile minimal --component rustfmt --target ${target_arch_rust}
158+
159+
ENV PATH="/root/.cargo/bin:/root/.local/bin:${PATH}"
160+
161+
WORKDIR /opt/lightningd
165162

166163
COPY .git/ .git/
167164
RUN git submodule update --init --recursive --jobs $(nproc) --depth 1
168165

166+
#TODO: Fix unaligned access on armv7
167+
RUN ./configure --prefix=/tmp/lightning_install --enable-static --disable-compat --disable-valgrind
168+
#TODO: Fix cp stat error on amd64 x86-64
169169
RUN uv run make install-program -j$(nproc)
170-
#TODO: prettier
170+
171171
RUN find /tmp/lightning_install -type f -executable -exec \
172-
file {} + | \
173-
grep -E ':.*ELF' | \
174-
cut -d: -f1 | \
175-
xargs -r ${STRIP} --strip-unneeded
172+
file {} + | \
173+
awk -F: '/ELF/ {print $1}' | \
174+
xargs -r ${STRIP} --strip-unneeded
176175

177176
FROM base-target AS final
178177

plugins/Makefile

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,17 @@ $(shell test -d plugins/wss-proxy && $(RM) -r plugins/wss-proxy || true)
140140
ifneq ($(RUST),0)
141141
# Builtin plugins must be in this plugins dir to work when we're executed
142142
# *without* make install.
143-
plugins/cln-grpc: target/${RUST_PROFILE}/cln-grpc
143+
plugins/cln-grpc: $(RUST_TARGET_DIR)/cln-grpc
144144
@cp $< $@
145-
plugins/clnrest: target/${RUST_PROFILE}/clnrest
145+
plugins/clnrest: $(RUST_TARGET_DIR)/clnrest
146146
@cp $< $@
147-
plugins/cln-lsps-client: target/${RUST_PROFILE}/cln-lsps-client
147+
plugins/cln-lsps-client: $(RUST_TARGET_DIR)/cln-lsps-client
148148
@cp $< $@
149-
plugins/cln-lsps-service: target/${RUST_PROFILE}/cln-lsps-service
149+
plugins/cln-lsps-service: $(RUST_TARGET_DIR)/cln-lsps-service
150150
@cp $< $@
151-
plugins/wss-proxy: target/${RUST_PROFILE}/wss-proxy
151+
plugins/wss-proxy: $(RUST_TARGET_DIR)/wss-proxy
152152
@cp $< $@
153-
plugins/cln-bip353: target/${RUST_PROFILE}/cln-bip353
153+
plugins/cln-bip353: $(RUST_TARGET_DIR)/cln-bip353
154154
@cp $< $@
155155

156156
PLUGINS += plugins/cln-grpc plugins/clnrest plugins/cln-lsps-client plugins/cln-lsps-service plugins/wss-proxy plugins/cln-bip353
@@ -293,14 +293,14 @@ PLUGIN_BASES := $(PLUGINS:plugins/%=%) $(PY_PLUGINS:plugins/%=%)
293293
plugins/list_of_builtin_plugins_gen.h: plugins/Makefile Makefile config.vars
294294
@$(call VERBOSE,GEN $@,echo "static const char *list_of_builtin_plugins[] = { $(PLUGIN_BASES:%=\"%\",) NULL };" > $@)
295295

296-
target/${RUST_PROFILE}/examples/cln-subscribe-wildcard: ${CLN_PLUGIN_SRC} plugins/examples/cln-subscribe-wildcard.rs
296+
$(RUST_TARGET_DIR)/examples/cln-subscribe-wildcard: ${CLN_PLUGIN_SRC} plugins/examples/cln-subscribe-wildcard.rs
297297
cargo build ${CARGO_OPTS} --example cln-subscribe-wildcard
298298

299299
CLN_PLUGIN_EXAMPLES := \
300-
target/${RUST_PROFILE}/examples/cln-plugin-startup \
301-
target/${RUST_PROFILE}/examples/cln-plugin-reentrant \
302-
target/${RUST_PROFILE}/examples/cln-rpc-getinfo \
303-
target/${RUST_PROFILE}/examples/cln-subscribe-wildcard
300+
$(RUST_TARGET_DIR)/examples/cln-plugin-startup \
301+
$(RUST_TARGET_DIR)/examples/cln-plugin-reentrant \
302+
$(RUST_TARGET_DIR)/examples/cln-rpc-getinfo \
303+
$(RUST_TARGET_DIR)/examples/cln-subscribe-wildcard
304304

305305
CLN_PLUGIN_SRC = $(shell find plugins/src -name "*.rs")
306306
CLN_GRPC_PLUGIN_SRC = $(shell find plugins/grpc-plugin/src -name "*.rs")
@@ -309,17 +309,17 @@ CLN_LSPS_PLUGIN_SRC = $(shell find plugins/lsps-plugin/src -name "*.rs")
309309
CLN_WSS_PROXY_PLUGIN_SRC = $(shell find plugins/wss-proxy-plugin/src -name "*.rs")
310310
CLN_BIP353_PLUGIN_SRC = $(shell find plugins/bip353-plugin/src -name "*.rs")
311311

312-
target/${RUST_PROFILE}/cln-grpc: ${CLN_PLUGIN_SRC} ${CLN_GRPC_PLUGIN_SRC} $(MSGGEN_GENALL) $(MSGGEN_GEN_ALL)
312+
$(RUST_TARGET_DIR)/cln-grpc: ${CLN_PLUGIN_SRC} ${CLN_GRPC_PLUGIN_SRC} $(MSGGEN_GENALL) $(MSGGEN_GEN_ALL)
313313
cargo build ${CARGO_OPTS} --bin cln-grpc
314-
target/${RUST_PROFILE}/clnrest: ${CLN_REST_PLUGIN_SRC}
314+
$(RUST_TARGET_DIR)/clnrest: ${CLN_REST_PLUGIN_SRC}
315315
cargo build ${CARGO_OPTS} --bin clnrest
316-
target/${RUST_PROFILE}/cln-lsps-client: ${CLN_LSPS_PLUGIN_SRC}
316+
$(RUST_TARGET_DIR)/cln-lsps-client: ${CLN_LSPS_PLUGIN_SRC}
317317
cargo build ${CARGO_OPTS} --bin cln-lsps-client
318-
target/${RUST_PROFILE}/cln-lsps-service: ${CLN_LSPS_PLUGIN_SRC}
318+
$(RUST_TARGET_DIR)/cln-lsps-service: ${CLN_LSPS_PLUGIN_SRC}
319319
cargo build ${CARGO_OPTS} --bin cln-lsps-service
320-
target/${RUST_PROFILE}/wss-proxy: ${CLN_WSS_PROXY_PLUGIN_SRC}
320+
$(RUST_TARGET_DIR)/wss-proxy: ${CLN_WSS_PROXY_PLUGIN_SRC}
321321
cargo build ${CARGO_OPTS} --bin wss-proxy
322-
target/${RUST_PROFILE}/cln-bip353: ${CLN_BIP353_PLUGIN_SRC}
322+
$(RUST_TARGET_DIR)/cln-bip353: ${CLN_BIP353_PLUGIN_SRC}
323323
cargo build ${CARGO_OPTS} --bin cln-bip353
324324

325325
ifneq ($(RUST),0)

0 commit comments

Comments
 (0)