Commit edf35163 authored by Sylvestre Ledru's avatar Sylvestre Ledru

Merge branch '7' of salsa.debian.org:pkg-llvm-team/llvm-toolchain into 7

parents a3ea521a de8350ee
......@@ -17,6 +17,13 @@ llvm-toolchain-7 (1:7.1.0~svn352582-1~exp1) UNRELEASED; urgency=medium
-- Sylvestre Ledru <sylvestre@debian.org> Wed, 30 Jan 2019 08:53:14 +0100
llvm-toolchain-7 (1:7.0.1-6) unstable; urgency=medium
* Add support for kfreebsd (Closes: #921246)
Many thanks to Svante Signell for all patches
-- Sylvestre Ledru <sylvestre@debian.org> Sun, 03 Feb 2019 17:27:51 +0100
llvm-toolchain-7 (1:7.0.1-5) unstable; urgency=medium
* Add 'Rules-Requires-Root: no' in debian/control
......
Index: llvm-toolchain-7-7.0.1/CMakeLists.txt
===================================================================
--- llvm-toolchain-7-7.0.1.orig/CMakeLists.txt
+++ llvm-toolchain-7-7.0.1/CMakeLists.txt
@@ -821,7 +821,7 @@ if(LLVM_TARGET_IS_CROSSCOMPILE_HOST)
# (this is a variable that CrossCompile sets on recursive invocations)
endif()
-if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
+if( ${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)" AND NOT "kFreeBSD" )
# On FreeBSD, /usr/local/* is not used by default. In order to build LLVM
# with libxml2, iconv.h, etc., we must add /usr/local paths.
include_directories(SYSTEM "/usr/local/include")
Index: llvm-toolchain-7-7.0.1/clang/lib/Basic/Targets.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/clang/lib/Basic/Targets.cpp
+++ llvm-toolchain-7-7.0.1/clang/lib/Basic/Targets.cpp
@@ -469,8 +469,8 @@ TargetInfo *AllocateTarget(const llvm::T
return new OpenBSDI386TargetInfo(Triple, Opts);
case llvm::Triple::FreeBSD:
return new FreeBSDTargetInfo<X86_32TargetInfo>(Triple, Opts);
- case llvm::Triple::KFreeBSD:
- return new KFreeBSDTargetInfo<X86_32TargetInfo>(Triple, Opts);
+ case llvm::Triple::kFreeBSD:
+ return new kFreeBSDTargetInfo<X86_32TargetInfo>(Triple, Opts);
case llvm::Triple::Minix:
return new MinixTargetInfo<X86_32TargetInfo>(Triple, Opts);
case llvm::Triple::Solaris:
@@ -528,8 +528,8 @@ TargetInfo *AllocateTarget(const llvm::T
return new FreeBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
case llvm::Triple::Fuchsia:
return new FuchsiaTargetInfo<X86_64TargetInfo>(Triple, Opts);
- case llvm::Triple::KFreeBSD:
- return new KFreeBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
+ case llvm::Triple::kFreeBSD:
+ return new kFreeBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
case llvm::Triple::Solaris:
return new SolarisTargetInfo<X86_64TargetInfo>(Triple, Opts);
case llvm::Triple::Win32: {
Index: llvm-toolchain-7-7.0.1/clang/lib/Basic/Targets/OSTargets.h
===================================================================
--- llvm-toolchain-7-7.0.1.orig/clang/lib/Basic/Targets/OSTargets.h
+++ llvm-toolchain-7-7.0.1/clang/lib/Basic/Targets/OSTargets.h
@@ -226,7 +226,7 @@ public:
// GNU/kFreeBSD Target
template <typename Target>
-class LLVM_LIBRARY_VISIBILITY KFreeBSDTargetInfo : public OSTargetInfo<Target> {
+class LLVM_LIBRARY_VISIBILITY kFreeBSDTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
@@ -243,7 +243,7 @@ protected:
}
public:
- KFreeBSDTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+ kFreeBSDTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: OSTargetInfo<Target>(Triple, Opts) {}
};
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
@@ -86,9 +86,14 @@
extern "C" {
// <sys/umtx.h> must be included after <errno.h> and <sys/types.h> on
// FreeBSD 9.2 and 10.0.
+#if SANITIZER_KFREEBSD
+#include <bsd/sys/cdefs.h>
+#endif
#include <sys/umtx.h>
}
+#if !SANITIZER_KFREEBSD
#include <sys/thr.h>
+#endif
#endif // SANITIZER_FREEBSD
#if SANITIZER_NETBSD
@@ -466,10 +471,12 @@ bool FileExists(const char *filename) {
}
tid_t GetTid() {
-#if SANITIZER_FREEBSD
+#if SANITIZER_FREEBSD && !SANITIZER_KFREEBSD
long Tid;
thr_self(&Tid);
return Tid;
+#elif SANITIZER_KFREEBSD
+ return (uptr)pthread_self();
#elif SANITIZER_OPENBSD
return internal_syscall(SYSCALL(getthrid));
#elif SANITIZER_NETBSD
@@ -1143,10 +1150,10 @@ bool LibraryNameIs(const char *full_name
// Call cb for each region mapped by map.
void ForEachMappedRegion(link_map *map, void (*cb)(const void *, uptr)) {
CHECK_NE(map, nullptr);
-#if !SANITIZER_FREEBSD && !SANITIZER_OPENBSD
+#if !SANITIZER_FREEBSD && !SANITIZER_OPENBSD || SANITIZER_KFREEBSD
typedef ElfW(Phdr) Elf_Phdr;
typedef ElfW(Ehdr) Elf_Ehdr;
-#endif // !SANITIZER_FREEBSD && !SANITIZER_OPENBSD
+#endif // !SANITIZER_FREEBSD && !SANITIZER_OPENBSD || SANITIZER_KFREEBSD
char *base = (char *)map->l_addr;
Elf_Ehdr *ehdr = (Elf_Ehdr *)base;
char *phdrs = base + ehdr->e_phoff;
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc
@@ -35,10 +35,12 @@
#include <syslog.h>
#if SANITIZER_FREEBSD
-#include <pthread_np.h>
+# if !SANITIZER_KFREEBSD
+# include <pthread_np.h>
+# define pthread_getattr_np pthread_attr_get_np
+# endif
#include <osreldate.h>
#include <sys/sysctl.h>
-#define pthread_getattr_np pthread_attr_get_np
#endif
#if SANITIZER_OPENBSD
@@ -523,9 +525,9 @@ void GetThreadStackAndTls(bool main, upt
#endif
}
-#if !SANITIZER_FREEBSD && !SANITIZER_OPENBSD
+#if !SANITIZER_FREEBSD && !SANITIZER_OPENBSD || SANITIZER_KFREEBSD
typedef ElfW(Phdr) Elf_Phdr;
-#elif SANITIZER_WORDSIZE == 32 && __FreeBSD_version <= 902001 // v9.2
+#elif SANITIZER_WORDSIZE == 32 && !SANITIZER_KFREEBSD && __FreeBSD_version <= 902001 // v9.2
#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-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
+++ llvm-toolchain-7-7.0.1/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) && \
!defined(__Fuchsia__) && !defined(__rtems__) && \
- !(defined(__sun__) && defined(__svr4__))
+ !(defined(__sun__) && defined(__svr4__)) && !defined(__FreeBSD_kernel__)
# error "This operating system is not supported"
#endif
@@ -26,12 +26,18 @@
# define SANITIZER_LINUX 0
#endif
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# define SANITIZER_FREEBSD 1
#else
# define SANITIZER_FREEBSD 0
#endif
+#if defined(__FreeBSD_kernel__)
+# define SANITIZER_KFREEBSD 1
+#else
+# define SANITIZER_KFREEBSD 0
+#endif
+
#if defined(__NetBSD__)
# define SANITIZER_NETBSD 1
#else
@@ -113,7 +119,8 @@
#define SANITIZER_POSIX \
(SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_MAC || \
- SANITIZER_NETBSD || SANITIZER_OPENBSD || SANITIZER_SOLARIS)
+ SANITIZER_NETBSD || SANITIZER_OPENBSD || SANITIZER_SOLARIS || \
+ SANITIZER_KFREEBSD)
#if __LP64__ || defined(_WIN64)
# define SANITIZER_WORDSIZE 64
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -49,7 +49,7 @@
#include <utmp.h>
#endif
-#if !SANITIZER_IOS
+#if !SANITIZER_IOS && !SANITIZER_KFREEBSD
#include <net/route.h>
#endif
@@ -86,7 +86,11 @@
# include <sys/signal.h>
# include <sys/timespec.h>
# include <sys/timex.h>
+#if SANITIZER_KFREEBSD
+# include <mqueue.h>
+#else
# include <sys/mqueue.h>
+#endif
# include <sys/msg.h>
# include <sys/ipc.h>
# include <sys/msg.h>
@@ -95,7 +99,11 @@
# include <sys/mtio.h>
# include <sys/consio.h>
# include <sys/kbio.h>
+#if SANITIZER_KFREEBSD
+# include <link.h>
+#else
# include <sys/link_elf.h>
+#endif
# include <netinet/ip_mroute.h>
# include <netinet/in.h>
# include <net/ethernet.h>
@@ -286,7 +294,7 @@ namespace __sanitizer {
#endif
-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !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;
@@ -316,7 +324,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);
@@ -496,7 +504,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
@@ -547,7 +555,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
unsigned IOCTL_TIOCSPGRP = TIOCSPGRP;
unsigned IOCTL_TIOCSTI = TIOCSTI;
unsigned IOCTL_TIOCSWINSZ = TIOCSWINSZ;
-#if ((SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID)
+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_KFREEBSD
unsigned IOCTL_SIOCGETSGCNT = SIOCGETSGCNT;
unsigned IOCTL_SIOCGETVIFCNT = SIOCGETVIFCNT;
#endif
@@ -989,7 +997,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);
@@ -1009,8 +1017,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);
@@ -1032,7 +1042,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);
@@ -1074,7 +1086,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);
@@ -1114,7 +1128,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);
@@ -1147,13 +1163,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);
@@ -1192,7 +1209,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) ==
@@ -1218,15 +1235,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
@@ -1292,7 +1313,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-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -20,7 +20,7 @@
#include "sanitizer_internal_defs.h"
#include "sanitizer_platform.h"
-#if SANITIZER_FREEBSD
+#if SANITIZER_FREEBSD && !SANITIZER_KFREEBSD
// FreeBSD's dlopen() returns a pointer to an Obj_Entry structure that
// incorporates the map structure.
# define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc
@@ -43,7 +43,7 @@
# else
# define internal_syscall_ptr syscall
# endif
-#elif defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_MAC)
+#elif defined(__x86_64__) && ((SANITIZER_FREEBSD && !SANITIZER_KFREEBSD) || SANITIZER_MAC)
# define internal_syscall __syscall
# define internal_syscall64 __syscall
# define internal_syscall_ptr __syscall
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/asan/asan_linux.cc
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/asan/asan_linux.cc
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/asan/asan_linux.cc
@@ -38,7 +38,7 @@
#include <unistd.h>
#include <unwind.h>
-#if SANITIZER_FREEBSD
+#if SANITIZER_FREEBSD && !SANITIZER_KFREEBSD
#include <sys/link_elf.h>
#endif
@@ -48,7 +48,11 @@
#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS
#include <ucontext.h>
+#if SANITIZER_KFREEBSD
+#include <link.h>
+#else
extern "C" void* _DYNAMIC;
+#endif
#elif SANITIZER_NETBSD
#include <link_elf.h>
#include <ucontext.h>
@@ -61,7 +65,7 @@ extern Elf_Dyn _DYNAMIC;
// x86-64 FreeBSD 9.2 and older define 'ucontext_t' incorrectly in
// 32-bit mode.
#if SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32) && \
- __FreeBSD_version <= 902001 // v9.2
+ !SANITIZER_KFREEBSD && __FreeBSD_version <= 902001 // v9.2
#define ucontext_t xucontext_t
#endif
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/ubsan/ubsan_platform.h
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/ubsan/ubsan_platform.h
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/ubsan/ubsan_platform.h
@@ -15,7 +15,7 @@
// Other platforms should be easy to add, and probably work as-is.
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) || \
- defined(__NetBSD__) || defined(__OpenBSD__) || \
+ defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD_kernel__) || \
(defined(__sun__) && defined(__svr4__)) || \
defined(_WIN32) || defined(__Fuchsia__) || defined(__rtems__)
# define CAN_SANITIZE_UB 1
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S
@@ -196,7 +196,7 @@ ASM_SYMBOL_INTERCEPTOR(setjmp):
#elif defined(__APPLE__)
lea 16(%rsp), %rdi
mov %rdi, %rsi
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__FreeBSD_kernel__)
lea 16(%rsp), %rdi
mov %rdi, %rsi
xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp)
@@ -244,7 +244,7 @@ ASM_SYMBOL_INTERCEPTOR(_setjmp):
#elif defined(__APPLE__)
lea 16(%rsp), %rdi
mov %rdi, %rsi
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__FreeBSD_kernel__)
lea 16(%rsp), %rdi
mov %rdi, %rsi
xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp)
@@ -299,7 +299,7 @@ ASM_SYMBOL_INTERCEPTOR(sigsetjmp):
#elif defined(__APPLE__)
lea 32(%rsp), %rdi
mov %rdi, %rsi
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__FreeBSD_kernel__)
lea 32(%rsp), %rdi
mov %rdi, %rsi
xor %fs:0x30, %rsi // magic mangling of rsp (see libc setjmp)
@@ -386,7 +386,7 @@ ASM_SYMBOL_INTERCEPTOR(__sigsetjmp):
ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
#endif // !defined(__APPLE__) && !defined(__NetBSD__)
-#if defined(__FreeBSD__) || defined(__linux__)
+#if defined(__FreeBSD__) || defined(__linux__) || defined(__FreeBSD_kernel__)
/* We do not need executable stack. */
/* This note is not needed on NetBSD. */
.section .note.GNU-stack,"",@progbits
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/fuzzer/FuzzerDefs.h
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/fuzzer/FuzzerDefs.h
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/fuzzer/FuzzerDefs.h
@@ -54,6 +54,15 @@
#define LIBFUZZER_FREEBSD 1
#define LIBFUZZER_OPENBSD 0
#define LIBFUZZER_WINDOWS 0
+#elif __FreeBSD_kernel__
+#define LIBFUZZER_APPLE 0
+#define LIBFUZZER_FUCHSIA 0
+#define LIBFUZZER_LINUX 0
+#define LIBFUZZER_NETBSD 0
+#define LIBFUZZER_FREEBSD 0
+#define LIBFUZZER_KFREEBSD 1
+#define LIBFUZZER_OPENBSD 0
+#define LIBFUZZER_WINDOWS 0
#elif __OpenBSD__
#define LIBFUZZER_APPLE 0
#define LIBFUZZER_FUCHSIA 0
@@ -88,7 +97,7 @@
#define LIBFUZZER_POSIX \
(LIBFUZZER_APPLE || LIBFUZZER_LINUX || LIBFUZZER_NETBSD || \
- LIBFUZZER_FREEBSD || LIBFUZZER_OPENBSD)
+ LIBFUZZER_FREEBSD || LIBFUZZER_OPENBSD || LIBFUZZER_KFREEBSD)
#ifdef __x86_64
# if __has_attribute(target)
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
@@ -119,7 +119,7 @@ size_t GetPeakRSSMb() {
if (getrusage(RUSAGE_SELF, &usage))
return 0;
if (LIBFUZZER_LINUX || LIBFUZZER_FREEBSD || LIBFUZZER_NETBSD ||
- LIBFUZZER_OPENBSD) {
+ LIBFUZZER_OPENBSD || LIBFUZZER_KFREEBSD) {
// ru_maxrss is in KiB
return usage.ru_maxrss >> 10;
} else if (LIBFUZZER_APPLE) {
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/fuzzer/FuzzerExtraCounters.cpp
@@ -12,7 +12,7 @@
#include "FuzzerDefs.h"
#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FREEBSD || \
- LIBFUZZER_OPENBSD
+ LIBFUZZER_OPENBSD || LIBFUZZER_KFREEBSD
__attribute__((weak)) extern uint8_t __start___libfuzzer_extra_counters;
__attribute__((weak)) extern uint8_t __stop___libfuzzer_extra_counters;
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/fuzzer/FuzzerExtFunctionsWeak.cpp
@@ -14,7 +14,7 @@
//===----------------------------------------------------------------------===//
#include "FuzzerDefs.h"
#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FUCHSIA || \
- LIBFUZZER_FREEBSD || LIBFUZZER_OPENBSD
+ LIBFUZZER_FREEBSD || LIBFUZZER_OPENBSD || LIBFUZZER_KFREEBSD
#include "FuzzerExtFunctions.h"
#include "FuzzerIO.h"
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/fuzzer/FuzzerUtilLinux.cpp
@@ -10,7 +10,7 @@
//===----------------------------------------------------------------------===//
#include "FuzzerDefs.h"
#if LIBFUZZER_LINUX || LIBFUZZER_NETBSD || LIBFUZZER_FREEBSD || \
- LIBFUZZER_OPENBSD
+ LIBFUZZER_OPENBSD || LIBFUZZER_KFREEBSD
#include "FuzzerCommand.h"
#include <stdlib.h>
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_freebsd.h
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/sanitizer_common/sanitizer_freebsd.h
+++ llvm-toolchain-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_freebsd.h
@@ -21,7 +21,7 @@
// 32-bit mode.
#if SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32)
# include <osreldate.h>
-# if __FreeBSD_version <= 902001 // v9.2
+# if !SANITIZER_KFREEBSD && __FreeBSD_version <= 902001 // v9.2
# include <link.h>
# include <sys/param.h>
# include <ucontext.h>
Index: llvm-toolchain-7-7.0.1/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cc
===================================================================
--- llvm-toolchain-7-7.0.1.orig/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cc
+++ llvm-toolchain-7-7.0.1/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)
#include <osreldate.h>
-#if __FreeBSD_version <= 902001 // v9.2
+#if !SANITIZER_KFREEBSD && __FreeBSD_version <= 902001 // v9.2
#define kinfo_vmentry xkinfo_vmentry
#endif
#endif
Index: llvm-toolchain-7-7.0.1/include/llvm/ADT/Triple.h
===================================================================
--- llvm-toolchain-7-7.0.1.orig/include/llvm/ADT/Triple.h
+++ llvm-toolchain-7-7.0.1/include/llvm/ADT/Triple.h
@@ -158,7 +158,7 @@ public:
FreeBSD,
Fuchsia,
IOS,
- KFreeBSD,
+ kFreeBSD,
Linux,
Lv2, // PS3
MacOSX,
@@ -575,8 +575,8 @@ public:
}
/// Tests whether the OS is kFreeBSD.
- bool isOSKFreeBSD() const {
- return getOS() == Triple::KFreeBSD;
+ bool isOSkFreeBSD() const {
+ return getOS() == Triple::kFreeBSD;
}
/// Tests whether the OS is Hurd.
@@ -586,7 +586,7 @@ public:
/// Tests whether the OS uses glibc.
bool isOSGlibc() const {
- return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
+ return (getOS() == Triple::Linux || getOS() == Triple::kFreeBSD ||
getOS() == Triple::Hurd) &&
!isAndroid();
}
Index: llvm-toolchain-7-7.0.1/libcxx/include/__config
===================================================================
--- llvm-toolchain-7-7.0.1.orig/libcxx/include/__config
+++ llvm-toolchain-7-7.0.1/libcxx/include/__config
@@ -1107,6 +1107,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
!defined(_LIBCPP_HAS_THREAD_API_WIN32) && \
!defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
# if defined(__FreeBSD__) || \
+ defined(__FreeBSD_kernel__) || \
defined(__Fuchsia__) || \
defined(__NetBSD__) || \
defined(__linux__) || \
Index: llvm-toolchain-7-7.0.1/openmp/runtime/src/kmp.h
===================================================================
--- llvm-toolchain-7-7.0.1.orig/openmp/runtime/src/kmp.h
+++ llvm-toolchain-7-7.0.1/openmp/runtime/src/kmp.h
@@ -1052,6 +1052,10 @@ extern kmp_uint64 __kmp_now_nsec();
/* TODO: tune for KMP_OS_HURD */
#define KMP_INIT_WAIT 1024U /* initial number of spin-tests */
#define KMP_NEXT_WAIT 512U /* susequent number of spin-tests */
+#elif KMP_OS_KFREEBSD
+/* TODO: tune for KMP_OS_KFREEBSD */
+#define KMP_INIT_WAIT 1024U /* initial number of spin-tests */
+#define KMP_NEXT_WAIT 512U /* susequent number of spin-tests */
#endif
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
Index: llvm-toolchain-7-7.0.1/openmp/runtime/src/kmp_ftn_entry.h
===================================================================
--- llvm-toolchain-7-7.0.1.orig/openmp/runtime/src/kmp_ftn_entry.h
+++ llvm-toolchain-7-7.0.1/openmp/runtime/src/kmp_ftn_entry.h
@@ -369,7 +369,7 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_
#else
int gtid;
-#if KMP_OS_DARWIN || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_HURD
+#if KMP_OS_DARWIN || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_HURD || KMP_OS_KFREEBSD
gtid = __kmp_entry_gtid();
#elif KMP_OS_WINDOWS
if (!__kmp_init_parallel ||
Index: llvm-toolchain-7-7.0.1/openmp/runtime/src/kmp_platform.h
===================================================================
--- llvm-toolchain-7-7.0.1.orig/openmp/runtime/src/kmp_platform.h
+++ llvm-toolchain-7-7.0.1/openmp/runtime/src/kmp_platform.h
@@ -18,6 +18,7 @@
#define KMP_OS_LINUX 0
#define KMP_OS_FREEBSD 0
+#define KMP_OS_KFREEBSD 0
#define KMP_OS_NETBSD 0
#define KMP_OS_DARWIN 0
#define KMP_OS_WINDOWS 0
@@ -50,6 +51,11 @@
#define KMP_OS_FREEBSD 1
#endif
+#if (defined __FreeBSD_kernel__)
+#undef KMP_OS_KFREEBSD
+#define KMP_OS_KFREEBSD 1
+#endif
+
#if (defined __NetBSD__)
#undef KMP_OS_NETBSD
#define KMP_OS_NETBSD 1
@@ -67,11 +73,11 @@
#if (1 != \
KMP_OS_LINUX + KMP_OS_FREEBSD + KMP_OS_NETBSD + KMP_OS_DARWIN + \
- KMP_OS_WINDOWS + KMP_OS_HURD)
+ KMP_OS_WINDOWS + KMP_OS_HURD + KMP_OS_KFREEBSD)
#error Unknown OS
#endif
-#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_DARWIN || KMP_OS_HURD
+#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_KFREEBSD || KMP_OS_NETBSD || KMP_OS_DARWIN || KMP_OS_HURD
#undef KMP_OS_UNIX
#define KMP_OS_UNIX 1
#endif
Index: llvm-toolchain-7-7.0.1/openmp/runtime/src/kmp_runtime.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/openmp/runtime/src/kmp_runtime.cpp
+++ llvm-toolchain-7-7.0.1/openmp/runtime/src/kmp_runtime.cpp
@@ -7643,7 +7643,7 @@ __kmp_determine_reduction_method(
#if KMP_ARCH_X86_64 || KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64
#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_WINDOWS || \
- KMP_OS_DARWIN || KMP_OS_HURD
+ KMP_OS_DARWIN || KMP_OS_HURD || KMP_OS_KFREEBSD
int teamsize_cutoff = 4;
@@ -7670,7 +7670,7 @@ __kmp_determine_reduction_method(
#elif KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_AARCH || KMP_ARCH_MIPS
-#if KMP_OS_LINUX || KMP_OS_WINDOWS || KMP_OS_HURD
+#if KMP_OS_LINUX || KMP_OS_WINDOWS || KMP_OS_HURD || KMP_OS_KFREEBSD
// basic tuning
Index: llvm-toolchain-7-7.0.1/openmp/runtime/src/z_Linux_util.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/openmp/runtime/src/z_Linux_util.cpp
+++ llvm-toolchain-7-7.0.1/openmp/runtime/src/z_Linux_util.cpp
@@ -444,7 +444,7 @@ void __kmp_terminate_thread(int gtid) {
determined exactly, FALSE if incremental refinement is necessary. */
static kmp_int32 __kmp_set_stack_info(int gtid, kmp_info_t *th) {
int stack_data;
-#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_HURD
+#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_NETBSD || KMP_OS_HURD || KMP_OS_KFREEBSD
pthread_attr_t attr;