Hello,
The attached patch adds initial support to clang for FreeBSD on ARM.
I've tested this on FreeBSD's integrated clang 3.1 and forward ported
the changes to clang's trunk.
Andrew (please CC me, I'm not on the list)
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp (revision 168536)
+++ lib/Basic/Targets.cpp (working copy)
@@ -3092,7 +3092,10 @@
// name.
if (Name == "apcs-gnu") {
DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 32;
- SizeType = UnsignedLong;
+ // size_t is unsigned int on FreeBSD.
+ if (getTriple().getOS() != llvm::Triple::FreeBSD) {
+ SizeType = UnsignedLong;
+ }
// Revert to using SignedInt on apcs-gnu to comply with existing behaviour.
WCharType = SignedInt;
@@ -3299,6 +3302,12 @@
// when Neon instructions are actually available.
if ((FPU & NeonFPU) && !SoftFloat && IsARMv7)
Builder.defineMacro("__ARM_NEON__");
+
+ // This is set when we are building for FreeBSD for ARMv6+.
+ // The maximum value may change with new versions of the Architecture
+ if (getTriple().getOS() == llvm::Triple::FreeBSD && CPUArch[0] >= '6' &&
+ CPUArch[0] <= '7')
+ Builder.defineMacro("__FreeBSD_ARCH_armv6__");
}
virtual void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const {
Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp (revision 168536)
+++ lib/Driver/ToolChains.cpp (working copy)
@@ -1684,6 +1684,19 @@
return *T;
}
+bool FreeBSD::UseSjLjExceptions() const {
+ // FreeBSD uses SjLj exceptions on ARM oabi.
+ switch (getTriple().getEnvironment()) {
+ case llvm::Triple::GNUEABI:
+ case llvm::Triple::EABI:
+ return false;
+
+ default:
+ return (getTriple().getArch() == llvm::Triple::arm ||
+ getTriple().getArch() == llvm::Triple::thumb);
+ }
+}
+
/// NetBSD - NetBSD tool chain which can call as(1) and ld(1) directly.
NetBSD::NetBSD(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
Index: lib/Driver/ToolChains.h
===================================================================
--- lib/Driver/ToolChains.h (revision 168536)
+++ lib/Driver/ToolChains.h (working copy)
@@ -469,6 +469,7 @@
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
const ActionList &Inputs) const;
+ virtual bool UseSjLjExceptions() const;
};
class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp (revision 168536)
+++ lib/Driver/Tools.cpp (working copy)
@@ -665,6 +665,11 @@
break;
}
+ case llvm::Triple::FreeBSD:
+ // FreeBSD currently only supports soft float
+ FloatABI = "soft";
+ break;
+
default:
switch(Triple.getEnvironment()) {
case llvm::Triple::GNUEABIHF:
@@ -4815,6 +4820,17 @@
LastPICArg->getOption().matches(options::OPT_fpie))) {
CmdArgs.push_back("-KPIC");
}
+ } else if (getToolChain().getArch() == llvm::Triple::arm ||
+ getToolChain().getArch() == llvm::Triple::thumb) {
+ CmdArgs.push_back("-mfpu=softvfp");
+ switch(getToolChain().getTriple().getEnvironment()) {
+ case llvm::Triple::GNUEABI:
+ case llvm::Triple::EABI:
+ break;
+
+ default:
+ CmdArgs.push_back("-matpcs");
+ }
}
Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits