Skip to content

Commit

Permalink
Constrain -Clto and -Cembed-bitcode flag inheritance to be `clang…
Browse files Browse the repository at this point in the history
…`-only (#1379)
  • Loading branch information
jieyouxu authored Jan 31, 2025
1 parent 8533e8c commit 65b4d9a
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,6 @@ impl<'this> RustcCodegenFlags<'this> {
push_if_supported(format!("-mguard={cc_val}").into());
}
}
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-flto
if let Some(value) = self.lto {
let cc_val = match value {
"y" | "yes" | "on" | "true" | "fat" => Some("full"),
"thin" => Some("thin"),
_ => None,
};
if let Some(cc_val) = cc_val {
push_if_supported(format!("-flto={cc_val}").into());
}
}
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fPIC
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fPIE
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mdynamic-no-pic
Expand All @@ -234,11 +223,6 @@ impl<'this> RustcCodegenFlags<'this> {
push_if_supported(cc_flag.into());
}
}
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fembed-bitcode
if let Some(value) = self.embed_bitcode {
let cc_val = if value { "all" } else { "off" };
push_if_supported(format!("-fembed-bitcode={cc_val}").into());
}
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fno-omit-frame-pointer
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer
if let Some(value) = self.force_frame_pointers {
Expand Down Expand Up @@ -285,6 +269,24 @@ impl<'this> RustcCodegenFlags<'this> {
if let Some(value) = self.profile_use {
push_if_supported(format!("-fprofile-use={value}").into());
}

// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fembed-bitcode
if let Some(value) = self.embed_bitcode {
let cc_val = if value { "all" } else { "off" };
push_if_supported(format!("-fembed-bitcode={cc_val}").into());
}

// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-flto
if let Some(value) = self.lto {
let cc_val = match value {
"y" | "yes" | "on" | "true" | "fat" => Some("full"),
"thin" => Some("thin"),
_ => None,
};
if let Some(cc_val) = cc_val {
push_if_supported(format!("-flto={cc_val}").into());
}
}
}
ToolFamily::Gnu { .. } => {}
ToolFamily::Msvc { .. } => {
Expand Down

0 comments on commit 65b4d9a

Please sign in to comment.