@@ -89,13 +89,14 @@ struct DriverArgs {
89
89
std::string ISysroot;
90
90
std::string Target;
91
91
std::string Stdlib;
92
+ llvm::SmallVector<std::string> Specs;
92
93
93
94
bool operator ==(const DriverArgs &RHS) const {
94
95
return std::tie (Driver, StandardIncludes, StandardCXXIncludes, Lang,
95
- Sysroot, ISysroot, Target, Stdlib) ==
96
+ Sysroot, ISysroot, Target, Stdlib, Specs ) ==
96
97
std::tie (RHS.Driver , RHS.StandardIncludes , RHS.StandardCXXIncludes ,
97
- RHS.Lang , RHS.Sysroot , RHS.ISysroot , RHS.Target ,
98
- RHS.Stdlib );
98
+ RHS.Lang , RHS.Sysroot , RHS.ISysroot , RHS.Target , RHS. Stdlib ,
99
+ RHS.Specs );
99
100
}
100
101
101
102
DriverArgs (const tooling::CompileCommand &Cmd, llvm::StringRef File) {
@@ -145,6 +146,17 @@ struct DriverArgs {
145
146
Stdlib = Cmd.CommandLine [I + 1 ];
146
147
} else if (Arg.consume_front (" -stdlib=" )) {
147
148
Stdlib = Arg.str ();
149
+ } else if (Arg.startswith (" -specs=" )) {
150
+ // clang requires a single token like `-specs=file` or `--specs=file`,
151
+ // but gcc will accept two tokens like `--specs file`. Since the
152
+ // compilation database is presumably correct, we just forward the flags
153
+ // as-is.
154
+ Specs.push_back (Arg.str ());
155
+ } else if (Arg.startswith (" --specs=" )) {
156
+ Specs.push_back (Arg.str ());
157
+ } else if (Arg == " --specs" && I + 1 < E) {
158
+ Specs.push_back (Arg.str ());
159
+ Specs.push_back (Cmd.CommandLine [I + 1 ]);
148
160
}
149
161
}
150
162
@@ -186,6 +198,11 @@ struct DriverArgs {
186
198
Args.append ({" -target" , Target});
187
199
if (!Stdlib.empty ())
188
200
Args.append ({" --stdlib" , Stdlib});
201
+
202
+ for (llvm::StringRef Spec : Specs) {
203
+ Args.push_back (Spec);
204
+ }
205
+
189
206
return Args;
190
207
}
191
208
@@ -210,7 +227,7 @@ template <> struct DenseMapInfo<DriverArgs> {
210
227
return Driver;
211
228
}
212
229
static unsigned getHashValue (const DriverArgs &Val) {
213
- return llvm::hash_value (std::tuple{
230
+ unsigned FixedFieldsHash = llvm::hash_value (std::tuple{
214
231
Val.Driver ,
215
232
Val.StandardIncludes ,
216
233
Val.StandardCXXIncludes ,
@@ -220,6 +237,11 @@ template <> struct DenseMapInfo<DriverArgs> {
220
237
Val.Target ,
221
238
Val.Stdlib ,
222
239
});
240
+
241
+ unsigned SpecsHash =
242
+ llvm::hash_combine_range (Val.Specs .begin (), Val.Specs .end ());
243
+
244
+ return llvm::hash_combine (FixedFieldsHash, SpecsHash);
223
245
}
224
246
static bool isEqual (const DriverArgs &LHS, const DriverArgs &RHS) {
225
247
return LHS == RHS;
0 commit comments