2012-11-23 05:09:17 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# FIXME: do we need a license (or whatever else) header here?
|
|
|
|
|
|
|
|
# This script merges libsanitizer sources from upstream.
|
|
|
|
|
|
|
|
get_upstream() {
|
|
|
|
rm -rf upstream
|
2019-11-07 10:33:54 +01:00
|
|
|
git clone https://github.com/llvm/llvm-project.git upstream
|
2012-11-23 05:09:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
get_current_rev() {
|
|
|
|
cd upstream
|
2019-11-07 10:33:54 +01:00
|
|
|
git rev-parse HEAD
|
2012-11-23 05:09:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
list_files() {
|
2019-08-14 10:47:11 +02:00
|
|
|
(cd $1; ls *.{cc,cpp,h,inc,S} 2> /dev/null)
|
2012-11-23 05:09:17 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
change_comment_headers() {
|
|
|
|
for f in $(list_files $1); do
|
2017-01-24 01:18:36 +01:00
|
|
|
sed -n 3p $1/$f | grep -q 'The LLVM Compiler Infrastructure' || continue
|
2012-11-23 05:09:17 +01:00
|
|
|
changed=$(awk 'NR != 2 && NR != 3' < $1/$f)
|
|
|
|
echo "$changed" > $1/$f
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# ARGUMENTS: upstream_path local_path
|
|
|
|
# This function merges changes from the directory upstream_path to
|
|
|
|
# the directory local_path.
|
|
|
|
merge() {
|
2020-05-25 20:55:29 +02:00
|
|
|
upstream_path=upstream/compiler-rt/$1
|
2012-11-23 05:09:17 +01:00
|
|
|
local_path=$2
|
|
|
|
change_comment_headers $upstream_path
|
|
|
|
echo MERGE: $upstream_path
|
|
|
|
all=$( (list_files $upstream_path; list_files $local_path) | sort | uniq)
|
|
|
|
#echo $all
|
|
|
|
for f in $all; do
|
|
|
|
if [ -f $upstream_path/$f -a -f $local_path/$f ]; then
|
|
|
|
echo "FOUND IN BOTH :" $f
|
|
|
|
# diff -u $local_path/$f $upstream_path/$f
|
|
|
|
cp -v $upstream_path/$f $local_path
|
|
|
|
elif [ -f $upstream_path/$f ]; then
|
|
|
|
echo "FOUND IN UPSTREAM :" $f
|
2012-11-23 15:46:25 +01:00
|
|
|
cp -v $upstream_path/$f $local_path
|
2020-05-25 20:55:29 +02:00
|
|
|
git add $local_path/$f
|
2012-11-23 05:09:17 +01:00
|
|
|
elif [ -f $local_path/$f ]; then
|
|
|
|
echo "FOUND IN LOCAL :" $f
|
2020-05-25 20:55:29 +02:00
|
|
|
git rm $local_path/$f
|
2012-11-23 05:09:17 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fatal() {
|
|
|
|
echo "$1"
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
pwd | grep 'libsanitizer$' || \
|
|
|
|
fatal "Run this script from libsanitizer dir"
|
|
|
|
get_upstream
|
|
|
|
CUR_REV=$(get_current_rev)
|
|
|
|
echo Current upstream revision: $CUR_REV
|
|
|
|
merge include/sanitizer include/sanitizer
|
|
|
|
merge lib/asan asan
|
2013-11-04 22:33:31 +01:00
|
|
|
merge lib/lsan lsan
|
2012-11-23 15:46:25 +01:00
|
|
|
merge lib/tsan/rtl tsan
|
2012-11-23 05:09:17 +01:00
|
|
|
merge lib/sanitizer_common sanitizer_common
|
|
|
|
merge lib/interception interception
|
2013-08-30 18:12:58 +02:00
|
|
|
merge lib/ubsan ubsan
|
2020-11-13 17:06:48 +01:00
|
|
|
merge lib/hwasan hwasan
|
2012-11-23 05:09:17 +01:00
|
|
|
|
2016-11-08 23:04:09 +01:00
|
|
|
# Need to merge lib/builtins/assembly.h file:
|
|
|
|
mkdir -p builtins
|
2020-05-25 20:55:29 +02:00
|
|
|
cp -v upstream/compiler-rt/lib/builtins/assembly.h builtins/assembly.h
|
2016-11-08 23:04:09 +01:00
|
|
|
|
2012-11-23 05:09:17 +01:00
|
|
|
rm -rf upstream
|
|
|
|
|
|
|
|
# Update the MERGE file.
|
|
|
|
cat << EOF > MERGE
|
|
|
|
$CUR_REV
|
|
|
|
|
2019-11-07 10:33:54 +01:00
|
|
|
The first line of this file holds the git revision number of the
|
2012-11-23 05:09:17 +01:00
|
|
|
last merge done from the master library sources.
|
|
|
|
EOF
|