Commit de8350ee authored by Sylvestre Ledru's avatar Sylvestre Ledru

kfreebsd support

parent d25bfbfc
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) {}
};
This diff is collapsed.
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;
int status;
size_t size = 0;
@@ -496,7 +496,7 @@ static void *__kmp_launch_worker(void *t
sigset_t new_set, old_set;
#endif /* KMP_BLOCK_SIGNALS */
void *exit_val;
-#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
void *volatile padding = 0;
#endif
int gtid;
@@ -1764,7 +1764,7 @@ static int __kmp_get_xproc(void) {
int r = 0;
-#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
r = sysconf(_SC_NPROCESSORS_ONLN);
@@ -1952,7 +1952,7 @@ int __kmp_is_address_mapped(void *addr)
int found = 0;
int rc;
-#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_HURD
+#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_HURD || KMP_OS_KFREEBSD
/* On GNUish OSes, read the /proc/<pid>/maps pseudo-file to get all the address
ranges mapped into the address space. */
Index: llvm-toolchain-7-7.0.1/libcxx/src/thread.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/libcxx/src/thread.cpp
+++ llvm-toolchain-7-7.0.1/libcxx/src/thread.cpp
@@ -19,7 +19,7 @@
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
# include <sys/param.h>
-# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__)
+# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__) || defined(__FreeBSD_kernel__)
# include <sys/sysctl.h>
# endif
#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
This diff is collapsed.
Index: llvm-toolchain-7-7.0.1/unittests/ADT/TripleTest.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/unittests/ADT/TripleTest.cpp
+++ llvm-toolchain-7-7.0.1/unittests/ADT/TripleTest.cpp
@@ -99,6 +99,18 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::Hurd, T.getOS());
EXPECT_EQ(Triple::GNU, T.getEnvironment());
+ T = Triple("i386-pc-kfreebsd-gnu");
+ EXPECT_EQ(Triple::x86, T.getArch());
+ EXPECT_EQ(Triple::PC, T.getVendor());
+ EXPECT_EQ(Triple::kFreeBSD, T.getOS());
+ EXPECT_EQ(Triple::GNU, T.getEnvironment());
+
+ T = Triple("x86_64-pc-kfreebsd-gnu");
+ EXPECT_EQ(Triple::x86_64, T.getArch());
+ EXPECT_EQ(Triple::PC, T.getVendor());
+ EXPECT_EQ(Triple::kFreeBSD, T.getOS());
+ EXPECT_EQ(Triple::GNU, T.getEnvironment());
+
T = Triple("x86_64-pc-linux-gnu");
EXPECT_EQ(Triple::x86_64, T.getArch());
EXPECT_EQ(Triple::PC, T.getVendor());
Index: llvm-toolchain-7-7.0.1/lib/Support/Triple.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/lib/Support/Triple.cpp
+++ llvm-toolchain-7-7.0.1/lib/Support/Triple.cpp
@@ -185,7 +185,7 @@ StringRef Triple::getOSTypeName(OSType K
case FreeBSD: return "freebsd";
case Fuchsia: return "fuchsia";
case IOS: return "ios";
- case KFreeBSD: return "kfreebsd";
+ case kFreeBSD: return "kfreebsd";
case Linux: return "linux";
case Lv2: return "lv2";
case MacOSX: return "macosx";
@@ -478,7 +478,7 @@ static Triple::OSType parseOS(StringRef
.StartsWith("freebsd", Triple::FreeBSD)
.StartsWith("fuchsia", Triple::Fuchsia)
.StartsWith("ios", Triple::IOS)
- .StartsWith("kfreebsd", Triple::KFreeBSD)
+ .StartsWith("kfreebsd", Triple::kFreeBSD)
.StartsWith("linux", Triple::Linux)
.StartsWith("lv2", Triple::Lv2)
.StartsWith("macos", Triple::MacOSX)
Index: llvm-toolchain-7-7.0.1/lib/Support/Unix/Path.inc
===================================================================
--- llvm-toolchain-7-7.0.1.orig/lib/Support/Unix/Path.inc
+++ llvm-toolchain-7-7.0.1/lib/Support/Unix/Path.inc
@@ -54,13 +54,13 @@
#include <sys/types.h>
#if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && \
- !defined(__linux__)
+ !defined(__linux__) && !defined(__FreeBSD_kernel__)
#include <sys/statvfs.h>
#define STATVFS statvfs
#define FSTATVFS fstatvfs
#define STATVFS_F_FRSIZE(vfs) vfs.f_frsize
#else
-#if defined(__OpenBSD__) || defined(__FreeBSD__)
+#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <sys/mount.h>
#include <sys/param.h>
#elif defined(__linux__)
Index: llvm-toolchain-7-7.0.1/lib/Target/X86/X86Subtarget.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/lib/Target/X86/X86Subtarget.cpp
+++ llvm-toolchain-7-7.0.1/lib/Target/X86/X86Subtarget.cpp
@@ -270,7 +270,7 @@ void X86Subtarget::initSubtargetFeatures
if (StackAlignOverride)
stackAlignment = StackAlignOverride;
else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() ||
- isTargetKFreeBSD() || In64BitMode)
+ isTargetkFreeBSD() || In64BitMode)
stackAlignment = 16;
// Some CPUs have more overhead for gather. The specified overhead is relative
Index: llvm-toolchain-7-7.0.1/lib/Target/X86/X86Subtarget.h
===================================================================
--- llvm-toolchain-7-7.0.1.orig/lib/Target/X86/X86Subtarget.h
+++ llvm-toolchain-7-7.0.1/lib/Target/X86/X86Subtarget.h
@@ -708,7 +708,7 @@ public:
bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
- bool isTargetKFreeBSD() const { return TargetTriple.isOSKFreeBSD(); }
+ bool isTargetkFreeBSD() const { return TargetTriple.isOSkFreeBSD(); }
bool isTargetGlibc() const { return TargetTriple.isOSGlibc(); }
bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
usr/lib/llvm-7/lib/liblldb-7.so.1 /usr/lib/i386-kfreebsd-gnu/
usr/lib/llvm-7/lib/python2.7/site-packages/readline.so
Index: llvm-toolchain-7-7.0.1/lldb/source/Host/freebsd/Host.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/lldb/source/Host/freebsd/Host.cpp
+++ llvm-toolchain-7-7.0.1/lldb/source/Host/freebsd/Host.cpp
@@ -12,6 +12,13 @@
#include <sys/types.h>
#include <sys/exec.h>
+#ifdef __FreeBSD_kernel__
+# ifdef __amd64__
+# include </usr/include/x86_64-kfreebsd-gnu/sys/kglue/sys/types.h>
+# else
+# include </usr/include/i386-kfreebsd-gnu/sys/kglue/sys/types.h>
+# endif
+#endif
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/sysctl.h>
Index: llvm-toolchain-7-7.0.1/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
+++ llvm-toolchain-7-7.0.1/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
@@ -10,7 +10,9 @@
// C Includes
#include <errno.h>
#include <pthread.h>
+#ifndef __FreeBSD_kernel__
#include <pthread_np.h>
+#endif
#include <stdlib.h>
#include <sys/sysctl.h>
#include <sys/types.h>
Index: llvm-toolchain-7-7.0.1/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
===================================================================
--- llvm-toolchain-7-7.0.1.orig/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ llvm-toolchain-7-7.0.1/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -11,7 +11,9 @@
// C Includes
#include <errno.h>
#include <pthread.h>
+#ifndef __FreeBSD_kernel__
#include <pthread_np.h>
+#endif
#include <stdlib.h>
#include <sys/sysctl.h>
#include <sys/types.h>
Index: llvm-toolchain-7-7.0.1/tools/llvm-shlib/CMakeLists.txt
===================================================================
--- llvm-toolchain-7-7.0.1.orig/tools/llvm-shlib/CMakeLists.txt
+++ llvm-toolchain-7-7.0.1/tools/llvm-shlib/CMakeLists.txt
@@ -40,6 +40,7 @@ set_property(TARGET LLVM PROPERTY VERSIO
list(REMOVE_DUPLICATES LIB_NAMES)
if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU)
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
+ OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "kFreeBSD")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
......@@ -135,3 +135,19 @@ D54409-powerpcspe-register-spilling.diff
D54584-powerpcspe-double-parameter.diff
D52340-rustc-debuginfo.diff
# kfreebsd
kfreebsd/clang_lib_Basic_Targets.diff
kfreebsd/CMakeLists.txt.diff
kfreebsd/compiler-rt_lib.diff
kfreebsd/include_llvm_ADT_Triple.h.diff
kfreebsd/kfreebsd-libcxx-threads-detection.diff
kfreebsd/kfreebsd-openmp.diff
kfreebsd/kfreebsd-threads-build.diff
kfreebsd/kfreebsd-triple-clang.diff
kfreebsd/kfreebsd-triple.diff
kfreebsd/liblldb-7.install.kfreebsd
kfreebsd/lib_Support.diff
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment