Comments (3)
I understand that the library allows for the generation of LLVM IR. How can one programmatically compile the IR to machine code?
Hi @kant777!
Happy to see playing around with LLVM IR.
As you mentioned, the llir/llvm
library only handles read/write/modify of LLVM IR. So to compile LLVM IR to machine code one would rely on external tools.
The official LLVM toolchain contains tools for both compilation of LLVM IR to machine code and linking of LLVM IR modules.
If you want to do this programmatically, the easiest way would be to simply use the os/exec
Go package and invoke the official LLVM toolchain tools to compile the LLVM IR to machine code.
Potentially using a temporary output file for the LLVM IR. If you decide to use a temporary LLVM IR output file, ensure that the permissions are set in such a way that other users cannot modify its content, as otherwise the LLVM IR code could be changed before compilation (race condition) to inject potentially malicious code.
Let me know how it works out.
Happy coding!
Cheers,
Robin
from llvm.
@mewmew Got it. Also Do you plan to support latest llvm versions since its been a while now? if not, it makes me think I should probably use https://github.com/twitchyliquid64/golang-asm although I loose all the optimizations that comes with the llvm compiler.
from llvm.
@mewmew Got it. Also Do you plan to support latest llvm versions since its been a while now? if not, it makes me think I should probably use https://github.com/twitchyliquid64/golang-asm although I loose all the optimizations that comes with the llvm compiler.
Hi @kant777!
While we'd love to support the latest LLVM version, as this is a hobby project driven by open source enthusiasts, there are no immediate plans for it as it requires a large amount of dedicated time.
From time to time, we feel the urge to work on the project, and then update to the latest LLVM versions (as we've done in the past).
So, I'd say, if you need anything specific from the newer versions of LLVM, then use the official tools and bindings to the C library of LLVM. Also, look into the tinygo library with bindings for LLVM, https://pkg.go.dev/tinygo.org/x/go-llvm. They should also include the ability to directly target machine code which would suit your needs quite well.
Wish you all the best and happy coding!
Cheerful summer wishes.
Robin
from llvm.
Related Issues (20)
- `SRet` struct location HOT 3
- How to use Function Pointers? HOT 3
- Wrong function pointer type HOT 1
- indirect br only takes constant addr HOT 1
- Returning void as a value HOT 3
- update llir/llvm to support 14.0 HOT 2
- update llir/llvm to support LLVM 15.0 HOT 7
- How to have two structs referencing eachother HOT 4
- How to convert to exe? HOT 3
- `module.NewTypeDef` has unexpected side effects HOT 17
- Provide working Hello, World example HOT 1
- support llvm 16.0.0 HOT 2
- incorrect cmpxchg signature HOT 4
- How to generate ir for embedded struct? HOT 6
- Convert to string HOT 1
- Hello 10 instead of Hello world. Passing a IntPtr to printf (go - LLIR/LLVM) HOT 3
- malloc and strcpy in LLVM HOT 1
- unable to generate LLVM: structure, external , noundef and ptr HOT 1
- No way to find underlying type of pointer or array HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from llvm.