-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathToolChains.h
169 lines (133 loc) · 6.11 KB
/
ToolChains.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
//===--- ToolChains.h - Platform-specific ToolChain logic -------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_DRIVER_TOOLCHAINS_H
#define SWIFT_DRIVER_TOOLCHAINS_H
#include "swift/Basic/LLVM.h"
#include "swift/Driver/ToolChain.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Compiler.h"
namespace swift {
class DiagnosticEngine;
namespace driver {
namespace toolchains {
class LLVM_LIBRARY_VISIBILITY Darwin : public ToolChain {
protected:
void addLinkerInputArgs(InvocationInfo &II,
const JobContext &context) const;
void addArgsToLinkARCLite(llvm::opt::ArgStringList &Arguments,
const JobContext &context) const;
void addSanitizerArgs(llvm::opt::ArgStringList &Arguments,
const DynamicLinkJobAction &job,
const JobContext &context) const;
void addArgsToLinkStdlib(llvm::opt::ArgStringList &Arguments,
const DynamicLinkJobAction &job,
const JobContext &context) const;
void addProfileGenerationArgs(llvm::opt::ArgStringList &Arguments,
const JobContext &context) const;
void addDeploymentTargetArgs(llvm::opt::ArgStringList &Arguments,
const JobContext &context) const;
InvocationInfo constructInvocation(const InterpretJobAction &job,
const JobContext &context) const override;
InvocationInfo constructInvocation(const DynamicLinkJobAction &job,
const JobContext &context) const override;
InvocationInfo constructInvocation(const StaticLinkJobAction &job,
const JobContext &context) const override;
void validateArguments(DiagnosticEngine &diags,
const llvm::opt::ArgList &args,
StringRef defaultTarget) const override;
std::string findProgramRelativeToSwiftImpl(StringRef name) const override;
bool shouldStoreInvocationInDebugInfo() const override;
const Optional<llvm::Triple> TargetVariant;
public:
Darwin(const Driver &D, const llvm::Triple &Triple,
const Optional<llvm::Triple> &TargetVariant) :
ToolChain(D, Triple), TargetVariant(TargetVariant) {}
~Darwin() = default;
std::string sanitizerRuntimeLibName(StringRef Sanitizer,
bool shared = true) const override;
Optional<llvm::Triple> getTargetVariant() const {
return TargetVariant;
}
};
class LLVM_LIBRARY_VISIBILITY Windows : public ToolChain {
protected:
InvocationInfo constructInvocation(const DynamicLinkJobAction &job,
const JobContext &context) const override;
InvocationInfo constructInvocation(const StaticLinkJobAction &job,
const JobContext &context) const override;
public:
Windows(const Driver &D, const llvm::Triple &Triple) : ToolChain(D, Triple) {}
~Windows() = default;
std::string sanitizerRuntimeLibName(StringRef Sanitizer,
bool shared = true) const override;
};
class LLVM_LIBRARY_VISIBILITY GenericUnix : public ToolChain {
protected:
InvocationInfo constructInvocation(const InterpretJobAction &job,
const JobContext &context) const override;
InvocationInfo constructInvocation(const AutolinkExtractJobAction &job,
const JobContext &context) const override;
/// If provided, and if the user has not already explicitly specified a
/// linker to use via the "-fuse-ld=" option, this linker will be passed to
/// the compiler invocation via "-fuse-ld=". Return an empty string to not
/// specify any specific linker (the "-fuse-ld=" option will not be
/// specified).
///
/// The default behavior is to use the gold linker on ARM architectures,
/// and to not provide a specific linker otherwise.
virtual std::string getDefaultLinker() const;
/// The target to be passed to the compiler invocation. By default, this
/// is the target triple, but this may be overridden to accommodate some
/// platforms.
virtual std::string getTargetForLinker() const;
bool addRuntimeRPath(const llvm::Triple &T,
const llvm::opt::ArgList &Args) const;
InvocationInfo constructInvocation(const DynamicLinkJobAction &job,
const JobContext &context) const override;
InvocationInfo constructInvocation(const StaticLinkJobAction &job,
const JobContext &context) const override;
public:
GenericUnix(const Driver &D, const llvm::Triple &Triple)
: ToolChain(D, Triple) {}
~GenericUnix() = default;
std::string sanitizerRuntimeLibName(StringRef Sanitizer,
bool shared = true) const override;
};
class LLVM_LIBRARY_VISIBILITY Android : public GenericUnix {
protected:
std::string getTargetForLinker() const override;
public:
Android(const Driver &D, const llvm::Triple &Triple)
: GenericUnix(D, Triple) {}
~Android() = default;
};
class LLVM_LIBRARY_VISIBILITY Cygwin : public GenericUnix {
protected:
std::string getDefaultLinker() const override;
std::string getTargetForLinker() const override;
public:
Cygwin(const Driver &D, const llvm::Triple &Triple)
: GenericUnix(D, Triple) {}
~Cygwin() = default;
};
class LLVM_LIBRARY_VISIBILITY OpenBSD : public GenericUnix {
protected:
std::string getDefaultLinker() const override;
public:
OpenBSD(const Driver &D, const llvm::Triple &Triple)
: GenericUnix(D, Triple) {}
~OpenBSD() = default;
};
} // end namespace toolchains
} // end namespace driver
} // end namespace swift
#endif