tags 761650 + patch thanks On 09/10/14 14:23, Steven Chamberlain wrote: > I just finished a test-build on kfreebsd-amd64 (this took 34 hours [...]
> there are still problems with > linker path and C++ includes. Hi again, I think the attached, updated patches will fix all three issues: * kfreebsd-* FTBFS building lldb * kfreebsd-amd64 linker path is missing GNU libc libraries * kfreebsd (and possibly other arches?) C++ include path is missing GCC includes although it will take me several hours to build and test. Thanks, Regards, -- Steven Chamberlain ste...@pyro.eu.org
--- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1974,6 +1974,8 @@ TC = new toolchains::Minix(*this, Target, Args); break; case llvm::Triple::Linux: + case llvm::Triple::KFreeBSD: /* GNU/kFreeBSD is more + similar to a GNU/Linux install than a FreeBSD install */ if (Target.getArch() == llvm::Triple::hexagon) TC = new toolchains::Hexagon_TC(*this, Target, Args); else --- a/clang/lib/Driver/ToolChains.cpp +++ b/clang/lib/Driver/ToolChains.cpp @@ -1336,7 +1336,7 @@ "x86_64-linux-gnu", "x86_64-unknown-linux-gnu", "x86_64-pc-linux-gnu", "x86_64-redhat-linux6E", "x86_64-redhat-linux", "x86_64-suse-linux", "x86_64-manbo-linux-gnu", "x86_64-linux-gnu", "x86_64-slackware-linux", - "x86_64-linux-android", "x86_64-unknown-linux" + "x86_64-linux-android", "x86_64-unknown-linux", "x86_64-kfreebsd-gnu" }; static const char *const X32LibDirs[] = { "/libx32" }; static const char *const X86LibDirs[] = { "/lib32", "/lib" }; @@ -1344,7 +1344,8 @@ "i686-linux-gnu", "i686-pc-linux-gnu", "i486-linux-gnu", "i386-linux-gnu", "i386-redhat-linux6E", "i686-redhat-linux", "i586-redhat-linux", "i386-redhat-linux", "i586-suse-linux", "i486-slackware-linux", - "i686-montavista-linux", "i686-linux-android", "i586-linux-gnu" + "i686-montavista-linux", "i686-linux-android", "i586-linux-gnu", + "i386-kfreebsd-gnu", "i486-kfreebsd-gnu", "i586-kfreebsd-gnu" }; static const char *const MIPSLibDirs[] = { "/lib" }; @@ -2934,12 +2935,17 @@ case llvm::Triple::x86: if (llvm::sys::fs::exists(SysRoot + "/lib/i386-linux-gnu")) return "i386-linux-gnu"; + if (llvm::sys::fs::exists(SysRoot + "/lib/i386-kfreebsd-gnu")) + return "i386-kfreebsd-gnu"; + return TargetTriple.str(); case llvm::Triple::x86_64: // We don't want this for x32, otherwise it will match x86_64 libs if (TargetTriple.getEnvironment() != llvm::Triple::GNUX32 && llvm::sys::fs::exists(SysRoot + "/lib/x86_64-linux-gnu")) return "x86_64-linux-gnu"; + if (llvm::sys::fs::exists(SysRoot + "/lib/x86_64-kfreebsd-gnu")) + return "x86_64-kfreebsd-gnu"; return TargetTriple.str(); case llvm::Triple::arm64: case llvm::Triple::aarch64: @@ -3247,6 +3253,10 @@ if (DriverArgs.hasArg(options::OPT_nostdinc)) return; + // Under Debian, clang headers are installed into + // '/usr/include/clang/VERSION/include/' + addSystemInclude(DriverArgs, CC1Args, "/usr/include/clang/" + std::string(CLANG_VERSION_STRING) + "/include/"); + if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include"); @@ -3299,6 +3309,9 @@ const StringRef X86_64MultiarchIncludeDirs[] = { "/usr/include/x86_64-linux-gnu", + // GNU/kFreeBSD + "/usr/include/x86_64-kfreebsd-gnu", + // FIXME: These are older forms of multiarch. It's not clear that they're // in use in any released version of Debian, so we should consider // removing them. @@ -3307,6 +3320,9 @@ const StringRef X86MultiarchIncludeDirs[] = { "/usr/include/i386-linux-gnu", + // GNU/kFreeBSD + "/usr/include/i386-kfreebsd-gnu", + // FIXME: These are older forms of multiarch. It's not clear that they're // in use in any released version of Debian, so we should consider // removing them. --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -7177,6 +7177,12 @@ static StringRef getLinuxDynamicLinker(const ArgList &Args, const toolchains::Linux &ToolChain) { +#ifdef __FreeBSD_kernel__ + if (ToolChain.getArch() == llvm::Triple::x86) + return "/lib/ld.so.1"; + else + return "/lib/ld-kfreebsd-x86-64.so.1"; +#else if (ToolChain.getTriple().getEnvironment() == llvm::Triple::Android) { if (ToolChain.getTriple().isArch64Bit()) return "/system/bin/linker64"; @@ -7229,6 +7235,7 @@ return "/libx32/ld-linux-x32.so.2"; else return "/lib64/ld-linux-x86-64.so.2"; +#endif } static void AddRunTimeLibs(const ToolChain &TC, const Driver &D, @@ -7296,6 +7303,11 @@ CmdArgs.push_back("-m"); if (ToolChain.getArch() == llvm::Triple::x86) +#ifdef __FreeBSD_kernel__ + CmdArgs.push_back("elf_i386_fbsd"); + else + CmdArgs.push_back("elf_x86_64_fbsd"); +#else CmdArgs.push_back("elf_i386"); else if (ToolChain.getArch() == llvm::Triple::aarch64 || ToolChain.getArch() == llvm::Triple::arm64) @@ -7342,6 +7354,7 @@ CmdArgs.push_back("elf32_x86_64"); else CmdArgs.push_back("elf_x86_64"); +#endif if (Args.hasArg(options::OPT_static)) { if (ToolChain.getArch() == llvm::Triple::arm ||
%diff --git llvm-toolchain-snapshot_3.5~svn201241.orig/lldllvm-toolchain-snapshot_3.5~svn201241/lldb/source/Host/freebsd/Host.cpp llvm-toolchain-snapshot_3.5~svn201241/lldb/source/Host/freebsd/Host.cpp index 4f6af67..47cbb25 100644 --- a/lldb/source/Host/freebsd/Host.cpp +++ b/lldb/source/Host/freebsd/Host.cpp @@ -83,6 +83,18 @@ Host::SetShortThreadName (LLDB_INVALID_PROCESS_ID, LLDB_INVALID_THREAD_ID, thread_name, 16); } +// Debian kFreeBSD uses the FreeBSD kernel with a GNU libc +#ifdef __GLIBC__ +static inline void * +reallocf(void *ptr, size_t size) +{ + void *rv = realloc(ptr, size); + if (rv == NULL) + free(ptr); + return rv; +} +#endif + std::string Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid) {
--- a/lldb/tools/Makefile +++ b/lldb/tools/Makefile @@ -25,7 +25,7 @@ DIRS += debugserver endif -ifeq ($(HOST_OS),Linux) +ifneq (,$(strip $(filter $(HOST_OS), Linux GNU GNU/kFreeBSD))) DIRS += lldb-mi endif --- a/lldb/tools/lldb-mi/MICmnLogMediumFile.cpp +++ b/lldb/tools/lldb-mi/MICmnLogMediumFile.cpp @@ -28,7 +28,7 @@ #if defined( _MSC_VER ) #include "MIUtilSystemWindows.h" -#elif defined( __FreeBSD__ ) || defined( __linux__ ) +#elif defined( __FreeBSD_kernel__ ) || defined( __linux__ ) #include "MIUtilSystemLinux.h" #elif defined( __APPLE__ ) #include "MIUtilSystemOsx.h" --- a/lldb/tools/lldb-mi/MIUtilSystemLinux.h +++ b/lldb/tools/lldb-mi/MIUtilSystemLinux.h @@ -24,7 +24,7 @@ // Include compiler configuration #include "MICmnConfig.h" -#if defined( __FreeBSD__ ) || defined( __linux__ ) +#if defined( __FreeBSD_kernel__ ) || defined( __linux__ ) // In-house headers: #include "MIUtilString.h" --- a/lldb/tools/lldb-mi/MIUtilSystemLinux.cpp +++ b/lldb/tools/lldb-mi/MIUtilSystemLinux.cpp @@ -22,7 +22,7 @@ // Include compiler configuration #include "MICmnConfig.h" -#if defined( __FreeBSD__ ) || defined( __linux__ ) +#if defined( __FreeBSD_kernel__ ) || defined( __linux__ ) // In-house headers: #include "MIUtilSystemLinux.h"