Merge remote-tracking branch 'origin/9' into snapshot

This commit is contained in:
Sylvestre Ledru 2019-10-20 19:04:30 +02:00
commit 5b35341a97
4 changed files with 96 additions and 5 deletions

7
debian/changelog vendored
View File

@ -126,6 +126,13 @@ llvm-toolchain-snapshot (1:10~svn366440-1~exp1) experimental; urgency=medium
-- Sylvestre Ledru <sylvestre@debian.org> Thu, 18 Jul 2019 18:58:32 +0200 -- Sylvestre Ledru <sylvestre@debian.org> Thu, 18 Jul 2019 18:58:32 +0200
llvm-toolchain-9 (1:9.0.0-2) unstable; urgency=medium
* polly, openmp & lldb aren't enabled for every platform
So, add to PROJECTS only when enabled
-- Sylvestre Ledru <sylvestre@debian.org> Sun, 20 Oct 2019 17:27:50 +0200
llvm-toolchain-9 (1:9.0.0-1) unstable; urgency=medium llvm-toolchain-9 (1:9.0.0-1) unstable; urgency=medium
* Repack to move to git * Repack to move to git

View File

@ -201,7 +201,7 @@ if ! ldd o 2>&1|grep -q libclang-cpp; then
echo "Didn't link against libclang-cpp$VERSION" echo "Didn't link against libclang-cpp$VERSION"
# exit 42 # exit 42
fi fi
./o > /dev/null #./o > /dev/null
# Check that the symlink is correct # Check that the symlink is correct
ls -al /usr/lib/llvm-$VERSION/lib/libclang-cpp.so.1 > /dev/null ls -al /usr/lib/llvm-$VERSION/lib/libclang-cpp.so.1 > /dev/null
@ -328,14 +328,20 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
__builtin_trap(); __builtin_trap();
return 0; return 0;
} }
EOF EOF
clang++-$VERSION -fsanitize=address -fsanitize-coverage=edge,trace-pc test_fuzzer.cc /usr/lib/llvm-$VERSION/lib/libFuzzer.a clang++-$VERSION -fsanitize=address -fsanitize-coverage=edge,trace-pc test_fuzzer.cc /usr/lib/llvm-$VERSION/lib/libFuzzer.a
if ! ./a.out 2>&1 | grep -q -E "(Test unit written|PreferSmall)"; then if ! ./a.out 2>&1 | grep -q -E "(Test unit written|PreferSmall)"; then
echo "fuzzer" echo "fuzzer failed"
exit 42 exit 42
fi fi
clang++-$VERSION -fsanitize=address,fuzzer test_fuzzer.cc
if ! ./a.out 2>&1 | grep -q "libFuzzer: deadly signal"; then
echo "fuzzer failed"
fi
echo 'int main(int argc, char **argv) { echo 'int main(int argc, char **argv) {
int *array = new int[100]; int *array = new int[100];
delete [] array; delete [] array;
@ -381,6 +387,79 @@ if ! grep -q "foo.cpp:3:3" foo.log; then
exit 42 exit 42
fi fi
# Example from https://github.com/google/fuzzing/blob/master/tutorial/libFuzzerTutorial.md
# coverage fuzzing
cat << EOF > StandaloneFuzzTargetMain.c
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size);
__attribute__((weak)) extern int LLVMFuzzerInitialize(int *argc, char ***argv);
int main(int argc, char **argv) {
fprintf(stderr, "StandaloneFuzzTargetMain: running %d inputs\n", argc - 1);
if (LLVMFuzzerInitialize)
LLVMFuzzerInitialize(&argc, &argv);
for (int i = 1; i < argc; i++) {
fprintf(stderr, "Running: %s\n", argv[i]);
FILE *f = fopen(argv[i], "r");
assert(f);
fseek(f, 0, SEEK_END);
size_t len = ftell(f);
fseek(f, 0, SEEK_SET);
unsigned char *buf = (unsigned char*)malloc(len);
size_t n_read = fread(buf, 1, len, f);
fclose(f);
assert(n_read == len);
LLVMFuzzerTestOneInput(buf, len);
free(buf);
fprintf(stderr, "Done: %s: (%zd bytes)\n", argv[i], n_read);
}
}
EOF
cat << EOF > fuzz_me.cc
#include <stdint.h>
#include <stddef.h>
bool FuzzMe(const uint8_t *Data, size_t DataSize) {
return DataSize >= 3 &&
Data[0] == 'F' &&
Data[1] == 'U' &&
Data[2] == 'Z' &&
Data[3] == 'Z';
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
FuzzMe(Data, Size);
return 0;
}
EOF
clang-9 -fprofile-instr-generate -fcoverage-mapping fuzz_me.cc StandaloneFuzzTargetMain.c
rm -rf CORPUS
mkdir -p CORPUS
echo -n A > CORPUS/A
./a.out CORPUS/*
if ! ./a.out CORPUS/* 2>&1 | grep -q "running 1 inputs"; then
echo "Coverage fuzzing failed"
exit 1
fi
llvm-profdata-$VERSION merge -sparse *.profraw -o default.profdata
llvm-cov-$VERSION show a.out -instr-profile=default.profdata -name=FuzzMe &> foo.log
if ! grep -q "return DataSize >= 3" foo.log; then
echo "llvm-cov didn't show the expected output in fuzzing"
exit 1
fi
echo -n FUZA > CORPUS/FUZA && ./a.out CORPUS/*
llvm-profdata-$VERSION merge -sparse *.profraw -o default.profdata
llvm-cov-$VERSION show a.out -instr-profile=default.profdata -name=FuzzMe &> foo.log
if ! grep -q "Data\[3\] == 'Z';" foo.log; then
echo "llvm-cov didn't show the expected output in fuzzing"
exit 1
fi
rm -rf CORPUS fuzz_me.cc StandaloneFuzzTargetMain.c
echo "Testing sanitizers ..." echo "Testing sanitizers ..."
echo '#include <stdlib.h> echo '#include <stdlib.h>

10
debian/rules vendored
View File

@ -1,6 +1,7 @@
#!/usr/bin/make -f #!/usr/bin/make -f
PROJECTS="clang;clang-tools-extra;libcxx;libcxxabi;lldb;compiler-rt;lld;polly;debuginfo-tests;openmp" # polly, openmp & lldb aren't enabled for every platform
PROJECTS="clang;clang-tools-extra;libcxx;libcxxabi;compiler-rt;lld;debuginfo-tests"
TARGET_BUILD := build-llvm TARGET_BUILD := build-llvm
TARGET_BUILD_STAGE2 := $(TARGET_BUILD)/tools/clang/stage2-bins TARGET_BUILD_STAGE2 := $(TARGET_BUILD)/tools/clang/stage2-bins
@ -175,12 +176,16 @@ BOOTSTRAP_CFLAGS_EXTRA = $(CFLAGS_EXTRA) # Nothing for now. Keeping in case w
POLLY_ENABLE=yes POLLY_ENABLE=yes
ifneq (,$(filter $(DEB_HOST_ARCH), powerpc powerpcspe)) ifneq (,$(filter $(DEB_HOST_ARCH), powerpc powerpcspe))
POLLY_ENABLE=no POLLY_ENABLE=no
else
PROJECTS += ";polly"
endif endif
# Enable openmp (or not) # Enable openmp (or not)
OPENMP_ENABLE=yes OPENMP_ENABLE=yes
ifneq (,$(filter $(DEB_HOST_ARCH), mips mipsel powerpc powerpcspe riscv64 sparc64 s390x x32)) ifneq (,$(filter $(DEB_HOST_ARCH), mips mipsel powerpc powerpcspe riscv64 sparc64 s390x x32))
OPENMP_ENABLE=no OPENMP_ENABLE=no
else
PROJECTS= += ";openmp"
endif endif
RUN_TEST=yes RUN_TEST=yes
@ -224,11 +229,12 @@ LLDB_DISABLE_ARCHS := hurd-i386 ia64 powerpc powerpcspe ppc64 riscv64 sparc64
# hurd has threading issues # hurd has threading issues
ifeq (,$(filter-out $(LLDB_DISABLE_ARCHS), $(DEB_HOST_ARCH))) ifeq (,$(filter-out $(LLDB_DISABLE_ARCHS), $(DEB_HOST_ARCH)))
# Disable LLDB for this arch. # Disable LLDB for this arch.
LLDB_ENABLE=no LLDB_ENABLE=no
else else
# See https://llvm.org/bugs/show_bug.cgi?id=28898 # See https://llvm.org/bugs/show_bug.cgi?id=28898
# Enable it again as it seems it is fixed upstream https://bugs.llvm.org/show_bug.cgi?id=35291 # Enable it again as it seems it is fixed upstream https://bugs.llvm.org/show_bug.cgi?id=35291
# CMAKE_EXTRA += -DLLDB_DISABLE_LIBEDIT=ON # CMAKE_EXTRA += -DLLDB_DISABLE_LIBEDIT=ON
PROJECTS += ";lldb"
endif endif
LLD_ENABLE=yes LLD_ENABLE=yes

1
debian/unpack.sh vendored
View File

@ -3,7 +3,6 @@ ORIG_VERSION=snapshot
MAJOR_VERSION=10 # 8.0.1 MAJOR_VERSION=10 # 8.0.1
REV=`ls -1 *${ORIG_VERSION}_${MAJOR_VERSION}*~+*xz | tail -1|perl -ne 'print "$1\n" if /~\+(.*)\.orig/;' | sort -ru` REV=`ls -1 *${ORIG_VERSION}_${MAJOR_VERSION}*~+*xz | tail -1|perl -ne 'print "$1\n" if /~\+(.*)\.orig/;' | sort -ru`
#SVN_REV=347285
VERSION=$REV VERSION=$REV
echo $VERSION echo $VERSION
#VERSION=+rc3 #VERSION=+rc3