Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Driver/ToolChains/Minix.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- Minix.cpp - Minix ToolChain Implementations ------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "Minix.h"
10
#include "CommonArgs.h"
11
#include "InputInfo.h"
12
#include "clang/Driver/Compilation.h"
13
#include "clang/Driver/Driver.h"
14
#include "clang/Driver/Options.h"
15
#include "llvm/Option/ArgList.h"
16
#include "llvm/Support/VirtualFileSystem.h"
17
18
using namespace clang::driver;
19
using namespace clang;
20
using namespace llvm::opt;
21
22
void tools::minix::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
23
                                           const InputInfo &Output,
24
                                           const InputInfoList &Inputs,
25
                                           const ArgList &Args,
26
0
                                           const char *LinkingOutput) const {
27
0
  claimNoWarnArgs(Args);
28
0
  ArgStringList CmdArgs;
29
0
30
0
  Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler);
31
0
32
0
  CmdArgs.push_back("-o");
33
0
  CmdArgs.push_back(Output.getFilename());
34
0
35
0
  for (const auto &II : Inputs)
36
0
    CmdArgs.push_back(II.getFilename());
37
0
38
0
  const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
39
0
  C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
40
0
}
41
42
void tools::minix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
43
                                 const InputInfo &Output,
44
                                 const InputInfoList &Inputs,
45
                                 const ArgList &Args,
46
0
                                 const char *LinkingOutput) const {
47
0
  const Driver &D = getToolChain().getDriver();
48
0
  ArgStringList CmdArgs;
49
0
50
0
  if (Output.isFilename()) {
51
0
    CmdArgs.push_back("-o");
52
0
    CmdArgs.push_back(Output.getFilename());
53
0
  } else {
54
0
    assert(Output.isNothing() && "Invalid output.");
55
0
  }
56
0
57
0
  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
58
0
    CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crt1.o")));
59
0
    CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crti.o")));
60
0
    CmdArgs.push_back(
61
0
        Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
62
0
    CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
63
0
  }
64
0
65
0
  Args.AddAllArgs(CmdArgs,
66
0
                  {options::OPT_L, options::OPT_T_Group, options::OPT_e});
67
0
68
0
  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
69
0
70
0
  getToolChain().addProfileRTLibs(Args, CmdArgs);
71
0
72
0
  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
73
0
    if (D.CCCIsCXX()) {
74
0
      if (getToolChain().ShouldLinkCXXStdlib(Args))
75
0
        getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
76
0
      CmdArgs.push_back("-lm");
77
0
    }
78
0
  }
79
0
80
0
  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
81
0
    if (Args.hasArg(options::OPT_pthread))
82
0
      CmdArgs.push_back("-lpthread");
83
0
    CmdArgs.push_back("-lc");
84
0
    CmdArgs.push_back("-lCompilerRT-Generic");
85
0
    CmdArgs.push_back("-L/usr/pkg/compiler-rt/lib");
86
0
    CmdArgs.push_back(
87
0
        Args.MakeArgString(getToolChain().GetFilePath("crtend.o")));
88
0
  }
89
0
90
0
  const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath());
91
0
  C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
92
0
}
93
94
/// Minix - Minix tool chain which can call as(1) and ld(1) directly.
95
96
toolchains::Minix::Minix(const Driver &D, const llvm::Triple &Triple,
97
                         const ArgList &Args)
98
0
    : Generic_ELF(D, Triple, Args) {
99
0
  getFilePaths().push_back(getDriver().Dir + "/../lib");
100
0
  getFilePaths().push_back("/usr/lib");
101
0
}
102
103
0
Tool *toolchains::Minix::buildAssembler() const {
104
0
  return new tools::minix::Assembler(*this);
105
0
}
106
107
0
Tool *toolchains::Minix::buildLinker() const {
108
0
  return new tools::minix::Linker(*this);
109
0
}