mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
Fix using -plugin-opt=apiflie when also using -plugin-opt=emit-llvm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215378 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7c0fa0cfab
commit
b2d2f28351
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
|
; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
|
||||||
; RUN: --plugin-opt=emit-llvm \
|
; RUN: --plugin-opt=emit-llvm \
|
||||||
|
; RUN: --plugin-opt=generate-api-file \
|
||||||
; RUN: -shared %t.o -o %t2.o
|
; RUN: -shared %t.o -o %t2.o
|
||||||
; RUN: llvm-dis %t2.o -o - | FileCheck %s
|
; RUN: llvm-dis %t2.o -o - | FileCheck %s
|
||||||
|
; RUN: FileCheck --check-prefix=API %s < %T/../apifile.txt
|
||||||
|
|
||||||
; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
|
; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
|
||||||
; RUN: -m elf_x86_64 --plugin-opt=also-emit-llvm \
|
; RUN: -m elf_x86_64 --plugin-opt=also-emit-llvm \
|
||||||
@ -51,3 +53,9 @@ define linkonce_odr void @f6() unnamed_addr {
|
|||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
@g6 = global void()* @f6
|
@g6 = global void()* @f6
|
||||||
|
|
||||||
|
|
||||||
|
; API: f3
|
||||||
|
; API: f5
|
||||||
|
; API: g5
|
||||||
|
; API: g6
|
||||||
|
@ -390,20 +390,9 @@ static bool mustPreserve(ld_plugin_symbol &Sym) {
|
|||||||
/// gold informs us that all symbols have been read. At this point, we use
|
/// gold informs us that all symbols have been read. At this point, we use
|
||||||
/// get_symbols to see if any of our definitions have been overridden by a
|
/// get_symbols to see if any of our definitions have been overridden by a
|
||||||
/// native object file. Then, perform optimization and codegen.
|
/// native object file. Then, perform optimization and codegen.
|
||||||
static ld_plugin_status all_symbols_read_hook(void) {
|
static ld_plugin_status allSymbolsReadHook(raw_fd_ostream *apiFile) {
|
||||||
// FIXME: raw_fd_ostream should be able to represent an unopened file.
|
|
||||||
std::unique_ptr<raw_fd_ostream> api_file;
|
|
||||||
|
|
||||||
assert(CodeGen);
|
assert(CodeGen);
|
||||||
|
|
||||||
if (options::generate_api_file) {
|
|
||||||
std::string Error;
|
|
||||||
api_file.reset(new raw_fd_ostream("apifile.txt", Error, sys::fs::F_None));
|
|
||||||
if (!Error.empty())
|
|
||||||
message(LDPL_FATAL, "Unable to open apifile.txt for writing: %s",
|
|
||||||
Error.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (claimed_file &F : Modules) {
|
for (claimed_file &F : Modules) {
|
||||||
if (F.syms.empty())
|
if (F.syms.empty())
|
||||||
continue;
|
continue;
|
||||||
@ -413,7 +402,7 @@ static ld_plugin_status all_symbols_read_hook(void) {
|
|||||||
CodeGen->addMustPreserveSymbol(Sym.name);
|
CodeGen->addMustPreserveSymbol(Sym.name);
|
||||||
|
|
||||||
if (options::generate_api_file)
|
if (options::generate_api_file)
|
||||||
(*api_file) << Sym.name << "\n";
|
(*apiFile) << Sym.name << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -434,10 +423,8 @@ static ld_plugin_status all_symbols_read_hook(void) {
|
|||||||
std::string Error;
|
std::string Error;
|
||||||
if (!CodeGen->writeMergedModules(path.c_str(), Error))
|
if (!CodeGen->writeMergedModules(path.c_str(), Error))
|
||||||
message(LDPL_FATAL, "Failed to write the output file.");
|
message(LDPL_FATAL, "Failed to write the output file.");
|
||||||
if (options::generate_bc_file == options::BC_ONLY) {
|
if (options::generate_bc_file == options::BC_ONLY)
|
||||||
delete CodeGen;
|
return LDPS_OK;
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ObjPath;
|
std::string ObjPath;
|
||||||
@ -450,7 +437,6 @@ static ld_plugin_status all_symbols_read_hook(void) {
|
|||||||
ObjPath = Temp;
|
ObjPath = Temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete CodeGen;
|
|
||||||
for (claimed_file &F : Modules) {
|
for (claimed_file &F : Modules) {
|
||||||
for (ld_plugin_symbol &Sym : F.syms)
|
for (ld_plugin_symbol &Sym : F.syms)
|
||||||
free(Sym.name);
|
free(Sym.name);
|
||||||
@ -474,6 +460,27 @@ static ld_plugin_status all_symbols_read_hook(void) {
|
|||||||
return LDPS_OK;
|
return LDPS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ld_plugin_status all_symbols_read_hook(void) {
|
||||||
|
ld_plugin_status Ret;
|
||||||
|
if (!options::generate_api_file) {
|
||||||
|
Ret = allSymbolsReadHook(nullptr);
|
||||||
|
} else {
|
||||||
|
std::string Error;
|
||||||
|
raw_fd_ostream apiFile("apifile.txt", Error, sys::fs::F_None);
|
||||||
|
if (!Error.empty())
|
||||||
|
message(LDPL_FATAL, "Unable to open apifile.txt for writing: %s",
|
||||||
|
Error.c_str());
|
||||||
|
Ret = allSymbolsReadHook(&apiFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete CodeGen;
|
||||||
|
|
||||||
|
if (options::generate_bc_file == options::BC_ONLY)
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
return Ret;
|
||||||
|
}
|
||||||
|
|
||||||
static ld_plugin_status cleanup_hook(void) {
|
static ld_plugin_status cleanup_hook(void) {
|
||||||
for (std::string &Name : Cleanup) {
|
for (std::string &Name : Cleanup) {
|
||||||
std::error_code EC = sys::fs::remove(Name);
|
std::error_code EC = sys::fs::remove(Name);
|
||||||
|
Loading…
Reference in New Issue
Block a user