- add OpenBSD config; from jsg@.

- install a symlink as a workaround to a bug identifying the path to clang-cc.

commit approved by naddy.
This commit is contained in:
sthen 2009-06-25 15:25:13 +00:00
parent 8dbbda04e5
commit e6fe633831
12 changed files with 473 additions and 3 deletions

View File

@ -1,11 +1,11 @@
# $OpenBSD: Makefile,v 1.12 2009/06/24 20:23:12 sthen Exp $
# $OpenBSD: Makefile,v 1.13 2009/06/25 15:25:13 sthen Exp $
COMMENT = Low Level Virtual Machine (LLVM) compiler infrastructure
LLVM_V = 2.6pre20090621
DISTNAME = llvm-${LLVM_V}
EXTRACT_SUFX = .tar.bz2
PKGNAME = ${DISTNAME}p0
PKGNAME = ${DISTNAME}p1
CATEGORIES = devel
@ -63,8 +63,10 @@ pre-configure:
@ln -s ${MODPY_BIN} ${WRKDIR}/bin/python
# XXX googletest doesn't build
# XXX symlink to workaround problem finding the correct clang binary path
post-install:
@ln -s ${TRUEPREFIX}/libexec/clang-cc ${PREFIX}/bin
@${INSTALL_DATA_DIR} ${PREFIX}/share/llvm
@${INSTALL_DATA_DIR} ${WRKINST}/${MODPY_SITEPKG}
@${INSTALL_SCRIPT} ${WRKSRC}/tools/clang/utils/ccc-analyzer \

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-include_llvm_ADT_Triple_h,v 1.1 2009/06/25 15:25:13 sthen Exp $
--- include/llvm/ADT/Triple.h.orig Tue Jun 23 11:49:14 2009
+++ include/llvm/ADT/Triple.h Tue Jun 23 11:50:07 2009
@@ -52,6 +52,7 @@ class Triple { (public)
AuroraUX,
Darwin,
DragonFly,
+ OpenBSD,
FreeBSD,
Linux
};

View File

@ -0,0 +1,20 @@
$OpenBSD: patch-lib_Support_Triple_cpp,v 1.1 2009/06/25 15:25:13 sthen Exp $
--- lib/Support/Triple.cpp.orig Tue Jun 23 11:52:16 2009
+++ lib/Support/Triple.cpp Tue Jun 23 11:53:41 2009
@@ -46,6 +46,7 @@ const char *Triple::getOSTypeName(OSType Kind) {
case AuroraUX: return "auroraux";
case Darwin: return "darwin";
case DragonFly: return "dragonfly";
+ case OpenBSD: return "openbsd";
case FreeBSD: return "freebsd";
case Linux: return "linux";
}
@@ -86,6 +87,8 @@ void Triple::Parse() const {
OS = Darwin;
else if (memcmp(&OSName[0], "dragonfly", 9) == 0)
OS = DragonFly;
+ else if (memcmp(&OSName[0], "openbsd", 7) == 0)
+ OS = OpenBSD;
else if (memcmp(&OSName[0], "freebsd", 7) == 0)
OS = FreeBSD;
else if (memcmp(&OSName[0], "linux", 5) == 0)

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-tools_clang_include_clang_Driver_HostInfo_h,v 1.1 2009/06/25 15:25:13 sthen Exp $
--- tools/clang/include/clang/Driver/HostInfo.h.orig Tue Jun 23 10:36:52 2009
+++ tools/clang/include/clang/Driver/HostInfo.h Tue Jun 23 10:37:22 2009
@@ -69,6 +69,8 @@ class HostInfo { (public)
const HostInfo *createDarwinHostInfo(const Driver &D,
const llvm::Triple& Triple);
+const HostInfo *createOpenBSDHostInfo(const Driver &D,
+ const llvm::Triple& Triple);
const HostInfo *createFreeBSDHostInfo(const Driver &D,
const llvm::Triple& Triple);
const HostInfo *createDragonFlyHostInfo(const Driver &D,

View File

@ -0,0 +1,91 @@
$OpenBSD: patch-tools_clang_lib_Basic_Targets_cpp,v 1.1 2009/06/25 15:25:13 sthen Exp $
--- tools/clang/lib/Basic/Targets.cpp.orig Tue Jun 23 10:26:43 2009
+++ tools/clang/lib/Basic/Targets.cpp Tue Jun 23 10:26:50 2009
@@ -70,6 +70,19 @@ static void getSolarisDefines(const LangOptions &Opts,
Define(Defs, "__SVR4");
}
+static void getOpenBSDDefines(const LangOptions &Opts, bool is64Bit,
+ const char *Triple, std::vector<char> &Defs) {
+ // OpenBSD defines; list based off of gcc output
+
+ Define(Defs, "__OpenBSD__", "1");
+ Define(Defs, "__KPRINTF_ATTRIBUTE__");
+ DefineStd(Defs, "unix", Opts);
+ Define(Defs, "__ELF__", "1");
+ if (is64Bit) {
+ Define(Defs, "__LP64__");
+ }
+}
+
static void getFreeBSDDefines(const LangOptions &Opts, bool is64Bit,
const char *Triple, std::vector<char> &Defs) {
// FreeBSD defines; list based off of gcc output
@@ -862,6 +875,20 @@ class DarwinI386TargetInfo : public X86_32TargetInfo {
} // end anonymous namespace
namespace {
+// x86-32 OpenBSD target
+class OpenBSDX86_32TargetInfo : public X86_32TargetInfo {
+public:
+ OpenBSDX86_32TargetInfo(const std::string& triple) :
+ X86_32TargetInfo(triple) { }
+ virtual void getTargetDefines(const LangOptions &Opts,
+ std::vector<char> &Defines) const {
+ X86_32TargetInfo::getTargetDefines(Opts, Defines);
+ getOpenBSDDefines(Opts, 0, getTargetTriple(), Defines);
+ }
+};
+} // end anonymous namespace
+
+namespace {
// x86-32 FreeBSD target
class FreeBSDX86_32TargetInfo : public X86_32TargetInfo {
public:
@@ -983,6 +1010,20 @@ class X86_64TargetInfo : public X86TargetInfo { (publi
} // end anonymous namespace
namespace {
+// x86-64 OpenBSD target
+class OpenBSDX86_64TargetInfo : public X86_64TargetInfo {
+public:
+ OpenBSDX86_64TargetInfo(const std::string &triple)
+ : X86_64TargetInfo(triple) {}
+ virtual void getTargetDefines(const LangOptions &Opts,
+ std::vector<char> &Defines) const {
+ X86_64TargetInfo::getTargetDefines(Opts, Defines);
+ getOpenBSDDefines(Opts, 1, getTargetTriple(), Defines);
+ }
+};
+} // end anonymous namespace
+
+namespace {
// x86-64 FreeBSD target
class FreeBSDX86_64TargetInfo : public X86_64TargetInfo {
public:
@@ -1453,6 +1494,7 @@ TargetInfo* TargetInfo::CreateTargetInfo(const std::st
// Additions and corrections are welcome.
bool isDarwin = T.find("-darwin") != std::string::npos;
bool isDragonFly = T.find("-dragonfly") != std::string::npos;
+ bool isOpenBSD = T.find("-openbsd") != std::string::npos;
bool isFreeBSD = T.find("-freebsd") != std::string::npos;
bool isSolaris = T.find("-solaris") != std::string::npos;
bool isLinux = T.find("-linux") != std::string::npos;
@@ -1491,6 +1533,8 @@ TargetInfo* TargetInfo::CreateTargetInfo(const std::st
return new DarwinX86_64TargetInfo(T);
if (isLinux)
return new LinuxX86_64TargetInfo(T);
+ if (isOpenBSD)
+ return new OpenBSDX86_64TargetInfo(T);
if (isFreeBSD)
return new FreeBSDX86_64TargetInfo(T);
if (isSolaris)
@@ -1511,6 +1555,8 @@ TargetInfo* TargetInfo::CreateTargetInfo(const std::st
return new LinuxX86_32TargetInfo(T);
if (isDragonFly)
return new DragonFlyX86_32TargetInfo(T);
+ if (isOpenBSD)
+ return new OpenBSDX86_32TargetInfo(T);
if (isFreeBSD)
return new FreeBSDX86_32TargetInfo(T);
if (isSolaris)

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-tools_clang_lib_Driver_Driver_cpp,v 1.1 2009/06/25 15:25:13 sthen Exp $
--- tools/clang/lib/Driver/Driver.cpp.orig Tue Jun 23 10:35:26 2009
+++ tools/clang/lib/Driver/Driver.cpp Tue Jun 23 10:35:59 2009
@@ -1205,6 +1205,8 @@ const HostInfo *Driver::GetHostInfo(const char *Triple
return createDarwinHostInfo(*this, Triple);
case llvm::Triple::DragonFly:
return createDragonFlyHostInfo(*this, Triple);
+ case llvm::Triple::OpenBSD:
+ return createOpenBSDHostInfo(*this, Triple);
case llvm::Triple::FreeBSD:
return createFreeBSDHostInfo(*this, Triple);
case llvm::Triple::Linux:

View File

@ -0,0 +1,74 @@
$OpenBSD: patch-tools_clang_lib_Driver_HostInfo_cpp,v 1.1 2009/06/25 15:25:13 sthen Exp $
--- tools/clang/lib/Driver/HostInfo.cpp.orig Tue Jun 16 23:46:01 2009
+++ tools/clang/lib/Driver/HostInfo.cpp Tue Jun 23 13:25:41 2009
@@ -234,6 +234,57 @@ ToolChain *UnknownHostInfo::getToolChain(const ArgList
return TC;
}
+// OpenBSD Host Info
+
+/// OpenBSDHostInfo - OpenBSD host information implementation.
+class OpenBSDHostInfo : public HostInfo {
+ /// Cache of tool chains we have created.
+ mutable llvm::StringMap<ToolChain*> ToolChains;
+
+public:
+ OpenBSDHostInfo(const Driver &D, const llvm::Triple& Triple)
+ : HostInfo(D, Triple) {}
+ ~OpenBSDHostInfo();
+
+ virtual bool useDriverDriver() const;
+
+ virtual types::ID lookupTypeForExtension(const char *Ext) const {
+ return types::lookupTypeForExtension(Ext);
+ }
+
+ virtual ToolChain *getToolChain(const ArgList &Args,
+ const char *ArchName) const;
+};
+
+OpenBSDHostInfo::~OpenBSDHostInfo() {
+ for (llvm::StringMap<ToolChain*>::iterator
+ it = ToolChains.begin(), ie = ToolChains.end(); it != ie; ++it)
+ delete it->second;
+}
+
+bool OpenBSDHostInfo::useDriverDriver() const {
+ return false;
+}
+
+ToolChain *OpenBSDHostInfo::getToolChain(const ArgList &Args,
+ const char *ArchName) const {
+ assert(!ArchName &&
+ "Unexpected arch name on platform without driver driver support.");
+
+ std::string Arch = getArchName();
+ ArchName = Arch.c_str();
+
+ ToolChain *&TC = ToolChains[ArchName];
+ if (!TC) {
+ llvm::Triple TCTriple(getTriple());
+ TCTriple.setArchName(ArchName);
+
+ TC = new toolchains::OpenBSD(*this, TCTriple);
+ }
+
+ return TC;
+}
+
// FreeBSD Host Info
/// FreeBSDHostInfo - FreeBSD host information implementation.
@@ -414,6 +465,12 @@ const HostInfo *
clang::driver::createDarwinHostInfo(const Driver &D,
const llvm::Triple& Triple){
return new DarwinHostInfo(D, Triple);
+}
+
+const HostInfo *
+clang::driver::createOpenBSDHostInfo(const Driver &D,
+ const llvm::Triple& Triple) {
+ return new OpenBSDHostInfo(D, Triple);
}
const HostInfo *

View File

@ -0,0 +1,40 @@
$OpenBSD: patch-tools_clang_lib_Driver_ToolChains_cpp,v 1.1 2009/06/25 15:25:13 sthen Exp $
--- tools/clang/lib/Driver/ToolChains.cpp.orig Tue Jun 23 13:03:05 2009
+++ tools/clang/lib/Driver/ToolChains.cpp Tue Jun 23 13:01:50 2009
@@ -384,6 +384,36 @@ DerivedArgList *Generic_GCC::TranslateArgs(InputArgLis
return new DerivedArgList(Args, true);
}
+/// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
+
+OpenBSD::OpenBSD(const HostInfo &Host, const llvm::Triple& Triple)
+ : Generic_GCC(Host, Triple) {
+ getFilePaths().push_back(getHost().getDriver().Dir + "/../lib");
+ getFilePaths().push_back("/usr/lib");
+}
+
+Tool &OpenBSD::SelectTool(const Compilation &C, const JobAction &JA) const {
+ Action::ActionClass Key;
+ if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName()))
+ Key = Action::AnalyzeJobClass;
+ else
+ Key = JA.getKind();
+
+ Tool *&T = Tools[Key];
+ if (!T) {
+ switch (Key) {
+ case Action::AssembleJobClass:
+ T = new tools::openbsd::Assemble(*this); break;
+ case Action::LinkJobClass:
+ T = new tools::openbsd::Link(*this); break;
+ default:
+ T = &Generic_GCC::SelectTool(C, JA);
+ }
+ }
+
+ return *T;
+}
+
/// FreeBSD - FreeBSD tool chain which can call as(1) and ld(1) directly.
FreeBSD::FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32)

View File

@ -0,0 +1,17 @@
$OpenBSD: patch-tools_clang_lib_Driver_ToolChains_h,v 1.1 2009/06/25 15:25:13 sthen Exp $
--- tools/clang/lib/Driver/ToolChains.h.orig Tue Jun 23 13:16:32 2009
+++ tools/clang/lib/Driver/ToolChains.h Tue Jun 23 13:17:32 2009
@@ -107,6 +107,13 @@ class VISIBILITY_HIDDEN Darwin_GCC : public Generic_GC
virtual const char *GetDefaultRelocationModel() const { return "pic"; }
};
+class VISIBILITY_HIDDEN OpenBSD : public Generic_GCC {
+public:
+ OpenBSD(const HostInfo &Host, const llvm::Triple& Triple);
+
+ virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
+};
+
class VISIBILITY_HIDDEN FreeBSD : public Generic_GCC {
public:
FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32);

View File

@ -0,0 +1,145 @@
$OpenBSD: patch-tools_clang_lib_Driver_Tools_cpp,v 1.1 2009/06/25 15:25:13 sthen Exp $
--- tools/clang/lib/Driver/Tools.cpp.orig Mon Jun 8 23:48:20 2009
+++ tools/clang/lib/Driver/Tools.cpp Thu Jun 25 10:01:13 2009
@@ -1747,6 +1747,141 @@ void darwin::Lipo::ConstructJob(Compilation &C, const
Dest.addCommand(new Command(Exec, CmdArgs));
}
+void openbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest, const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &Args,
+ const char *LinkingOutput) const
+{
+ ArgStringList CmdArgs;
+
+ Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
+ options::OPT_Xassembler);
+
+ CmdArgs.push_back("-o");
+ if (Output.isPipe())
+ CmdArgs.push_back("-");
+ else
+ CmdArgs.push_back(Output.getFilename());
+
+ for (InputInfoList::const_iterator
+ it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) {
+ const InputInfo &II = *it;
+ if (II.isPipe())
+ CmdArgs.push_back("-");
+ else
+ CmdArgs.push_back(II.getFilename());
+ }
+
+ const char *Exec =
+ Args.MakeArgString(getToolChain().GetProgramPath(C, "as").c_str());
+ Dest.addCommand(new Command(Exec, CmdArgs));
+}
+
+void openbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest, const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &Args,
+ const char *LinkingOutput) const {
+ const Driver &D = getToolChain().getHost().getDriver();
+ ArgStringList CmdArgs;
+
+ if (Args.hasArg(options::OPT_static)) {
+ CmdArgs.push_back("-Bstatic");
+ } else {
+ CmdArgs.push_back("--eh-frame-hdr");
+ if (Args.hasArg(options::OPT_shared)) {
+ CmdArgs.push_back("-Bshareable");
+ } else {
+ CmdArgs.push_back("-dynamic-linker");
+ CmdArgs.push_back("/usr/libexec/ld.so");
+ }
+ }
+
+ if (Output.isPipe()) {
+ CmdArgs.push_back("-o");
+ CmdArgs.push_back("-");
+ } else if (Output.isFilename()) {
+ CmdArgs.push_back("-o");
+ CmdArgs.push_back(Output.getFilename());
+ } else {
+ assert(Output.isNothing() && "Invalid output.");
+ }
+
+ if (!Args.hasArg(options::OPT_nostdlib) &&
+ !Args.hasArg(options::OPT_nostartfiles)) {
+ if (!Args.hasArg(options::OPT_shared)) {
+ CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crt0.o").c_str()));
+ CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbegin.o").c_str()));
+ } else {
+ CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbeginS.o").c_str()));
+ }
+ }
+
+ Args.AddAllArgs(CmdArgs, options::OPT_L);
+ Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
+ Args.AddAllArgs(CmdArgs, options::OPT_e);
+
+ for (InputInfoList::const_iterator
+ it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) {
+ const InputInfo &II = *it;
+
+ // Don't try to pass LLVM inputs to a generic gcc.
+ if (II.getType() == types::TY_LLVMBC)
+ D.Diag(clang::diag::err_drv_no_linker_llvm_support)
+ << getToolChain().getTripleString().c_str();
+
+ if (II.isPipe())
+ CmdArgs.push_back("-");
+ else if (II.isFilename())
+ CmdArgs.push_back(II.getFilename());
+ else
+ II.getInputArg().renderAsInput(Args, CmdArgs);
+ }
+
+ if (!Args.hasArg(options::OPT_nostdlib) &&
+ !Args.hasArg(options::OPT_nodefaultlibs)) {
+#if 0
+ // FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding
+ // the default system libraries. Just mimic this for now.
+ CmdArgs.push_back("-lgcc");
+ if (Args.hasArg(options::OPT_static)) {
+ CmdArgs.push_back("-lgcc_eh");
+ } else {
+ CmdArgs.push_back("--as-needed");
+ CmdArgs.push_back("-lgcc_s");
+ CmdArgs.push_back("--no-as-needed");
+ }
+#endif
+
+ if (Args.hasArg(options::OPT_pthread))
+ CmdArgs.push_back("-pthread");
+ CmdArgs.push_back("-lc");
+
+#if 0
+ CmdArgs.push_back("-lgcc");
+ if (Args.hasArg(options::OPT_static)) {
+ CmdArgs.push_back("-lgcc_eh");
+ } else {
+ CmdArgs.push_back("--as-needed");
+ CmdArgs.push_back("-lgcc_s");
+ CmdArgs.push_back("--no-as-needed");
+ }
+#endif
+ }
+
+ if (!Args.hasArg(options::OPT_nostdlib) &&
+ !Args.hasArg(options::OPT_nostartfiles)) {
+ if (!Args.hasArg(options::OPT_shared))
+ CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtend.o").c_str()));
+ else
+ CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtendS.o").c_str()));
+ }
+
+ const char *Exec =
+ Args.MakeArgString(getToolChain().GetProgramPath(C, "ld").c_str());
+ Dest.addCommand(new Command(Exec, CmdArgs));
+}
void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,

View File

@ -0,0 +1,44 @@
$OpenBSD: patch-tools_clang_lib_Driver_Tools_h,v 1.1 2009/06/25 15:25:13 sthen Exp $
--- tools/clang/lib/Driver/Tools.h.orig Tue Jun 23 13:21:18 2009
+++ tools/clang/lib/Driver/Tools.h Tue Jun 23 13:22:51 2009
@@ -241,6 +241,40 @@ namespace darwin {
};
}
+ /// openbsd -- Directly call GNU Binutils assembler and linker
+namespace openbsd {
+ class VISIBILITY_HIDDEN Assemble : public Tool {
+ public:
+ Assemble(const ToolChain &TC) : Tool("openbsd::Assemble", TC) {}
+
+ virtual bool acceptsPipedInput() const { return true; }
+ virtual bool canPipeOutput() const { return true; }
+ virtual bool hasIntegratedCPP() const { return false; }
+
+ virtual void ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
+ const char *LinkingOutput) const;
+ };
+ class VISIBILITY_HIDDEN Link : public Tool {
+ public:
+ Link(const ToolChain &TC) : Tool("openbsd::Link", TC) {}
+
+ virtual bool acceptsPipedInput() const { return true; }
+ virtual bool canPipeOutput() const { return true; }
+ virtual bool hasIntegratedCPP() const { return false; }
+
+ virtual void ConstructJob(Compilation &C, const JobAction &JA,
+ Job &Dest,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
+ const char *LinkingOutput) const;
+ };
+}
+
/// freebsd -- Directly call GNU Binutils assembler and linker
namespace freebsd {
class VISIBILITY_HIDDEN Assemble : public Tool {

View File

@ -1,7 +1,8 @@
@comment $OpenBSD: PLIST,v 1.6 2009/06/22 00:19:02 sthen Exp $
@comment $OpenBSD: PLIST,v 1.7 2009/06/25 15:25:13 sthen Exp $
@bin bin/bugpoint
bin/ccc-analyzer
@bin bin/clang
bin/clang-cc
bin/gccas
bin/gccld
@bin bin/llc
@ -76,6 +77,7 @@ include/llvm/ADT/StringSet.h
include/llvm/ADT/Tree.h
include/llvm/ADT/Trie.h
include/llvm/ADT/Triple.h
@comment include/llvm/ADT/Triple.h.orig
include/llvm/ADT/UniqueVector.h
include/llvm/ADT/VectorExtras.h
include/llvm/ADT/ilist.h