Allow output of only bc, ll, or s by making -of set the output type depending

on the extension.
This commit is contained in:
Christian Kamm
2008-10-13 10:58:00 +02:00
parent 6c19259c68
commit bc39d73425
3 changed files with 69 additions and 25 deletions

View File

@@ -211,25 +211,31 @@ void Module::genobjfile(int multiobj, char** envp)
}
// write native assembly
LLPath spath = LLPath(objfile->name->toChars());
spath.eraseSuffix();
spath.appendSuffix(std::string(global.s_ext));
if (!global.params.output_s) {
spath.createTemporaryFileOnDisk();
}
Logger::println("Writing native asm to: %s\n", spath.c_str());
std::string err;
{
llvm::raw_fd_ostream out(spath.c_str(), err);
write_asm_to_file(*ir.module, out);
}
if (global.params.output_s || global.params.output_o) {
LLPath spath = LLPath(objfile->name->toChars());
spath.eraseSuffix();
spath.appendSuffix(std::string(global.s_ext));
if (!global.params.output_s) {
spath.createTemporaryFileOnDisk();
}
Logger::println("Writing native asm to: %s\n", spath.c_str());
std::string err;
{
llvm::raw_fd_ostream out(spath.c_str(), err);
write_asm_to_file(*ir.module, out);
}
// call gcc to convert assembly to object file
LLPath objpath = LLPath(objfile->name->toChars());
assemble(spath, objpath, envp);
// call gcc to convert assembly to object file
if (global.params.output_o) {
LLPath objpath = LLPath(objfile->name->toChars());
objpath.eraseSuffix();
objpath.appendSuffix(std::string(global.obj_ext));
assemble(spath, objpath, envp);
}
if (!global.params.output_s) {
spath.eraseFromDisk();
if (!global.params.output_s) {
spath.eraseFromDisk();
}
}
delete ir.module;