-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "Linker.h" | ||
|
||
#include <nanobind/nanobind.h> | ||
#include <llvm-c/Linker.h> | ||
#include "types_priv.h" | ||
|
||
namespace nb = nanobind; | ||
using namespace nb::literals; | ||
|
||
void populateLinker(nanobind::module_ &m) { | ||
nb::enum_<LLVMLinkerMode>(m, "LinkerMode" "LinkerMode") | ||
// LLVMLinkerPreserveSource_Removed is deprecated | ||
.value("DestroySource", LLVMLinkerMode::LLVMLinkerDestroySource, | ||
"This is the default behavior."); | ||
|
||
// TODO customize (if error, throw an runtime error containing the reason. Just | ||
// like what llvmlite does) | ||
m.def("link_module", | ||
[](PymModule dest, PymModule src) { | ||
return LLVMLinkModules2(dest.get(), src.get()) != 0; | ||
}, | ||
"dest"_a, "src"_a, | ||
"Links the source module into the destination module. The source module is" | ||
"destroyed.\n" | ||
"The return value is true if an error occurred, false otherwise.\n" | ||
"Use the diagnostic handler to get any diagnostic message."); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef LINKER_H | ||
#define LINKER_H | ||
|
||
#include <nanobind/nanobind.h> | ||
|
||
void populateLinker(nanobind::module_ &m); | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .llvmpym_ext.linker import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters