|
@@ -1099,6 +1099,11 @@ void Clang::AddX86TargetArgs(const ArgList &Args,
|
|
|
CPUName = "x86-64";
|
|
|
else if (getToolChain().getArch() == llvm::Triple::x86)
|
|
|
CPUName = "i486";
|
|
|
+ } else if (getToolChain().getOS().startswith("bitrig")) {
|
|
|
+ if (getToolChain().getArch() == llvm::Triple::x86_64)
|
|
|
+ CPUName = "x86-64";
|
|
|
+ else if (getToolChain().getArch() == llvm::Triple::x86)
|
|
|
+ CPUName = "i686";
|
|
|
} else if (getToolChain().getOS().startswith("freebsd")) {
|
|
|
if (getToolChain().getArch() == llvm::Triple::x86_64)
|
|
|
CPUName = "x86-64";
|
|
@@ -4958,6 +4963,138 @@ void openbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
|
|
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
|
|
|
}
|
|
|
|
|
|
+void bitrig::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
|
|
|
+ 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");
|
|
|
+ CmdArgs.push_back(Output.getFilename());
|
|
|
+
|
|
|
+ for (InputInfoList::const_iterator
|
|
|
+ it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) {
|
|
|
+ const InputInfo &II = *it;
|
|
|
+ CmdArgs.push_back(II.getFilename());
|
|
|
+ }
|
|
|
+
|
|
|
+ const char *Exec =
|
|
|
+ Args.MakeArgString(getToolChain().GetProgramPath("as"));
|
|
|
+ C.addCommand(new Command(JA, *this, Exec, CmdArgs));
|
|
|
+}
|
|
|
+
|
|
|
+void bitrig::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
|
|
+ const InputInfo &Output,
|
|
|
+ const InputInfoList &Inputs,
|
|
|
+ const ArgList &Args,
|
|
|
+ const char *LinkingOutput) const {
|
|
|
+ const Driver &D = getToolChain().getDriver();
|
|
|
+ ArgStringList CmdArgs;
|
|
|
+
|
|
|
+ if ((!Args.hasArg(options::OPT_nostdlib)) &&
|
|
|
+ (!Args.hasArg(options::OPT_shared))) {
|
|
|
+ CmdArgs.push_back("-e");
|
|
|
+ CmdArgs.push_back("__start");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Args.hasArg(options::OPT_static)) {
|
|
|
+ CmdArgs.push_back("-Bstatic");
|
|
|
+ } else {
|
|
|
+ if (Args.hasArg(options::OPT_rdynamic))
|
|
|
+ CmdArgs.push_back("-export-dynamic");
|
|
|
+ CmdArgs.push_back("--eh-frame-hdr");
|
|
|
+ CmdArgs.push_back("-Bdynamic");
|
|
|
+ if (Args.hasArg(options::OPT_shared)) {
|
|
|
+ CmdArgs.push_back("-shared");
|
|
|
+ } else {
|
|
|
+ CmdArgs.push_back("-dynamic-linker");
|
|
|
+ CmdArgs.push_back("/usr/libexec/ld.so");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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)) {
|
|
|
+ if (Args.hasArg(options::OPT_pg))
|
|
|
+ CmdArgs.push_back(Args.MakeArgString(
|
|
|
+ getToolChain().GetFilePath("gcrt0.o")));
|
|
|
+ else
|
|
|
+ CmdArgs.push_back(Args.MakeArgString(
|
|
|
+ getToolChain().GetFilePath("crt0.o")));
|
|
|
+ CmdArgs.push_back(Args.MakeArgString(
|
|
|
+ getToolChain().GetFilePath("crtbegin.o")));
|
|
|
+ } else {
|
|
|
+ CmdArgs.push_back(Args.MakeArgString(
|
|
|
+ getToolChain().GetFilePath("crtbeginS.o")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Args.AddAllArgs(CmdArgs, options::OPT_L);
|
|
|
+ Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
|
|
|
+ Args.AddAllArgs(CmdArgs, options::OPT_e);
|
|
|
+
|
|
|
+ AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
|
|
|
+
|
|
|
+ if (!Args.hasArg(options::OPT_nostdlib) &&
|
|
|
+ !Args.hasArg(options::OPT_nodefaultlibs)) {
|
|
|
+ if (D.CCCIsCXX) {
|
|
|
+ getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
|
|
|
+ if (Args.hasArg(options::OPT_pg))
|
|
|
+ CmdArgs.push_back("-lm_p");
|
|
|
+ else
|
|
|
+ CmdArgs.push_back("-lm");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Args.hasArg(options::OPT_pthread))
|
|
|
+ CmdArgs.push_back("-lpthread");
|
|
|
+ if (!Args.hasArg(options::OPT_shared)) {
|
|
|
+ if (Args.hasArg(options::OPT_pg))
|
|
|
+ CmdArgs.push_back("-lc_p");
|
|
|
+ else
|
|
|
+ CmdArgs.push_back("-lc");
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string myarch = "-lclang_rt.";
|
|
|
+ const llvm::Triple &T = getToolChain().getTriple();
|
|
|
+ llvm::Triple::ArchType Arch = T.getArch();
|
|
|
+ switch (Arch) {
|
|
|
+ case llvm::Triple::arm:
|
|
|
+ myarch += ("arm");
|
|
|
+ break;
|
|
|
+ case llvm::Triple::x86:
|
|
|
+ myarch += ("i386");
|
|
|
+ break;
|
|
|
+ case llvm::Triple::x86_64:
|
|
|
+ myarch += ("amd64");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ assert(0 && "Unsupported architecture");
|
|
|
+ }
|
|
|
+ CmdArgs.push_back(Args.MakeArgString(myarch));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Args.hasArg(options::OPT_nostdlib) &&
|
|
|
+ !Args.hasArg(options::OPT_nostartfiles)) {
|
|
|
+ if (!Args.hasArg(options::OPT_shared))
|
|
|
+ CmdArgs.push_back(Args.MakeArgString(
|
|
|
+ getToolChain().GetFilePath("crtend.o")));
|
|
|
+ else
|
|
|
+ CmdArgs.push_back(Args.MakeArgString(
|
|
|
+ getToolChain().GetFilePath("crtendS.o")));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
|
|
|
const InputInfo &Output,
|
|
|
const InputInfoList &Inputs,
|