Skip to content

Commit a08c023

Browse files
committed
Don't pass 'embed-bitcode'/'lto' while building proc-macros
cargo is usually good about not passing `RUSTFLAGS` to build-time dependencies which need to be built for the host platform rather than the target platform, but for some reason it does not do so for `proc-macro` crates. Thus, we have to manually drop the `embed-bitcode` and `lto` arguments when calling rustc in our existing rustc wrapper.
1 parent 636543d commit a08c023

File tree

1 file changed

+19
-2
lines changed
  • deterministic-build-wrappers

1 file changed

+19
-2
lines changed

deterministic-build-wrappers/rustc

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@
77
# ever (indirectly) depend on multiple versions of the same crate.
88
args=("$@")
99
IS_LIGHTNING=false
10+
SKIP_EMBED_BITCODE=false
1011
for ((i=0; i<"${#args[@]}"; ++i)); do
1112
case ${args[i]} in
1213
--crate-name)
13-
if [ "${args[i+1]}" = "lightning" -o "${args[i+1]}" = "lightning_background_processor" -o "${args[i+1]}" = "lightning_invoice" -o "${args[i+1]}" = "lightning_persister" -o "${args[i+1]}" = "lightning_rapid_gossip_sync" -o "${args[i+1]}" = "ldk" ]; then
14+
if [ "${args[i+1]}" = "lightning" -o "${args[i+1]}" = "lightning_background_processor" -o "${args[i+1]}" = "lightning_invoice" -o "${args[i+1]}" = "lightning_persister" -o "${args[i+1]}" = "lightning_rapid_gossip_sync" -o "${args[i+1]}" = "lightning_transaction_sync" -o "${args[i+1]}" = "ldk" ]; then
1415
IS_LIGHTNING=true
1516
fi
1617
;;
18+
--crate-type)
19+
if [ "${args[i+1]}" = "proc-macro" ]; then
20+
# If we're building a proc-macro, rustc incorrectly passes our RUSTFLAGS containing
21+
# embed-bitcode=yes, which we don't want.
22+
SKIP_EMBED_BITCODE=true
23+
fi
24+
;;
1725
esac
1826
done
1927
for ((i=0; i<"${#args[@]}"; ++i)); do
@@ -24,7 +32,16 @@ for ((i=0; i<"${#args[@]}"; ++i)); do
2432
args[i]="metadata=42"
2533
fi
2634
;;
35+
embed-bitcode=yes)
36+
if [ "$SKIP_EMBED_BITCODE" = "true" ]; then
37+
args[i]="embed-bitcode=no"
38+
fi
39+
;;
40+
lto)
41+
if [ "$SKIP_EMBED_BITCODE" = "true" ]; then
42+
args[i]="lto=no"
43+
fi
44+
;;
2745
esac
2846
done
29-
3047
$LDK_RUSTC_PATH "${args[@]}"

0 commit comments

Comments
 (0)