Skip to content

Commit 65b4d9a

Browse files
authored
Constrain -Clto and -Cembed-bitcode flag inheritance to be clang-only (#1379)
1 parent 8533e8c commit 65b4d9a

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/flags.rs

+18-16
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,6 @@ impl<'this> RustcCodegenFlags<'this> {
209209
push_if_supported(format!("-mguard={cc_val}").into());
210210
}
211211
}
212-
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-flto
213-
if let Some(value) = self.lto {
214-
let cc_val = match value {
215-
"y" | "yes" | "on" | "true" | "fat" => Some("full"),
216-
"thin" => Some("thin"),
217-
_ => None,
218-
};
219-
if let Some(cc_val) = cc_val {
220-
push_if_supported(format!("-flto={cc_val}").into());
221-
}
222-
}
223212
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fPIC
224213
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fPIE
225214
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mdynamic-no-pic
@@ -234,11 +223,6 @@ impl<'this> RustcCodegenFlags<'this> {
234223
push_if_supported(cc_flag.into());
235224
}
236225
}
237-
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fembed-bitcode
238-
if let Some(value) = self.embed_bitcode {
239-
let cc_val = if value { "all" } else { "off" };
240-
push_if_supported(format!("-fembed-bitcode={cc_val}").into());
241-
}
242226
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fno-omit-frame-pointer
243227
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer
244228
if let Some(value) = self.force_frame_pointers {
@@ -285,6 +269,24 @@ impl<'this> RustcCodegenFlags<'this> {
285269
if let Some(value) = self.profile_use {
286270
push_if_supported(format!("-fprofile-use={value}").into());
287271
}
272+
273+
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fembed-bitcode
274+
if let Some(value) = self.embed_bitcode {
275+
let cc_val = if value { "all" } else { "off" };
276+
push_if_supported(format!("-fembed-bitcode={cc_val}").into());
277+
}
278+
279+
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-flto
280+
if let Some(value) = self.lto {
281+
let cc_val = match value {
282+
"y" | "yes" | "on" | "true" | "fat" => Some("full"),
283+
"thin" => Some("thin"),
284+
_ => None,
285+
};
286+
if let Some(cc_val) = cc_val {
287+
push_if_supported(format!("-flto={cc_val}").into());
288+
}
289+
}
288290
}
289291
ToolFamily::Gnu { .. } => {}
290292
ToolFamily::Msvc { .. } => {

0 commit comments

Comments
 (0)