From ace867c06eb772f23c4ca3e7cc15e1637ec47ba8 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 7 Feb 2019 10:08:05 +0100 Subject: [PATCH 01/11] Only run this test with clang-7 --- debian/qualify-clang.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index 93e5b973..3d2bff57 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -383,9 +383,10 @@ echo 'int main() { ' > foo.c clang-$VERSION -g -o bar foo.c -# ABI issue between gcc & clang +# ABI issue between gcc & clang with clang 7 # https://bugs.llvm.org/show_bug.cgi?id=39427 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=913271 +if test $VERSION -eq 7; then echo ' #include #include @@ -427,6 +428,7 @@ if test -f /usr/bin/g++; then ./foo fi rm part1.o part2.o +fi if test ! -f /usr/lib/llvm-$VERSION/lib/libomp.so; then echo "Install libomp-$VERSION-dev"; From 9972814cca3e270fe6fd41d675874a2184f4a12c Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 7 Feb 2019 10:08:26 +0100 Subject: [PATCH 02/11] add a test case which failed with clang-9 --- debian/qualify-clang.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index 3d2bff57..115fe3bf 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -366,6 +366,33 @@ int main(int argc, char **argv) clang-$VERSION -fsanitize=address foo.c -o foo -lc ./foo &> /dev/null || true + +echo ' +class a { +public: + ~a(); +}; +template using b = a; +struct f { + template using e = b; +}; +struct g { + typedef f::e c; +}; +class h { + struct : g::c {}; +}; +struct m { + h i; +}; +template void __attribute__((noreturn)) j(); +void k() { + m l; + j(); +}' > foo.cpp +clang++-$VERSION -std=c++14 -O3 -fsanitize=address -fsanitize=undefined -c foo.cpp -fno-crash-diagnostics + + # fails on 32 bit, seems a real BUG in the package, using 64bit static libs? LANG=C clang-$VERSION -fsanitize=fuzzer test_fuzzer.cc &> foo.log || true if ! grep "No such file or directory" foo.log; then From c17b260032ea0c3d4370ef4fbd6f0eb209ee91d5 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 7 Feb 2019 17:10:23 +0100 Subject: [PATCH 03/11] new rc release --- debian/changelog | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index eed564e2..a3c11d5b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,10 @@ -llvm-toolchain-8 (1:8~+rc1-1~exp2) UNRELEASED; urgency=medium +llvm-toolchain-8 (1:8~+rc2-1~exp1) UNRELEASED; urgency=medium * Add support for kfreebsd (Closes: #921246) Many thanks to Svante Signell for all patches + * experimental New snapshot release - -- Sylvestre Ledru Mon, 04 Feb 2019 23:38:37 +0100 + -- Sylvestre Ledru Thu, 07 Feb 2019 17:09:15 +0100 llvm-toolchain-8 (1:8~+rc1-1~exp1) experimental; urgency=medium From 393f88fe8ee016d1d4223af04d30766053b3c77e Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 7 Feb 2019 18:02:00 +0100 Subject: [PATCH 04/11] rebase of the patch --- debian/patches/kfreebsd/compiler-rt_lib.diff | 300 +++--------------- .../kfreebsd/kfreebsd-triple-clang.diff | 66 ++-- 2 files changed, 88 insertions(+), 278 deletions(-) diff --git a/debian/patches/kfreebsd/compiler-rt_lib.diff b/debian/patches/kfreebsd/compiler-rt_lib.diff index ca23c353..726f1821 100644 --- a/debian/patches/kfreebsd/compiler-rt_lib.diff +++ b/debian/patches/kfreebsd/compiler-rt_lib.diff @@ -1,7 +1,7 @@ -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc @@ -84,9 +84,14 @@ extern "C" { // must be included after and on @@ -44,10 +44,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_linux. char *base = (char *)map->l_addr; Elf_Ehdr *ehdr = (Elf_Ehdr *)base; char *phdrs = base + ehdr->e_phoff; -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc @@ -36,10 +36,12 @@ #include @@ -75,10 +75,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_linux_ #define Elf_Phdr XElf32_Phdr #define dl_phdr_info xdl_phdr_info #define dl_iterate_phdr(c, b) xdl_iterate_phdr((c), (b)) -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_platform.h +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_platform.h =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/sanitizer_common/sanitizer_platform.h -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_platform.h +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/sanitizer_common/sanitizer_platform.h ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_platform.h @@ -16,7 +16,7 @@ #if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \ !defined(__OpenBSD__) && !defined(__APPLE__) && !defined(_WIN32) && \ @@ -118,192 +118,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_platfo #if __LP64__ || defined(_WIN64) # define SANITIZER_WORDSIZE 64 -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/asan/asan_linux.cc =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc -@@ -50,7 +50,7 @@ - #include - #endif - --#if !SANITIZER_IOS -+#if !SANITIZER_IOS && !SANITIZER_KFREEBSD - #include - #endif - -@@ -109,7 +109,11 @@ typedef struct user_fpregs elf_fpregset_ - #if SANITIZER_LINUX && !SANITIZER_ANDROID - #include - #include --#include -+#if SANITIZER_KFREEBSD -+# include -+#else -+# include -+#endif - #include - #include - #include -@@ -146,6 +150,12 @@ typedef struct user_fpregs elf_fpregset_ - #include - #endif - -+#if SANITIZER_KFREEBSD -+# include -+#else -+# include -+#endif -+ - #if SANITIZER_LINUX - #include - #include -@@ -256,7 +266,7 @@ namespace __sanitizer { - #endif - - --#if SANITIZER_LINUX && !SANITIZER_ANDROID -+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_KFREEBSD - unsigned struct_shminfo_sz = sizeof(struct shminfo); - unsigned struct_shm_info_sz = sizeof(struct shm_info); - int shmctl_ipc_stat = (int)IPC_STAT; -@@ -286,7 +296,7 @@ namespace __sanitizer { - return 0; - } - --#if SANITIZER_LINUX -+#if SANITIZER_LINUX || SANITIZER_KFREEBSD - unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr)); - #elif SANITIZER_FREEBSD - unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); -@@ -466,7 +476,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El - unsigned struct_ppp_stats_sz = sizeof(struct ppp_stats); - #endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID - --#if !SANITIZER_ANDROID && !SANITIZER_MAC -+#if !SANITIZER_ANDROID && !SANITIZER_MAC && !SANITIZER_KFREEBSD - unsigned struct_sioc_sg_req_sz = sizeof(struct sioc_sg_req); - unsigned struct_sioc_vif_req_sz = sizeof(struct sioc_vif_req); - #endif -@@ -519,7 +529,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El - unsigned IOCTL_TIOCSPGRP = TIOCSPGRP; - unsigned IOCTL_TIOCSTI = TIOCSTI; - unsigned IOCTL_TIOCSWINSZ = TIOCSWINSZ; --#if SANITIZER_LINUX && !SANITIZER_ANDROID -+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_KFREEBSD - unsigned IOCTL_SIOCGETSGCNT = SIOCGETSGCNT; - unsigned IOCTL_SIOCGETVIFCNT = SIOCGETVIFCNT; - #endif -@@ -958,7 +968,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi - CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum); - #endif // SANITIZER_LINUX || SANITIZER_FREEBSD - --#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID -+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_KFREEBSD - CHECK_TYPE_SIZE(glob_t); - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc); - CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv); -@@ -978,8 +988,10 @@ CHECK_SIZE_AND_OFFSET(addrinfo, ai_sockt - CHECK_SIZE_AND_OFFSET(addrinfo, ai_protocol); - CHECK_SIZE_AND_OFFSET(addrinfo, ai_protocol); - CHECK_SIZE_AND_OFFSET(addrinfo, ai_addrlen); -+#if !SANITIZER_KFREEBSD - CHECK_SIZE_AND_OFFSET(addrinfo, ai_canonname); - CHECK_SIZE_AND_OFFSET(addrinfo, ai_addr); -+#endif - - CHECK_TYPE_SIZE(hostent); - CHECK_SIZE_AND_OFFSET(hostent, h_name); -@@ -1001,7 +1013,9 @@ CHECK_SIZE_AND_OFFSET(msghdr, msg_contro - CHECK_SIZE_AND_OFFSET(msghdr, msg_controllen); - CHECK_SIZE_AND_OFFSET(msghdr, msg_flags); - -+#if !SANITIZER_KFREEBSD - CHECK_TYPE_SIZE(cmsghdr); -+#endif - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len); - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level); - CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type); -@@ -1043,7 +1057,9 @@ CHECK_SIZE_AND_OFFSET(pollfd, fd); - CHECK_SIZE_AND_OFFSET(pollfd, events); - CHECK_SIZE_AND_OFFSET(pollfd, revents); - -+#if !SANITIZER_KFREEBSD - CHECK_TYPE_SIZE(nfds_t); -+#endif - - CHECK_TYPE_SIZE(sigset_t); - -@@ -1083,7 +1099,9 @@ CHECK_TYPE_SIZE(__kernel_fd_set); - #endif - - #if !SANITIZER_ANDROID -+# if !SANITIZER_KFREEBSD - CHECK_TYPE_SIZE(wordexp_t); -+# endif - CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordc); - CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordv); - CHECK_SIZE_AND_OFFSET(wordexp_t, we_offs); -@@ -1116,13 +1134,14 @@ CHECK_TYPE_SIZE(ether_addr); - - #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID - CHECK_TYPE_SIZE(ipc_perm); --# if SANITIZER_FREEBSD -+#if SANITIZER_FREEBSD && !SANITIZER_KFREEBSD - CHECK_SIZE_AND_OFFSET(ipc_perm, key); - CHECK_SIZE_AND_OFFSET(ipc_perm, seq); --# else -+#endif -+#if !SANITIZER_FREEBSD && !SANITIZER_KFREEBSD - CHECK_SIZE_AND_OFFSET(ipc_perm, __key); - CHECK_SIZE_AND_OFFSET(ipc_perm, __seq); --# endif -+#endif - CHECK_SIZE_AND_OFFSET(ipc_perm, uid); - CHECK_SIZE_AND_OFFSET(ipc_perm, gid); - CHECK_SIZE_AND_OFFSET(ipc_perm, cuid); -@@ -1161,7 +1180,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_netma - #ifdef ifa_dstaddr - #undef ifa_dstaddr - #endif --# if SANITIZER_FREEBSD -+# if SANITIZER_FREEBSD && !SANITIZER_KFREEBSD - CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr); - # else - COMPILER_CHECK(sizeof(((__sanitizer_ifaddrs *)nullptr)->ifa_dstaddr) == -@@ -1187,15 +1206,19 @@ CHECK_SIZE_AND_OFFSET(timeb, timezone); - CHECK_SIZE_AND_OFFSET(timeb, dstflag); - #endif - -+#if !SANITIZER_KFREEBSD - CHECK_TYPE_SIZE(passwd); -+#endif - CHECK_SIZE_AND_OFFSET(passwd, pw_name); - CHECK_SIZE_AND_OFFSET(passwd, pw_passwd); - CHECK_SIZE_AND_OFFSET(passwd, pw_uid); - CHECK_SIZE_AND_OFFSET(passwd, pw_gid); -+#if !SANITIZER_KFREEBSD - CHECK_SIZE_AND_OFFSET(passwd, pw_dir); - CHECK_SIZE_AND_OFFSET(passwd, pw_shell); -+#endif - --#if !SANITIZER_ANDROID -+#if !SANITIZER_ANDROID && !SANITIZER_KFREEBSD - CHECK_SIZE_AND_OFFSET(passwd, pw_gecos); - #endif - -@@ -1261,7 +1284,7 @@ CHECK_SIZE_AND_OFFSET(cookie_io_function - CHECK_SIZE_AND_OFFSET(cookie_io_functions_t, close); - #endif - --#if SANITIZER_LINUX || SANITIZER_FREEBSD -+#if SANITIZER_LINUX || (SANITIZER_FREEBSD && !SANITIZER_KFREEBSD) - CHECK_TYPE_SIZE(sem_t); - #endif - -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/asan/asan_linux.cc -=================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/asan/asan_linux.cc -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/asan/asan_linux.cc +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/asan/asan_linux.cc ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/asan/asan_linux.cc @@ -38,7 +38,7 @@ #include #include @@ -334,10 +152,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/asan/asan_linux.cc #define ucontext_t xucontext_t #endif -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/ubsan/ubsan_platform.h +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/ubsan/ubsan_platform.h =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/ubsan/ubsan_platform.h -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/ubsan/ubsan_platform.h +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/ubsan/ubsan_platform.h ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/ubsan/ubsan_platform.h @@ -15,7 +15,7 @@ // Other platforms should be easy to add, and probably work as-is. @@ -347,10 +165,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/ubsan/ubsan_platform.h (defined(__sun__) && defined(__svr4__)) || \ defined(_WIN32) || defined(__Fuchsia__) || defined(__rtems__) # define CAN_SANITIZE_UB 1 -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S @@ -197,7 +197,7 @@ ASM_SYMBOL_INTERCEPTOR(setjmp): lea 16(%rsp), %rdi mov %rdi, %rsi @@ -387,10 +205,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S /* We do not need executable stack. */ /* This note is not needed on NetBSD. */ .section .note.GNU-stack,"",@progbits -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerDefs.h +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/fuzzer/FuzzerDefs.h =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/fuzzer/FuzzerDefs.h -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerDefs.h +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/fuzzer/FuzzerDefs.h ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/fuzzer/FuzzerDefs.h @@ -28,6 +28,7 @@ #define LIBFUZZER_LINUX 1 #define LIBFUZZER_NETBSD 0 @@ -424,10 +242,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerDefs.h #ifdef __x86_64 # if __has_attribute(target) -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp @@ -119,7 +119,7 @@ size_t GetPeakRSSMb() { if (getrusage(RUSAGE_SELF, &usage)) return 0; @@ -437,10 +255,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp // ru_maxrss is in KiB return usage.ru_maxrss >> 10; } else if (LIBFUZZER_APPLE) { -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp @@ -12,7 +12,7 @@ #include "FuzzerDefs.h" @@ -450,10 +268,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp __attribute__((weak)) extern uint8_t __start___libfuzzer_extra_counters; __attribute__((weak)) extern uint8_t __stop___libfuzzer_extra_counters; -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp @@ -14,7 +14,7 @@ //===----------------------------------------------------------------------===// #include "FuzzerDefs.h" @@ -463,10 +281,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp #include "FuzzerExtFunctions.h" #include "FuzzerIO.h" -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// #include "FuzzerDefs.h" @@ -476,10 +294,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp #include "FuzzerCommand.h" #include -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_freebsd.h +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_freebsd.h =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/sanitizer_common/sanitizer_freebsd.h -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_freebsd.h +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/sanitizer_common/sanitizer_freebsd.h ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_freebsd.h @@ -21,7 +21,7 @@ // 32-bit mode. #if SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32) @@ -489,10 +307,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_freebs # include # include # include -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cc +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cc =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cc -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cc +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cc ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cc @@ -38,7 +38,7 @@ // Fix 'kinfo_vmentry' definition on FreeBSD prior v9.2 in 32-bit mode. #if SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32) @@ -502,10 +320,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_procma #define kinfo_vmentry xkinfo_vmentry #endif #endif -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -20,7 +20,9 @@ #include "sanitizer_internal_defs.h" #include "sanitizer_platform.h" @@ -516,10 +334,10 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_platfo #ifndef __GLIBC_PREREQ #define __GLIBC_PREREQ(x, y) 0 -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc +Index: llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc +--- llvm-toolchain-8_8~+rc2.orig/compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc ++++ llvm-toolchain-8_8~+rc2/compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc @@ -20,7 +20,7 @@ # define SYSCALL(name) __NR_ ## name #endif @@ -529,31 +347,3 @@ Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_syscal # define internal_syscall __syscall # else # define internal_syscall syscall -Index: llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc -=================================================================== ---- llvm-toolchain-8-8~+rc1.orig/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc -+++ llvm-toolchain-8-8~+rc1/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc -@@ -110,9 +110,9 @@ typedef struct user_fpregs elf_fpregset_ - #include - #include - #if SANITIZER_KFREEBSD --# include --#else - # include -+#else -+# include - #endif - #include - #include -@@ -151,9 +151,9 @@ typedef struct user_fpregs elf_fpregset_ - #endif - - #if SANITIZER_KFREEBSD --# include --#else - # include -+#else -+# include - #endif - - #if SANITIZER_LINUX diff --git a/debian/patches/kfreebsd/kfreebsd-triple-clang.diff b/debian/patches/kfreebsd/kfreebsd-triple-clang.diff index cd24440f..c848440e 100644 --- a/debian/patches/kfreebsd/kfreebsd-triple-clang.diff +++ b/debian/patches/kfreebsd/kfreebsd-triple-clang.diff @@ -1,7 +1,7 @@ -Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/CMakeLists.txt +Index: llvm-toolchain-8_8~+rc2/clang/lib/Driver/CMakeLists.txt =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/clang/lib/Driver/CMakeLists.txt -+++ llvm-toolchain-8-8~+rc1/clang/lib/Driver/CMakeLists.txt +--- llvm-toolchain-8_8~+rc2.orig/clang/lib/Driver/CMakeLists.txt ++++ llvm-toolchain-8_8~+rc2/clang/lib/Driver/CMakeLists.txt @@ -49,6 +49,7 @@ add_clang_library(clangDriver ToolChains/HIP.cpp ToolChains/Hexagon.cpp @@ -10,10 +10,10 @@ Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/CMakeLists.txt ToolChains/Linux.cpp ToolChains/MipsLinux.cpp ToolChains/MinGW.cpp -Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/Driver.cpp +Index: llvm-toolchain-8_8~+rc2/clang/lib/Driver/Driver.cpp =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/clang/lib/Driver/Driver.cpp -+++ llvm-toolchain-8-8~+rc1/clang/lib/Driver/Driver.cpp +--- llvm-toolchain-8_8~+rc2.orig/clang/lib/Driver/Driver.cpp ++++ llvm-toolchain-8_8~+rc2/clang/lib/Driver/Driver.cpp @@ -27,6 +27,7 @@ #include "ToolChains/Haiku.h" #include "ToolChains/Hexagon.h" @@ -32,10 +32,10 @@ Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/Driver.cpp case llvm::Triple::Minix: TC = llvm::make_unique(*this, Target, Args); break; -Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/Clang.cpp +Index: llvm-toolchain-8_8~+rc2/clang/lib/Driver/ToolChains/Clang.cpp =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/clang/lib/Driver/ToolChains/Clang.cpp -+++ llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/Clang.cpp +--- llvm-toolchain-8_8~+rc2.orig/clang/lib/Driver/ToolChains/Clang.cpp ++++ llvm-toolchain-8_8~+rc2/clang/lib/Driver/ToolChains/Clang.cpp @@ -535,7 +535,7 @@ static bool useFramePointerForTargetByDe } @@ -45,11 +45,29 @@ Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/Clang.cpp switch (Triple.getArch()) { // Don't use a frame pointer on linux if optimizing for certain targets. case llvm::Triple::mips64: -Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/Gnu.cpp +Index: llvm-toolchain-8_8~+rc2/clang/lib/Driver/ToolChains/Gnu.cpp =================================================================== ---- llvm-toolchain-8-8~+rc1.orig/clang/lib/Driver/ToolChains/Gnu.cpp -+++ llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/Gnu.cpp -@@ -522,6 +522,18 @@ void tools::gnutools::Linker::ConstructJ +--- llvm-toolchain-8_8~+rc2.orig/clang/lib/Driver/ToolChains/Gnu.cpp ++++ llvm-toolchain-8_8~+rc2/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -259,6 +259,8 @@ static const char *getLDMOption(const ll + case llvm::Triple::x86: + if (T.isOSIAMCU()) + return "elf_iamcu"; ++ if (T.isOSkFreeBSD()) ++ return "elf_i386_fbsd"; + return "elf_i386"; + case llvm::Triple::aarch64: + return "aarch64linux"; +@@ -303,6 +305,8 @@ static const char *getLDMOption(const ll + case llvm::Triple::x86_64: + if (T.getEnvironment() == llvm::Triple::GNUX32) + return "elf32_x86_64"; ++ if (T.isOSkFreeBSD()) ++ return "elf_x86_64_fbsd"; + return "elf_x86_64"; + default: + return nullptr; +@@ -522,6 +526,18 @@ void tools::gnutools::Linker::ConstructJ CmdArgs.push_back("--wrap=pthread_create"); CmdArgs.push_back("-lc"); @@ -68,7 +86,7 @@ Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/Gnu.cpp // Add IAMCU specific libs, if needed. if (IsIAMCU) -@@ -1898,7 +1910,8 @@ void Generic_GCC::GCCInstallationDetecto +@@ -1898,7 +1914,8 @@ void Generic_GCC::GCCInstallationDetecto "x86_64-redhat-linux", "x86_64-suse-linux", "x86_64-manbo-linux-gnu", "x86_64-linux-gnu", "x86_64-slackware-linux", "x86_64-unknown-linux", @@ -78,19 +96,21 @@ Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/Gnu.cpp static const char *const X32LibDirs[] = {"/libx32"}; static const char *const X86LibDirs[] = {"/lib32", "/lib"}; static const char *const X86Triples[] = { -@@ -1907,6 +1920,8 @@ void Generic_GCC::GCCInstallationDetecto +@@ -1907,7 +1924,9 @@ void Generic_GCC::GCCInstallationDetecto "i586-redhat-linux", "i386-redhat-linux", "i586-suse-linux", "i486-slackware-linux", "i686-montavista-linux", "i586-linux-gnu", "i686-linux-android", "i386-gnu", "i486-gnu", -+ "i686-kfreebsd-gnu", "i686-pc-kfreebsd-gnu", "i486-kfreebsd-gnu", -+ "i386-kfreebsd-gnu", - "i586-gnu", "i686-gnu"}; +- "i586-gnu", "i686-gnu"}; ++ "i586-gnu", "i686-gnu", ++ "i686-kfreebsd-gnu", "i686-pc-kfreebsd-gnu", "i486-kfreebsd-gnu", ++ "i386-kfreebsd-gnu" }; static const char *const MIPSLibDirs[] = {"/lib"}; -Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/KFreeBSD.cpp + static const char *const MIPSTriples[] = { +Index: llvm-toolchain-8_8~+rc2/clang/lib/Driver/ToolChains/KFreeBSD.cpp =================================================================== --- /dev/null -+++ llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/KFreeBSD.cpp ++++ llvm-toolchain-8_8~+rc2/clang/lib/Driver/ToolChains/KFreeBSD.cpp @@ -0,0 +1,459 @@ +//===--- KFreeBSD.cpp - kFreeBSD ToolChain Implementations --------*- C++ -*-===// +// @@ -103,6 +123,7 @@ Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/KFreeBSD.cpp + +#include "KFreeBSD.h" +#include "CommonArgs.h" ++#include "clang/Basic/VirtualFileSystem.h" +#include "clang/Config/config.h" +#include "clang/Driver/Driver.h" +#include "clang/Driver/Options.h" @@ -110,7 +131,6 @@ Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/KFreeBSD.cpp +#include "llvm/Option/ArgList.h" +#include "llvm/ProfileData/InstrProf.h" +#include "llvm/Support/Path.h" -+#include "llvm/Support/VirtualFileSystem.h" + +using namespace clang::driver; +using namespace clang::driver::toolchains; @@ -551,10 +571,10 @@ Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/KFreeBSD.cpp + return Res; +} + -Index: llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/KFreeBSD.h +Index: llvm-toolchain-8_8~+rc2/clang/lib/Driver/ToolChains/KFreeBSD.h =================================================================== --- /dev/null -+++ llvm-toolchain-8-8~+rc1/clang/lib/Driver/ToolChains/KFreeBSD.h ++++ llvm-toolchain-8_8~+rc2/clang/lib/Driver/ToolChains/KFreeBSD.h @@ -0,0 +1,54 @@ +//===--- KFreeBSD.h - kFreeBSD ToolChain Implementations ----------*- C++ -*-===// +// From e171407e959278e33097ce5aa85fa3ba1ddb4805 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 7 Feb 2019 22:44:40 +0100 Subject: [PATCH 05/11] vfs path --- debian/patches/kfreebsd/vfs.diff | 464 +++++++++++++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 465 insertions(+) create mode 100644 debian/patches/kfreebsd/vfs.diff diff --git a/debian/patches/kfreebsd/vfs.diff b/debian/patches/kfreebsd/vfs.diff new file mode 100644 index 00000000..c95665fb --- /dev/null +++ b/debian/patches/kfreebsd/vfs.diff @@ -0,0 +1,464 @@ +Index: llvm-toolchain-8-8~+rc2/home/sylvestre/dev/debian/pkg-llvm/llvm-toolchain/branches/llvm-toolchain-8-8~+rc2/tools/clang/lib/Driver/ToolChains/KFreeBSD.cpp +=================================================================== +--- llvm-toolchain-8-8~+rc2.orig/home/sylvestre/dev/debian/pkg-llvm/llvm-toolchain/branches/llvm-toolchain-8-8~+rc2/tools/clang/lib/Driver/ToolChains/KFreeBSD.cpp ++++ /dev/null +@@ -1,459 +0,0 @@ +-//===--- KFreeBSD.cpp - kFreeBSD ToolChain Implementations --------*- C++ -*-===// +-// +-// The LLVM Compiler Infrastructure +-// +-// This file is distributed under the University of Illinois Open Source +-// License. See LICENSE.TXT for details. +-// +-//===----------------------------------------------------------------------===// +- +-#include "KFreeBSD.h" +-#include "CommonArgs.h" +-#include "clang/Basic/VirtualFileSystem.h" +-#include "clang/Config/config.h" +-#include "clang/Driver/Driver.h" +-#include "clang/Driver/Options.h" +-#include "clang/Driver/SanitizerArgs.h" +-#include "llvm/Option/ArgList.h" +-#include "llvm/ProfileData/InstrProf.h" +-#include "llvm/Support/Path.h" +- +-using namespace clang::driver; +-using namespace clang::driver::toolchains; +-using namespace clang; +-using namespace llvm::opt; +- +-using tools::addPathIfExists; +- +-/// Get our best guess at the multiarch triple for a target. +-/// +-/// Debian-based systems are starting to use a multiarch setup where they use +-/// a target-triple directory in the library and header search paths. +-/// Unfortunately, this triple does not align with the vanilla target triple, +-/// so we provide a rough mapping here. +-static std::string getMultiarchTriple(const Driver &D, +- const llvm::Triple &TargetTriple, +- StringRef SysRoot) { +- // For most architectures, just use whatever we have rather than trying to be +- // clever. +- switch (TargetTriple.getArch()) { +- default: +- break; +- +- // We use the existence of '/lib/' as a directory to detect +- // some common kfreebsd triples that don't quite match the Clang +- // triple for both 32-bit and 64-bit targets. Multiarch fixes its +- // install triples to these regardless of what the actual target +- // triple is. +- case llvm::Triple::x86_64: +- if (D.getVFS().exists(SysRoot + "/lib/x86_64-kfreebsd-gnu")) +- return "x86_64-kfreebsd-gnu"; +- break; +- case llvm::Triple::x86: +- if (D.getVFS().exists(SysRoot + "/lib/i386-kfreebsd-gnu")) +- return "i386-kfreebsd-gnu"; +- break; +- } +- +- return TargetTriple.str(); +-} +- +-static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) { +- // It happens that only x86 and PPC use the 'lib32' variant of oslibdir, and +- // using that variant while targeting other architectures causes problems +- // because the libraries are laid out in shared system roots that can't cope +- // with a 'lib32' library search path being considered. So we only enable +- // them when we know we may need it. +- // +- // FIXME: This is a bit of a hack. We should really unify this code for +- // reasoning about oslibdir spellings with the lib dir spellings in the +- // GCCInstallationDetector, but that is a more significant refactoring. +- +- if (Triple.getArch() == llvm::Triple::x86) +- return "lib"; +- +- if (Triple.getArch() == llvm::Triple::x86_64) +- return "lib"; +- +- return Triple.isArch32Bit() ? "lib" : "lib64"; +-} +- +-static void addMultilibsFilePaths(const Driver &D, const MultilibSet &Multilibs, +- const Multilib &Multilib, +- StringRef InstallPath, +- ToolChain::path_list &Paths) { +- if (const auto &PathsCallback = Multilibs.filePathsCallback()) +- for (const auto &Path : PathsCallback(Multilib)) +- addPathIfExists(D, InstallPath + Path, Paths); +-} +- +-kFreeBSD::kFreeBSD(const Driver &D, const llvm::Triple &Triple, +- const ArgList &Args) +- : Generic_ELF(D, Triple, Args) { +- GCCInstallation.init(Triple, Args); +- Multilibs = GCCInstallation.getMultilibs(); +- std::string SysRoot = computeSysRoot(); +- +- // Cross-compiling binutils and GCC installations (vanilla and openSUSE at +- // least) put various tools in a triple-prefixed directory off of the parent +- // of the GCC installation. We use the GCC triple here to ensure that we end +- // up with tools that support the same amount of cross compiling as the +- // detected GCC installation. For example, if we find a GCC installation +- // targeting x86_64, but it is a bi-arch GCC installation, it can also be +- // used to target i386. +- // FIXME: This seems unlikely to be Linux-, kFreeBSD- or Hurd-specific. +- ToolChain::path_list &PPaths = getProgramPaths(); +- PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" + +- GCCInstallation.getTriple().str() + "/bin") +- .str()); +- +-#ifdef ENABLE_LINKER_BUILD_ID +- ExtraOpts.push_back("--build-id"); +-#endif +- +- // The selection of paths to try here is designed to match the patterns which +- // the GCC driver itself uses, as this is part of the GCC-compatible driver. +- // This was determined by running GCC in a fake filesystem, creating all +- // possible permutations of these directories, and seeing which ones it added +- // to the link paths. +- path_list &Paths = getFilePaths(); +- +- const std::string OSLibDir = getOSLibDir(Triple, Args); +- const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot); +- +- // Add the multilib suffixed paths where they are available. +- if (GCCInstallation.isValid()) { +- const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); +- const std::string &LibPath = GCCInstallation.getParentLibPath(); +- const Multilib &Multilib = GCCInstallation.getMultilib(); +- const MultilibSet &Multilibs = GCCInstallation.getMultilibs(); +- +- // Add toolchain / multilib specific file paths. +- addMultilibsFilePaths(D, Multilibs, Multilib, +- GCCInstallation.getInstallPath(), Paths); +- +- // Sourcery CodeBench MIPS toolchain holds some libraries under +- // a biarch-like suffix of the GCC installation. +- addPathIfExists(D, GCCInstallation.getInstallPath() + Multilib.gccSuffix(), +- Paths); +- +- // GCC cross compiling toolchains will install target libraries which ship +- // as part of the toolchain under // rather than as +- // any part of the GCC installation in +- // //gcc//. This decision is somewhat +- // debatable, but is the reality today. We need to search this tree even +- // when we have a sysroot somewhere else. It is the responsibility of +- // whomever is doing the cross build targeting a sysroot using a GCC +- // installation that is *not* within the system root to ensure two things: +- // +- // 1) Any DSOs that are linked in from this tree or from the install path +- // above must be present on the system root and found via an +- // appropriate rpath. +- // 2) There must not be libraries installed into +- // // unless they should be preferred over +- // those within the system root. +- // +- // Note that this matches the GCC behavior. See the below comment for where +- // Clang diverges from GCC's behavior. +- addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib/../" + +- OSLibDir + Multilib.osSuffix(), +- Paths); +- +- // If the GCC installation we found is inside of the sysroot, we want to +- // prefer libraries installed in the parent prefix of the GCC installation. +- // It is important to *not* use these paths when the GCC installation is +- // outside of the system root as that can pick up unintended libraries. +- // This usually happens when there is an external cross compiler on the +- // host system, and a more minimal sysroot available that is the target of +- // the cross. Note that GCC does include some of these directories in some +- // configurations but this seems somewhere between questionable and simply +- // a bug. +- if (StringRef(LibPath).startswith(SysRoot)) { +- addPathIfExists(D, LibPath + "/" + MultiarchTriple, Paths); +- addPathIfExists(D, LibPath + "/../" + OSLibDir, Paths); +- } +- } +- +- // Similar to the logic for GCC above, if we currently running Clang inside +- // of the requested system root, add its parent library paths to +- // those searched. +- // FIXME: It's not clear whether we should use the driver's installed +- // directory ('Dir' below) or the ResourceDir. +- if (StringRef(D.Dir).startswith(SysRoot)) { +- addPathIfExists(D, D.Dir + "/../lib/" + MultiarchTriple, Paths); +- addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths); +- } +- +- addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths); +- addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths); +- +- addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths); +- addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths); +- +- // Try walking via the GCC triple path in case of biarch or multiarch GCC +- // installations with strange symlinks. +- if (GCCInstallation.isValid()) { +- addPathIfExists(D, +- SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() + +- "/../../" + OSLibDir, +- Paths); +- +- // Add the 'other' biarch variant path +- Multilib BiarchSibling; +- if (GCCInstallation.getBiarchSibling(BiarchSibling)) { +- addPathIfExists(D, GCCInstallation.getInstallPath() + +- BiarchSibling.gccSuffix(), +- Paths); +- } +- +- // See comments above on the multilib variant for details of why this is +- // included even from outside the sysroot. +- const std::string &LibPath = GCCInstallation.getParentLibPath(); +- const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); +- const Multilib &Multilib = GCCInstallation.getMultilib(); +- addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib" + +- Multilib.osSuffix(), +- Paths); +- +- // See comments above on the multilib variant for details of why this is +- // only included from within the sysroot. +- if (StringRef(LibPath).startswith(SysRoot)) +- addPathIfExists(D, LibPath, Paths); +- } +- +- // Similar to the logic for GCC above, if we are currently running Clang +- // inside of the requested system root, add its parent library path to those +- // searched. +- // FIXME: It's not clear whether we should use the driver's installed +- // directory ('Dir' below) or the ResourceDir. +- if (StringRef(D.Dir).startswith(SysRoot)) +- addPathIfExists(D, D.Dir + "/../lib", Paths); +- +- addPathIfExists(D, SysRoot + "/lib", Paths); +- addPathIfExists(D, SysRoot + "/usr/lib", Paths); +-} +- +-bool kFreeBSD::HasNativeLLVMSupport() const { return true; } +- +-Tool *kFreeBSD::buildLinker() const { return new tools::gnutools::Linker(*this); } +- +-Tool *kFreeBSD::buildAssembler() const { +- return new tools::gnutools::Assembler(*this); +-} +- +-std::string kFreeBSD::computeSysRoot() const { +- if (!getDriver().SysRoot.empty()) +- return getDriver().SysRoot; +- +- return std::string(); +-} +- +-std::string kFreeBSD::getDynamicLinker(const ArgList &Args) const { +- const llvm::Triple::ArchType Arch = getArch(); +- +- if (Arch == llvm::Triple::x86_64) +- return "/lib/ld-kfreebsd-x86-64.so.1"; +- +- if (Arch == llvm::Triple::x86) +- return "/lib/ld.so.1"; +- +- llvm_unreachable("unsupported architecture"); +-} +- +-void kFreeBSD::AddClangSystemIncludeArgs(const ArgList &DriverArgs, +- ArgStringList &CC1Args) const { +- const Driver &D = getDriver(); +- std::string SysRoot = computeSysRoot(); +- +- if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc)) +- return; +- +- if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) +- addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include"); +- +- if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) { +- SmallString<128> P(D.ResourceDir); +- llvm::sys::path::append(P, "include"); +- addSystemInclude(DriverArgs, CC1Args, P); +- } +- +- if (DriverArgs.hasArg(options::OPT_nostdlibinc)) +- return; +- +- // Check for configure-time C include directories. +- StringRef CIncludeDirs(C_INCLUDE_DIRS); +- if (CIncludeDirs != "") { +- SmallVector dirs; +- CIncludeDirs.split(dirs, ":"); +- for (StringRef dir : dirs) { +- StringRef Prefix = +- llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : ""; +- addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir); +- } +- // addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include"); +- return; +- } +- +- // Lacking those, try to detect the correct set of system includes for the +- // target triple. +- +- // Add include directories specific to the selected multilib set and multilib. +- if (GCCInstallation.isValid()) { +- const auto &Callback = Multilibs.includeDirsCallback(); +- if (Callback) { +- for (const auto &Path : Callback(GCCInstallation.getMultilib())) +- addExternCSystemIncludeIfExists( +- DriverArgs, CC1Args, GCCInstallation.getInstallPath() + Path); +- } +- } +- +- // Implement generic Debian multiarch support. +- const StringRef X86_64MultiarchIncludeDirs[] = { +- "/usr/include/x86_64-kfreebsd-gnu"}; +- +- // CHECK +- const StringRef X86MultiarchIncludeDirs[] = { +- "/usr/include/i386-kfreebsd-gnu"}; +- +- ArrayRef MultiarchIncludeDirs; +- switch (getTriple().getArch()) { +- case llvm::Triple::x86: +- MultiarchIncludeDirs = X86MultiarchIncludeDirs; +- break; +- case llvm::Triple::x86_64: +- MultiarchIncludeDirs = X86_64MultiarchIncludeDirs; +- break; +- default: +- break; +- } +- +- for (StringRef Dir : MultiarchIncludeDirs) { +- if (D.getVFS().exists(SysRoot + Dir)) { +- addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + Dir); +- break; +- } +- } +- +- // Add an include of '/include' directly. This isn't provided by default by +- // system GCCs, but is often used with cross-compiling GCCs, and harmless to +- // add even when Clang is acting as-if it were a system compiler. +- addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include"); +- +- addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include"); +-} +- +-static std::string DetectLibcxxIncludePath(StringRef base) { +- std::error_code EC; +- int MaxVersion = 0; +- std::string MaxVersionString = ""; +- for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC && LI != LE; +- LI = LI.increment(EC)) { +- StringRef VersionText = llvm::sys::path::filename(LI->path()); +- int Version; +- if (VersionText[0] == 'v' && +- !VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) { +- if (Version > MaxVersion) { +- MaxVersion = Version; +- MaxVersionString = VersionText; +- } +- } +- } +- return MaxVersion ? (base + "/" + MaxVersionString).str() : ""; +-} +- +-void kFreeBSD::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, +- llvm::opt::ArgStringList &CC1Args) const { +- const std::string& SysRoot = computeSysRoot(); +- const std::string LibCXXIncludePathCandidates[] = { +- DetectLibcxxIncludePath(getDriver().ResourceDir + "/include/c++"), +- DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"), +- // If this is a development, non-installed, clang, libcxx will +- // not be found at ../include/c++ but it likely to be found at +- // one of the following two locations: +- DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++"), +- DetectLibcxxIncludePath(SysRoot + "/usr/include/c++") }; +- for (const auto &IncludePath : LibCXXIncludePathCandidates) { +- if (IncludePath.empty() || !getVFS().exists(IncludePath)) +- continue; +- // Use the first candidate that exists. +- addSystemInclude(DriverArgs, CC1Args, IncludePath); +- return; +- } +-} +- +-void kFreeBSD::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, +- llvm::opt::ArgStringList &CC1Args) const { +- // We need a detected GCC installation on kFreeBSD to provide libstdc++'s +- // headers. +- if (!GCCInstallation.isValid()) +- return; +- +- // By default, look for the C++ headers in an include directory adjacent to +- // the lib directory of the GCC installation. Note that this is expect to be +- // equivalent to '/usr/include/c++/X.Y' in almost all cases. +- StringRef LibDir = GCCInstallation.getParentLibPath(); +- StringRef InstallDir = GCCInstallation.getInstallPath(); +- StringRef TripleStr = GCCInstallation.getTriple().str(); +- const Multilib &Multilib = GCCInstallation.getMultilib(); +- const std::string GCCMultiarchTriple = getMultiarchTriple( +- getDriver(), GCCInstallation.getTriple(), getDriver().SysRoot); +- const std::string TargetMultiarchTriple = +- getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot); +- const GCCVersion &Version = GCCInstallation.getVersion(); +- +- // The primary search for libstdc++ supports multiarch variants. +- if (addLibStdCXXIncludePaths(LibDir.str() + "/../include", +- "/c++/" + Version.Text, TripleStr, +- GCCMultiarchTriple, TargetMultiarchTriple, +- Multilib.includeSuffix(), DriverArgs, CC1Args)) +- return; +- +- // Otherwise, fall back on a bunch of options which don't use multiarch +- // layouts for simplicity. +- const std::string LibStdCXXIncludePathCandidates[] = { +- // Gentoo is weird and places its headers inside the GCC install, +- // so if the first attempt to find the headers fails, try these patterns. +- InstallDir.str() + "/include/g++-v" + Version.Text, +- InstallDir.str() + "/include/g++-v" + Version.MajorStr + "." + +- Version.MinorStr, +- InstallDir.str() + "/include/g++-v" + Version.MajorStr, +- // Android standalone toolchain has C++ headers in yet another place. +- LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text, +- // Freescale SDK C++ headers are directly in /usr/include/c++, +- // without a subdirectory corresponding to the gcc version. +- LibDir.str() + "/../include/c++", +- }; +- +- for (const auto &IncludePath : LibStdCXXIncludePathCandidates) { +- if (addLibStdCXXIncludePaths(IncludePath, /*Suffix*/ "", TripleStr, +- /*GCCMultiarchTriple*/ "", +- /*TargetMultiarchTriple*/ "", +- Multilib.includeSuffix(), DriverArgs, CC1Args)) +- break; +- } +-} +- +-/* FIXME: +-/home/srs/DEBs/llvm-toolchain-7/llvm-toolchain-7-7.0.1~+rc2-7/tools/clang/lib/Driver/ToolChains/KFreeBSD.cpp:431:15: error: no declaration matches ‘clang::SanitizerMask clang::driver::toolchains::kFreeBSD::getSupportedSanitizers() const’ +- SanitizerMask kFreeBSD::getSupportedSanitizers() const { +-*/ +-SanitizerMask kFreeBSD::getSupportedSanitizers() const { +- const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; +- const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; +- SanitizerMask Res = ToolChain::getSupportedSanitizers(); +- // FIXME: Add here!! +- if (IsX86_64) { +- Res |= SanitizerKind::DataFlow; +- Res |= SanitizerKind::Leak; +- Res |= SanitizerKind::Thread; +- Res |= SanitizerKind::Efficiency; +- Res |= SanitizerKind::Scudo; +- Res |= SanitizerKind::HWAddress; +- Res |= SanitizerKind::KernelHWAddress; +- } +- if (IsX86 || IsX86_64) +- Res |= SanitizerKind::Function; +- +- return Res; +-} +- diff --git a/debian/patches/series b/debian/patches/series index 4ba31d7e..4666801a 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -127,3 +127,4 @@ kfreebsd/lib_Target_X86.diff kfreebsd/lldb_source_Host_freebsd_Host.cpp.diff kfreebsd/lldb_source_Plugins_Process_FreeBSD.diff kfreebsd/tools_llvm-shlib_CMakeLists.txt.diff +kfreebsd/vfs.diff From c7892bed26e35c32b7f4414773bddc26499512b0 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 8 Feb 2019 09:01:23 +0100 Subject: [PATCH 06/11] New snapshot release --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index a3c11d5b..0d8764c0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -llvm-toolchain-8 (1:8~+rc2-1~exp1) UNRELEASED; urgency=medium +llvm-toolchain-8 (1:8~+rc2-1~exp1) unstable; urgency=medium + * New snapshot release * Add support for kfreebsd (Closes: #921246) Many thanks to Svante Signell for all patches - * experimental New snapshot release -- Sylvestre Ledru Thu, 07 Feb 2019 17:09:15 +0100 From bb5a801abe3d3160ae93303123f4712a4ef94e5e Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 8 Feb 2019 09:06:18 +0100 Subject: [PATCH 07/11] fix the path in the patches --- debian/patches/kfreebsd/kfreebsd-triple-clang.diff | 2 +- debian/patches/kfreebsd/vfs.diff | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/patches/kfreebsd/kfreebsd-triple-clang.diff b/debian/patches/kfreebsd/kfreebsd-triple-clang.diff index c848440e..904bc769 100644 --- a/debian/patches/kfreebsd/kfreebsd-triple-clang.diff +++ b/debian/patches/kfreebsd/kfreebsd-triple-clang.diff @@ -548,7 +548,7 @@ Index: llvm-toolchain-8_8~+rc2/clang/lib/Driver/ToolChains/KFreeBSD.cpp +} + +/* FIXME: -+/home/srs/DEBs/llvm-toolchain-7/llvm-toolchain-7-7.0.1~+rc2-7/tools/clang/lib/Driver/ToolChains/KFreeBSD.cpp:431:15: error: no declaration matches ‘clang::SanitizerMask clang::driver::toolchains::kFreeBSD::getSupportedSanitizers() const’ ++/home/srs/DEBs/llvm-toolchain-7/llvm-toolchain-7-7.0.1~+rc2-7/clang/lib/Driver/ToolChains/KFreeBSD.cpp:431:15: error: no declaration matches ‘clang::SanitizerMask clang::driver::toolchains::kFreeBSD::getSupportedSanitizers() const’ + SanitizerMask kFreeBSD::getSupportedSanitizers() const { +*/ +SanitizerMask kFreeBSD::getSupportedSanitizers() const { diff --git a/debian/patches/kfreebsd/vfs.diff b/debian/patches/kfreebsd/vfs.diff index c95665fb..d7ac5a89 100644 --- a/debian/patches/kfreebsd/vfs.diff +++ b/debian/patches/kfreebsd/vfs.diff @@ -1,4 +1,4 @@ -Index: llvm-toolchain-8-8~+rc2/home/sylvestre/dev/debian/pkg-llvm/llvm-toolchain/branches/llvm-toolchain-8-8~+rc2/tools/clang/lib/Driver/ToolChains/KFreeBSD.cpp +Index: llvm-toolchain-8-8~+rc2/home/sylvestre/dev/debian/pkg-llvm/llvm-toolchain/branches/llvm-toolchain-8-8~+rc2/tools/clang/!lib/Driver/ToolChains/KFreeBSD.cpp =================================================================== --- llvm-toolchain-8-8~+rc2.orig/home/sylvestre/dev/debian/pkg-llvm/llvm-toolchain/branches/llvm-toolchain-8-8~+rc2/tools/clang/lib/Driver/ToolChains/KFreeBSD.cpp +++ /dev/null From 8315f4a5c4948d3352e91f3c23562883c80cb97e Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 8 Feb 2019 09:10:10 +0100 Subject: [PATCH 08/11] fix the path --- .../kfreebsd/kfreebsd-triple-clang.diff | 2 +- debian/patches/kfreebsd/vfs.diff | 464 ------------------ debian/patches/series | 1 - 3 files changed, 1 insertion(+), 466 deletions(-) delete mode 100644 debian/patches/kfreebsd/vfs.diff diff --git a/debian/patches/kfreebsd/kfreebsd-triple-clang.diff b/debian/patches/kfreebsd/kfreebsd-triple-clang.diff index 904bc769..b118189a 100644 --- a/debian/patches/kfreebsd/kfreebsd-triple-clang.diff +++ b/debian/patches/kfreebsd/kfreebsd-triple-clang.diff @@ -123,7 +123,7 @@ Index: llvm-toolchain-8_8~+rc2/clang/lib/Driver/ToolChains/KFreeBSD.cpp + +#include "KFreeBSD.h" +#include "CommonArgs.h" -+#include "clang/Basic/VirtualFileSystem.h" ++#include "llvm/Support/VirtualFileSystem.h" +#include "clang/Config/config.h" +#include "clang/Driver/Driver.h" +#include "clang/Driver/Options.h" diff --git a/debian/patches/kfreebsd/vfs.diff b/debian/patches/kfreebsd/vfs.diff deleted file mode 100644 index d7ac5a89..00000000 --- a/debian/patches/kfreebsd/vfs.diff +++ /dev/null @@ -1,464 +0,0 @@ -Index: llvm-toolchain-8-8~+rc2/home/sylvestre/dev/debian/pkg-llvm/llvm-toolchain/branches/llvm-toolchain-8-8~+rc2/tools/clang/!lib/Driver/ToolChains/KFreeBSD.cpp -=================================================================== ---- llvm-toolchain-8-8~+rc2.orig/home/sylvestre/dev/debian/pkg-llvm/llvm-toolchain/branches/llvm-toolchain-8-8~+rc2/tools/clang/lib/Driver/ToolChains/KFreeBSD.cpp -+++ /dev/null -@@ -1,459 +0,0 @@ --//===--- KFreeBSD.cpp - kFreeBSD ToolChain Implementations --------*- C++ -*-===// --// --// The LLVM Compiler Infrastructure --// --// This file is distributed under the University of Illinois Open Source --// License. See LICENSE.TXT for details. --// --//===----------------------------------------------------------------------===// -- --#include "KFreeBSD.h" --#include "CommonArgs.h" --#include "clang/Basic/VirtualFileSystem.h" --#include "clang/Config/config.h" --#include "clang/Driver/Driver.h" --#include "clang/Driver/Options.h" --#include "clang/Driver/SanitizerArgs.h" --#include "llvm/Option/ArgList.h" --#include "llvm/ProfileData/InstrProf.h" --#include "llvm/Support/Path.h" -- --using namespace clang::driver; --using namespace clang::driver::toolchains; --using namespace clang; --using namespace llvm::opt; -- --using tools::addPathIfExists; -- --/// Get our best guess at the multiarch triple for a target. --/// --/// Debian-based systems are starting to use a multiarch setup where they use --/// a target-triple directory in the library and header search paths. --/// Unfortunately, this triple does not align with the vanilla target triple, --/// so we provide a rough mapping here. --static std::string getMultiarchTriple(const Driver &D, -- const llvm::Triple &TargetTriple, -- StringRef SysRoot) { -- // For most architectures, just use whatever we have rather than trying to be -- // clever. -- switch (TargetTriple.getArch()) { -- default: -- break; -- -- // We use the existence of '/lib/' as a directory to detect -- // some common kfreebsd triples that don't quite match the Clang -- // triple for both 32-bit and 64-bit targets. Multiarch fixes its -- // install triples to these regardless of what the actual target -- // triple is. -- case llvm::Triple::x86_64: -- if (D.getVFS().exists(SysRoot + "/lib/x86_64-kfreebsd-gnu")) -- return "x86_64-kfreebsd-gnu"; -- break; -- case llvm::Triple::x86: -- if (D.getVFS().exists(SysRoot + "/lib/i386-kfreebsd-gnu")) -- return "i386-kfreebsd-gnu"; -- break; -- } -- -- return TargetTriple.str(); --} -- --static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) { -- // It happens that only x86 and PPC use the 'lib32' variant of oslibdir, and -- // using that variant while targeting other architectures causes problems -- // because the libraries are laid out in shared system roots that can't cope -- // with a 'lib32' library search path being considered. So we only enable -- // them when we know we may need it. -- // -- // FIXME: This is a bit of a hack. We should really unify this code for -- // reasoning about oslibdir spellings with the lib dir spellings in the -- // GCCInstallationDetector, but that is a more significant refactoring. -- -- if (Triple.getArch() == llvm::Triple::x86) -- return "lib"; -- -- if (Triple.getArch() == llvm::Triple::x86_64) -- return "lib"; -- -- return Triple.isArch32Bit() ? "lib" : "lib64"; --} -- --static void addMultilibsFilePaths(const Driver &D, const MultilibSet &Multilibs, -- const Multilib &Multilib, -- StringRef InstallPath, -- ToolChain::path_list &Paths) { -- if (const auto &PathsCallback = Multilibs.filePathsCallback()) -- for (const auto &Path : PathsCallback(Multilib)) -- addPathIfExists(D, InstallPath + Path, Paths); --} -- --kFreeBSD::kFreeBSD(const Driver &D, const llvm::Triple &Triple, -- const ArgList &Args) -- : Generic_ELF(D, Triple, Args) { -- GCCInstallation.init(Triple, Args); -- Multilibs = GCCInstallation.getMultilibs(); -- std::string SysRoot = computeSysRoot(); -- -- // Cross-compiling binutils and GCC installations (vanilla and openSUSE at -- // least) put various tools in a triple-prefixed directory off of the parent -- // of the GCC installation. We use the GCC triple here to ensure that we end -- // up with tools that support the same amount of cross compiling as the -- // detected GCC installation. For example, if we find a GCC installation -- // targeting x86_64, but it is a bi-arch GCC installation, it can also be -- // used to target i386. -- // FIXME: This seems unlikely to be Linux-, kFreeBSD- or Hurd-specific. -- ToolChain::path_list &PPaths = getProgramPaths(); -- PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" + -- GCCInstallation.getTriple().str() + "/bin") -- .str()); -- --#ifdef ENABLE_LINKER_BUILD_ID -- ExtraOpts.push_back("--build-id"); --#endif -- -- // The selection of paths to try here is designed to match the patterns which -- // the GCC driver itself uses, as this is part of the GCC-compatible driver. -- // This was determined by running GCC in a fake filesystem, creating all -- // possible permutations of these directories, and seeing which ones it added -- // to the link paths. -- path_list &Paths = getFilePaths(); -- -- const std::string OSLibDir = getOSLibDir(Triple, Args); -- const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot); -- -- // Add the multilib suffixed paths where they are available. -- if (GCCInstallation.isValid()) { -- const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); -- const std::string &LibPath = GCCInstallation.getParentLibPath(); -- const Multilib &Multilib = GCCInstallation.getMultilib(); -- const MultilibSet &Multilibs = GCCInstallation.getMultilibs(); -- -- // Add toolchain / multilib specific file paths. -- addMultilibsFilePaths(D, Multilibs, Multilib, -- GCCInstallation.getInstallPath(), Paths); -- -- // Sourcery CodeBench MIPS toolchain holds some libraries under -- // a biarch-like suffix of the GCC installation. -- addPathIfExists(D, GCCInstallation.getInstallPath() + Multilib.gccSuffix(), -- Paths); -- -- // GCC cross compiling toolchains will install target libraries which ship -- // as part of the toolchain under // rather than as -- // any part of the GCC installation in -- // //gcc//. This decision is somewhat -- // debatable, but is the reality today. We need to search this tree even -- // when we have a sysroot somewhere else. It is the responsibility of -- // whomever is doing the cross build targeting a sysroot using a GCC -- // installation that is *not* within the system root to ensure two things: -- // -- // 1) Any DSOs that are linked in from this tree or from the install path -- // above must be present on the system root and found via an -- // appropriate rpath. -- // 2) There must not be libraries installed into -- // // unless they should be preferred over -- // those within the system root. -- // -- // Note that this matches the GCC behavior. See the below comment for where -- // Clang diverges from GCC's behavior. -- addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib/../" + -- OSLibDir + Multilib.osSuffix(), -- Paths); -- -- // If the GCC installation we found is inside of the sysroot, we want to -- // prefer libraries installed in the parent prefix of the GCC installation. -- // It is important to *not* use these paths when the GCC installation is -- // outside of the system root as that can pick up unintended libraries. -- // This usually happens when there is an external cross compiler on the -- // host system, and a more minimal sysroot available that is the target of -- // the cross. Note that GCC does include some of these directories in some -- // configurations but this seems somewhere between questionable and simply -- // a bug. -- if (StringRef(LibPath).startswith(SysRoot)) { -- addPathIfExists(D, LibPath + "/" + MultiarchTriple, Paths); -- addPathIfExists(D, LibPath + "/../" + OSLibDir, Paths); -- } -- } -- -- // Similar to the logic for GCC above, if we currently running Clang inside -- // of the requested system root, add its parent library paths to -- // those searched. -- // FIXME: It's not clear whether we should use the driver's installed -- // directory ('Dir' below) or the ResourceDir. -- if (StringRef(D.Dir).startswith(SysRoot)) { -- addPathIfExists(D, D.Dir + "/../lib/" + MultiarchTriple, Paths); -- addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths); -- } -- -- addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths); -- addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths); -- -- addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths); -- addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths); -- -- // Try walking via the GCC triple path in case of biarch or multiarch GCC -- // installations with strange symlinks. -- if (GCCInstallation.isValid()) { -- addPathIfExists(D, -- SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() + -- "/../../" + OSLibDir, -- Paths); -- -- // Add the 'other' biarch variant path -- Multilib BiarchSibling; -- if (GCCInstallation.getBiarchSibling(BiarchSibling)) { -- addPathIfExists(D, GCCInstallation.getInstallPath() + -- BiarchSibling.gccSuffix(), -- Paths); -- } -- -- // See comments above on the multilib variant for details of why this is -- // included even from outside the sysroot. -- const std::string &LibPath = GCCInstallation.getParentLibPath(); -- const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); -- const Multilib &Multilib = GCCInstallation.getMultilib(); -- addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib" + -- Multilib.osSuffix(), -- Paths); -- -- // See comments above on the multilib variant for details of why this is -- // only included from within the sysroot. -- if (StringRef(LibPath).startswith(SysRoot)) -- addPathIfExists(D, LibPath, Paths); -- } -- -- // Similar to the logic for GCC above, if we are currently running Clang -- // inside of the requested system root, add its parent library path to those -- // searched. -- // FIXME: It's not clear whether we should use the driver's installed -- // directory ('Dir' below) or the ResourceDir. -- if (StringRef(D.Dir).startswith(SysRoot)) -- addPathIfExists(D, D.Dir + "/../lib", Paths); -- -- addPathIfExists(D, SysRoot + "/lib", Paths); -- addPathIfExists(D, SysRoot + "/usr/lib", Paths); --} -- --bool kFreeBSD::HasNativeLLVMSupport() const { return true; } -- --Tool *kFreeBSD::buildLinker() const { return new tools::gnutools::Linker(*this); } -- --Tool *kFreeBSD::buildAssembler() const { -- return new tools::gnutools::Assembler(*this); --} -- --std::string kFreeBSD::computeSysRoot() const { -- if (!getDriver().SysRoot.empty()) -- return getDriver().SysRoot; -- -- return std::string(); --} -- --std::string kFreeBSD::getDynamicLinker(const ArgList &Args) const { -- const llvm::Triple::ArchType Arch = getArch(); -- -- if (Arch == llvm::Triple::x86_64) -- return "/lib/ld-kfreebsd-x86-64.so.1"; -- -- if (Arch == llvm::Triple::x86) -- return "/lib/ld.so.1"; -- -- llvm_unreachable("unsupported architecture"); --} -- --void kFreeBSD::AddClangSystemIncludeArgs(const ArgList &DriverArgs, -- ArgStringList &CC1Args) const { -- const Driver &D = getDriver(); -- std::string SysRoot = computeSysRoot(); -- -- if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc)) -- return; -- -- if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) -- addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include"); -- -- if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) { -- SmallString<128> P(D.ResourceDir); -- llvm::sys::path::append(P, "include"); -- addSystemInclude(DriverArgs, CC1Args, P); -- } -- -- if (DriverArgs.hasArg(options::OPT_nostdlibinc)) -- return; -- -- // Check for configure-time C include directories. -- StringRef CIncludeDirs(C_INCLUDE_DIRS); -- if (CIncludeDirs != "") { -- SmallVector dirs; -- CIncludeDirs.split(dirs, ":"); -- for (StringRef dir : dirs) { -- StringRef Prefix = -- llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : ""; -- addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir); -- } -- // addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include"); -- return; -- } -- -- // Lacking those, try to detect the correct set of system includes for the -- // target triple. -- -- // Add include directories specific to the selected multilib set and multilib. -- if (GCCInstallation.isValid()) { -- const auto &Callback = Multilibs.includeDirsCallback(); -- if (Callback) { -- for (const auto &Path : Callback(GCCInstallation.getMultilib())) -- addExternCSystemIncludeIfExists( -- DriverArgs, CC1Args, GCCInstallation.getInstallPath() + Path); -- } -- } -- -- // Implement generic Debian multiarch support. -- const StringRef X86_64MultiarchIncludeDirs[] = { -- "/usr/include/x86_64-kfreebsd-gnu"}; -- -- // CHECK -- const StringRef X86MultiarchIncludeDirs[] = { -- "/usr/include/i386-kfreebsd-gnu"}; -- -- ArrayRef MultiarchIncludeDirs; -- switch (getTriple().getArch()) { -- case llvm::Triple::x86: -- MultiarchIncludeDirs = X86MultiarchIncludeDirs; -- break; -- case llvm::Triple::x86_64: -- MultiarchIncludeDirs = X86_64MultiarchIncludeDirs; -- break; -- default: -- break; -- } -- -- for (StringRef Dir : MultiarchIncludeDirs) { -- if (D.getVFS().exists(SysRoot + Dir)) { -- addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + Dir); -- break; -- } -- } -- -- // Add an include of '/include' directly. This isn't provided by default by -- // system GCCs, but is often used with cross-compiling GCCs, and harmless to -- // add even when Clang is acting as-if it were a system compiler. -- addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include"); -- -- addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include"); --} -- --static std::string DetectLibcxxIncludePath(StringRef base) { -- std::error_code EC; -- int MaxVersion = 0; -- std::string MaxVersionString = ""; -- for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC && LI != LE; -- LI = LI.increment(EC)) { -- StringRef VersionText = llvm::sys::path::filename(LI->path()); -- int Version; -- if (VersionText[0] == 'v' && -- !VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) { -- if (Version > MaxVersion) { -- MaxVersion = Version; -- MaxVersionString = VersionText; -- } -- } -- } -- return MaxVersion ? (base + "/" + MaxVersionString).str() : ""; --} -- --void kFreeBSD::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, -- llvm::opt::ArgStringList &CC1Args) const { -- const std::string& SysRoot = computeSysRoot(); -- const std::string LibCXXIncludePathCandidates[] = { -- DetectLibcxxIncludePath(getDriver().ResourceDir + "/include/c++"), -- DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"), -- // If this is a development, non-installed, clang, libcxx will -- // not be found at ../include/c++ but it likely to be found at -- // one of the following two locations: -- DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++"), -- DetectLibcxxIncludePath(SysRoot + "/usr/include/c++") }; -- for (const auto &IncludePath : LibCXXIncludePathCandidates) { -- if (IncludePath.empty() || !getVFS().exists(IncludePath)) -- continue; -- // Use the first candidate that exists. -- addSystemInclude(DriverArgs, CC1Args, IncludePath); -- return; -- } --} -- --void kFreeBSD::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, -- llvm::opt::ArgStringList &CC1Args) const { -- // We need a detected GCC installation on kFreeBSD to provide libstdc++'s -- // headers. -- if (!GCCInstallation.isValid()) -- return; -- -- // By default, look for the C++ headers in an include directory adjacent to -- // the lib directory of the GCC installation. Note that this is expect to be -- // equivalent to '/usr/include/c++/X.Y' in almost all cases. -- StringRef LibDir = GCCInstallation.getParentLibPath(); -- StringRef InstallDir = GCCInstallation.getInstallPath(); -- StringRef TripleStr = GCCInstallation.getTriple().str(); -- const Multilib &Multilib = GCCInstallation.getMultilib(); -- const std::string GCCMultiarchTriple = getMultiarchTriple( -- getDriver(), GCCInstallation.getTriple(), getDriver().SysRoot); -- const std::string TargetMultiarchTriple = -- getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot); -- const GCCVersion &Version = GCCInstallation.getVersion(); -- -- // The primary search for libstdc++ supports multiarch variants. -- if (addLibStdCXXIncludePaths(LibDir.str() + "/../include", -- "/c++/" + Version.Text, TripleStr, -- GCCMultiarchTriple, TargetMultiarchTriple, -- Multilib.includeSuffix(), DriverArgs, CC1Args)) -- return; -- -- // Otherwise, fall back on a bunch of options which don't use multiarch -- // layouts for simplicity. -- const std::string LibStdCXXIncludePathCandidates[] = { -- // Gentoo is weird and places its headers inside the GCC install, -- // so if the first attempt to find the headers fails, try these patterns. -- InstallDir.str() + "/include/g++-v" + Version.Text, -- InstallDir.str() + "/include/g++-v" + Version.MajorStr + "." + -- Version.MinorStr, -- InstallDir.str() + "/include/g++-v" + Version.MajorStr, -- // Android standalone toolchain has C++ headers in yet another place. -- LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text, -- // Freescale SDK C++ headers are directly in /usr/include/c++, -- // without a subdirectory corresponding to the gcc version. -- LibDir.str() + "/../include/c++", -- }; -- -- for (const auto &IncludePath : LibStdCXXIncludePathCandidates) { -- if (addLibStdCXXIncludePaths(IncludePath, /*Suffix*/ "", TripleStr, -- /*GCCMultiarchTriple*/ "", -- /*TargetMultiarchTriple*/ "", -- Multilib.includeSuffix(), DriverArgs, CC1Args)) -- break; -- } --} -- --/* FIXME: --/home/srs/DEBs/llvm-toolchain-7/llvm-toolchain-7-7.0.1~+rc2-7/tools/clang/lib/Driver/ToolChains/KFreeBSD.cpp:431:15: error: no declaration matches ‘clang::SanitizerMask clang::driver::toolchains::kFreeBSD::getSupportedSanitizers() const’ -- SanitizerMask kFreeBSD::getSupportedSanitizers() const { --*/ --SanitizerMask kFreeBSD::getSupportedSanitizers() const { -- const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; -- const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; -- SanitizerMask Res = ToolChain::getSupportedSanitizers(); -- // FIXME: Add here!! -- if (IsX86_64) { -- Res |= SanitizerKind::DataFlow; -- Res |= SanitizerKind::Leak; -- Res |= SanitizerKind::Thread; -- Res |= SanitizerKind::Efficiency; -- Res |= SanitizerKind::Scudo; -- Res |= SanitizerKind::HWAddress; -- Res |= SanitizerKind::KernelHWAddress; -- } -- if (IsX86 || IsX86_64) -- Res |= SanitizerKind::Function; -- -- return Res; --} -- diff --git a/debian/patches/series b/debian/patches/series index 4666801a..4ba31d7e 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -127,4 +127,3 @@ kfreebsd/lib_Target_X86.diff kfreebsd/lldb_source_Host_freebsd_Host.cpp.diff kfreebsd/lldb_source_Plugins_Process_FreeBSD.diff kfreebsd/tools_llvm-shlib_CMakeLists.txt.diff -kfreebsd/vfs.diff From 145e47421bedaee9aa6b6434d8172ae52f40298f Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 8 Feb 2019 10:45:34 +0100 Subject: [PATCH 09/11] remove the hardcoded version --- debian/qualify-clang.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index 115fe3bf..a437d407 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -9,7 +9,7 @@ VERSION=$(dpkg-parsechangelog | sed -rne "s,^Version: 1:([0-9]+).*,\1,p") DETAILED_VERSION=$(dpkg-parsechangelog | sed -rne "s,^Version: 1:([0-9.]+)(~|-)(.*),\1\2\3,p") DEB_HOST_ARCH=$(dpkg-architecture -qDEB_HOST_ARCH) -LIST="libomp5-${VERSION}_${DETAILED_VERSION}_amd64.deb libomp-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb lldb-${VERSION}_${DETAILED_VERSION}_amd64.deb python-lldb-${VERSION}_${DETAILED_VERSION}_amd64.deb libllvm7_${DETAILED_VERSION}_amd64.deb llvm-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb liblldb-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb libclang1-${VERSION}_${DETAILED_VERSION}_amd64.deb libclang-common-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb llvm-${VERSION}_${DETAILED_VERSION}_amd64.deb liblldb-${VERSION}_${DETAILED_VERSION}_amd64.deb llvm-${VERSION}-runtime_${DETAILED_VERSION}_amd64.deb lld-${VERSION}_${DETAILED_VERSION}_amd64.deb libfuzzer-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb libclang-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb libc++-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb libc++abi-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb libc++1-${VERSION}_${DETAILED_VERSION}_amd64.deb libc++abi1-${VERSION}_${DETAILED_VERSION}_amd64.deb clang-${VERSION}_${DETAILED_VERSION}_amd64.deb llvm-${VERSION}-tools_${DETAILED_VERSION}_amd64.deb clang-tools-${VERSION}_${DETAILED_VERSION}_amd64.deb clang-${VERSION}-dbgsym_${DETAILED_VERSION}_amd64.deb libclang1-${VERSION}-dbgsym_${DETAILED_VERSION}_amd64.deb" +LIST="libomp5-${VERSION}_${DETAILED_VERSION}_amd64.deb libomp-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb lldb-${VERSION}_${DETAILED_VERSION}_amd64.deb python-lldb-${VERSION}_${DETAILED_VERSION}_amd64.deb libllvm${VERSION}_${DETAILED_VERSION}_amd64.deb llvm-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb liblldb-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb libclang1-${VERSION}_${DETAILED_VERSION}_amd64.deb libclang-common-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb llvm-${VERSION}_${DETAILED_VERSION}_amd64.deb liblldb-${VERSION}_${DETAILED_VERSION}_amd64.deb llvm-${VERSION}-runtime_${DETAILED_VERSION}_amd64.deb lld-${VERSION}_${DETAILED_VERSION}_amd64.deb libfuzzer-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb libclang-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb libc++-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb libc++abi-${VERSION}-dev_${DETAILED_VERSION}_amd64.deb libc++1-${VERSION}_${DETAILED_VERSION}_amd64.deb libc++abi1-${VERSION}_${DETAILED_VERSION}_amd64.deb clang-${VERSION}_${DETAILED_VERSION}_amd64.deb llvm-${VERSION}-tools_${DETAILED_VERSION}_amd64.deb clang-tools-${VERSION}_${DETAILED_VERSION}_amd64.deb clang-${VERSION}-dbgsym_${DETAILED_VERSION}_amd64.deb libclang1-${VERSION}-dbgsym_${DETAILED_VERSION}_amd64.deb" echo "To install everything:" echo "sudo dpkg -i $LIST" L="" From 64825e67ea4dfa8ebc02f7b52788a2a85f34f42d Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 8 Feb 2019 11:06:03 +0100 Subject: [PATCH 10/11] improve the test to avoid bug https://bugs.llvm.org/show_bug.cgi\?id\=40659 --- debian/qualify-clang.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index a437d407..b1f6237b 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -252,8 +252,14 @@ fi clang-$VERSION -fuse-ld=lld -O2 foo.c main.c -o foo ./foo > /dev/null -clang-$VERSION -fuse-ld=lld -flto -O2 foo.c main.c -o foo -./foo > /dev/null +if ls -al1 /usr/bin/ld.lld|grep ld.lld-$VERSION; then +# https://bugs.llvm.org/show_bug.cgi?id=40659 +# -fuse-ld=lld will call lld +# Mismatch of version can fail the check +# so, only run it when /usr/bin/lld == $VERSION + clang-$VERSION -fuse-ld=lld -flto -O2 foo.c main.c -o foo + ./foo > /dev/null +fi clang-$VERSION -fuse-ld=lld-$VERSION -O2 foo.c main.c -o foo ./foo > /dev/null From eb425e6379956540910f85da4787f4a4a98b7eb8 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 8 Feb 2019 21:34:44 +0100 Subject: [PATCH 11/11] Activate -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN for all gcc --- debian/changelog | 7 +++++++ debian/rules | 1 + 2 files changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index 0d8764c0..c3123278 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +llvm-toolchain-8 (1:8~+rc2-1~exp2) unstable; urgency=medium + + * Activate -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN for all + gcc + + -- Sylvestre Ledru Fri, 08 Feb 2019 21:34:32 +0100 + llvm-toolchain-8 (1:8~+rc2-1~exp1) unstable; urgency=medium * New snapshot release diff --git a/debian/rules b/debian/rules index b89ad3ed..8312655b 100755 --- a/debian/rules +++ b/debian/rules @@ -369,6 +369,7 @@ override_dh_auto_configure: preconfigure -DPOLLY_BUNDLED_JSONCPP=OFF \ -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="WebAssembly;AVR" \ -DCLANG_ENABLE_BOOTSTRAP=ON \ + -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ -DCLANG_VENDOR=$(VENDOR) \ -DCLANG_BOOTSTRAP_PASSTHROUGH="CMAKE_INSTALL_PREFIX;CMAKE_VERBOSE_MAKEFILE;CMAKE_BUILD_TYPE;CMAKE_CXX_FLAGS_RELWITHDEBINFO;LLVM_LINK_LLVM_DYLIB;LLVM_INSTALL_UTILS;LLVM_VERSION_SUFFIX;LLVM_ENABLE_SPHINX;SPHINX_WARNINGS_AS_ERRORS;LLVM_BUILD_LLVM_DYLIB;LLVM_ENABLE_RTTI;LLVM_ENABLE_FFI;LIBCLANG_LIBRARY_VERSION;ENABLE_LINKER_BUILD_ID;POLLY_BUNDLED_JSONCPP;LLVM_EXPERIMENTAL_TARGETS_TO_BUILD;LLVM_USE_PERF;LLVM_ENABLE_ASSERTIONS;LLVM_BINUTILS_INCDIR;LLVM_HOST_TRIPLE;;LLVM_COMPILER_CHECKED;COMPILER_RT_BUILD_BUILTINS;LIBOMP_LIBFLAGS;CMAKE_SHARED_LINKER_FLAGS"