Skip to content

Commit 1db7dc4

Browse files
committed
Fix use of funified-lto and save-temps flags together
> clang -flto -funified-lto -save-temps test.c Fails with the following error message: ```bash module flag identifiers must be unique (or of 'require' type) !"UnifiedLTO" fatal error: error in backend: Broken module found, compilation aborted! clang: error: clang frontend command failed with exit code 70 (use -v to see invocation) ``` Here is what the driver does when `-save-temps` flag is set: > clang -flto -funified-lto -save-temps test.c -ccc-print-phases > +- 0: input, "test.c", c > +- 1: preprocessor, {0}, cpp-output > +- 2: compiler, {1}, ir > +- 3: backend, {2}, lto-bc > 4: linker, {3}, image The IR output of "compiler" step has "UnifiedLTO" module flag. "backend" step adds another module flag with "UnifiedLTO" identifier, which invalidates the LLVM IR module.
1 parent 4df4b36 commit 1db7dc4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
11991199
}
12001200
}
12011201

1202-
if (shouldEmitUnifiedLTOModueFlag())
1202+
if (shouldEmitUnifiedLTOModueFlag() &&
1203+
!TheModule->getModuleFlag("UnifiedLTO"))
12031204
TheModule->addModuleFlag(llvm::Module::Error, "UnifiedLTO", uint32_t(1));
12041205
}
12051206

0 commit comments

Comments
 (0)