Skip to content

Commit ddcdc4a

Browse files
committed
[LTR] Normalize rustc version
If you have a newer version of rustc installed (or no rustc installed) you'll end up with config changes for CONFIG_RUSTC_VERSION and CONFIG_RUSTC_LLVM_VERSION when you run this script. We use scripts/dummy-tools to normalize gcc and friends, but that doesn't apply to rustc. So create our own dummy rustc that always reports the same rustc version as in our current config and pass that to make as RUSTC when running olddefconfig. That way, local rustc version does not affect our configs during a rebase.
1 parent dee011c commit ddcdc4a

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

lt_rebase.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,34 @@ CIQ_CONFIG_PATH=ciq/configs
6464

6565
CONFIG_LIST=$(ls ${CIQ_CONFIG_PATH}/*.config)
6666

67+
# scripts/dummy-tools doesn't normalize the rustc
68+
# version. So create a quick dummy rustc script
69+
# to report the same version as our current normalized
70+
# config and pass that to make as RUSTC
71+
72+
# Create a temporary directory for the dummy rustc
73+
TMPDIR=$(mktemp -d)
74+
75+
# Create the dummy rustc that always reports the same version
76+
cat > "$TMPDIR/rustc" << 'EOF'
77+
#!/bin/sh
78+
case "$1" in
79+
--version|-vV)
80+
echo "rustc 1.76.0"
81+
echo "LLVM version: 17.0.6"
82+
;;
83+
*)
84+
;;
85+
esac
86+
EOF
87+
chmod +x "$TMPDIR/rustc"
88+
6789
for config in $CONFIG_LIST; do
6890
echo "Rebasing $config"
6991
if [[ $config == *"x86_64"* ]]; then
7092
echo "Rebasing x86_64 config"
7193
cp $config .config
72-
make ARCH=x86_64 CROSS_COMPILE=scripts/dummy-tools/ olddefconfig
94+
make ARCH=x86_64 CROSS_COMPILE=scripts/dummy-tools/ RUSTC=$TMPDIR/rustc olddefconfig
7395
CONFIG_DIFF=$(diff --ignore-matching-lines='^# Linux/x86_64' .config $config | wc -l)
7496
if [ $CONFIG_DIFF -eq 0 ]; then
7597
echo "No changes to x86_64 config"
@@ -81,7 +103,7 @@ for config in $CONFIG_LIST; do
81103
elif [[ $config == *"aarch64"* ]]; then
82104
echo "Rebaseing aarch64 config"
83105
cp $config .config
84-
make ARCH=arm64 CROSS_COMPILE=scripts/dummy-tools/ olddefconfig
106+
make ARCH=arm64 CROSS_COMPILE=scripts/dummy-tools/ RUSTC="$TMPDIR/rustc" olddefconfig
85107
CONFIG_DIFF=$(diff --ignore-matching-lines='^# Linux/arm64' .config $config | wc -l)
86108
if [ $CONFIG_DIFF -eq 0 ]; then
87109
echo "No changes to aarch64 config"
@@ -96,6 +118,8 @@ for config in $CONFIG_LIST; do
96118
fi
97119
done
98120

121+
rm -rf $TMPDIR
122+
99123
REPO_STATUS=$(git status -s)
100124
if [ ! -z "$REPO_STATUS" ]; then
101125
echo "Repository is not clean adding configs"

0 commit comments

Comments
 (0)