Skip to content

Instantly share code, notes, and snippets.

@siddhesh
Created January 12, 2022 03:43
Show Gist options
  • Save siddhesh/8a900d4abc0218eed18ba01fbd3b2c25 to your computer and use it in GitHub Desktop.
Save siddhesh/8a900d4abc0218eed18ba01fbd3b2c25 to your computer and use it in GitHub Desktop.
Helper script to build a branch+target combination for gcc.
#!/bin/bash
worktree_root=PATH_TO/gcc-worktrees
gcc_root=$worktree_root/gcc
if [ -z $1 ]; then
echo "Usage: $0 <git commit ref> [target]"
exit 1
fi
ref=$1
if [ -z $2 ]; then
target="x86_64"
else
target="$2"
fi
case "$target" in
i686)
config="--enable-clocale=gnu --with-system-zlib --enable-shared --enable-cet --with-demangler-in-ld --enable-libmpx i686-linux --with-fpmath=sse --disable-bootstrap"
runtest=true
;;
ubsan)
config="--with-build-config=bootstrap-ubsan --enable-languages=c,c++ --disable-multilib --enable-shared"
runtest=false
;;
*)
config="--enable-bootstrap"
runtest=true
;;
esac
pushd $gcc_root
worktree_path=$worktree_root/$ref-$target
rm -rf $worktree_path
git worktree add -b $ref-$target $worktree_path $ref
pushd $worktree_path
mkdir build && cd build
../configure $config && \
make -j$(nproc) > /dev/null && $runtest && \
make -j$(nproc) check > $worktree_root/check-$ref-$target.out 2>&1
popd # $worktree_path
popd # $gcc_root
#git worktree remove --force $worktree_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment