mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Close linker context.
This commit is contained in:
committed by
Christoffer Lerno
parent
d5b01d3a8f
commit
eddae3b7f7
@@ -7,20 +7,15 @@
|
|||||||
#include "llvm/Object/SymbolicFile.h"
|
#include "llvm/Object/SymbolicFile.h"
|
||||||
#include "llvm-c/TargetMachine.h"
|
#include "llvm-c/TargetMachine.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
|
#include "lld/Common/CommonLinkerContext.h"
|
||||||
|
|
||||||
#if LLVM_VERSION_MAJOR > 13
|
|
||||||
#define LINK_SIG \
|
#define LINK_SIG \
|
||||||
bool link(llvm::ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS, \
|
bool link(llvm::ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS, \
|
||||||
llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput);
|
llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput);
|
||||||
#define CALL_ARGS arg_vector, output, output_err, false, false
|
#define CALL_ARGS arg_vector, output, output_err, false, false
|
||||||
#else
|
|
||||||
#define LINK_SIG \
|
|
||||||
bool link(llvm::ArrayRef<const char *> args, bool canExitEarly, \
|
|
||||||
llvm::raw_ostream &stdoutOS, llvm::raw_ostream &stderrOS);
|
|
||||||
#define CALL_ARGS arg_vector, false, output, output_err
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace lld {
|
namespace lld {
|
||||||
|
|
||||||
namespace coff {
|
namespace coff {
|
||||||
LINK_SIG
|
LINK_SIG
|
||||||
}
|
}
|
||||||
@@ -96,29 +91,35 @@ static bool llvm_link(ObjFormat format, const char **args, int arg_count, const
|
|||||||
llvm::raw_string_ostream output_err { output_err_string };*/
|
llvm::raw_string_ostream output_err { output_err_string };*/
|
||||||
llvm::raw_ostream &output = llvm::outs();
|
llvm::raw_ostream &output = llvm::outs();
|
||||||
llvm::raw_ostream &output_err = llvm::errs();
|
llvm::raw_ostream &output_err = llvm::errs();
|
||||||
|
bool success;
|
||||||
switch (format)
|
switch (format)
|
||||||
{
|
{
|
||||||
case ELF:
|
case ELF:
|
||||||
if (lld::elf::link(CALL_ARGS)) return true;
|
success = lld::elf::link(CALL_ARGS);
|
||||||
break;
|
break;
|
||||||
case MACHO:
|
case MACHO:
|
||||||
if (lld::macho::link(CALL_ARGS)) return true;
|
success = lld::macho::link(CALL_ARGS);
|
||||||
break;
|
break;
|
||||||
case WASM:
|
case WASM:
|
||||||
if (lld::wasm::link(CALL_ARGS)) return true;
|
success = lld::wasm::link(CALL_ARGS);
|
||||||
break;
|
break;
|
||||||
case COFF:
|
case COFF:
|
||||||
if (lld::coff::link(CALL_ARGS)) return true;
|
success = lld::coff::link(CALL_ARGS);
|
||||||
break;
|
break;
|
||||||
case MINGW:
|
case MINGW:
|
||||||
exit(-1);
|
printf("Mingw not enabled");
|
||||||
if (lld::mingw::link(CALL_ARGS)) return true;
|
exit(1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
printf("Unsupported linker");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
lld::CommonLinkerContext::destroy();
|
||||||
|
}
|
||||||
//*error_string = strdup(output_err_string.c_str());
|
//*error_string = strdup(output_err_string.c_str());
|
||||||
return false;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user