Don't pass LLVM pass & its args during linking (#1274)

This commit is contained in:
Dongjia "toka" Zhang 2023-05-17 14:32:56 +02:00 committed by GitHub
parent b7c1591b00
commit efc5756e3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -326,34 +326,38 @@ impl CompilerWrapper for ClangWrapper {
args.push("-flegacy-pass-manager".into()); args.push("-flegacy-pass-manager".into());
} }
} }
for pass in &self.passes {
use_pass = true; if !self.linking {
if self.use_new_pm { for pass in &self.passes {
// https://github.com/llvm/llvm-project/issues/56137 use_pass = true;
// Need this -Xclang -load -Xclang -<pass>.so thing even with the new PM if self.use_new_pm {
// to pass the arguments to LLVM Passes // https://github.com/llvm/llvm-project/issues/56137
args.push("-Xclang".into()); // Need this -Xclang -load -Xclang -<pass>.so thing even with the new PM
args.push("-load".into()); // to pass the arguments to LLVM Passes
args.push("-Xclang".into()); args.push("-Xclang".into());
args.push(pass.path().into_os_string().into_string().unwrap()); args.push("-load".into());
args.push("-Xclang".into()); args.push("-Xclang".into());
args.push(format!( args.push(pass.path().into_os_string().into_string().unwrap());
"-fpass-plugin={}", args.push("-Xclang".into());
pass.path().into_os_string().into_string().unwrap() args.push(format!(
)); "-fpass-plugin={}",
} else { pass.path().into_os_string().into_string().unwrap()
args.push("-Xclang".into()); ));
args.push("-load".into()); } else {
args.push("-Xclang".into()); args.push("-Xclang".into());
args.push(pass.path().into_os_string().into_string().unwrap()); args.push("-load".into());
} args.push("-Xclang".into());
} args.push(pass.path().into_os_string().into_string().unwrap());
if !self.is_asm && !self.passes.is_empty() { }
for passes_arg in &self.passes_args { }
args.push("-mllvm".into()); if !self.is_asm && !self.passes.is_empty() {
args.push(passes_arg.into()); for passes_arg in &self.passes_args {
args.push("-mllvm".into());
args.push(passes_arg.into());
}
} }
} }
if self.linking { if self.linking {
if self.x_set { if self.x_set {
args.push("-x".into()); args.push("-x".into());