aboutsummaryrefslogtreecommitdiffhomepage
path: root/content/2022-06-18-libclang-c-to-llvm-ir
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2022-12-19 18:54:41 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2022-12-19 18:54:41 +0100
commit1c123a75e9b17858b783fbc6533417bdfa9794eb (patch)
tree72b0e3d48553b31b37cc2271de446f9ddfd915ef /content/2022-06-18-libclang-c-to-llvm-ir
parentdf9ac27b1048713207d2314407079586a080fc4f (diff)
downloadblog-1c123a75e9b17858b783fbc6533417bdfa9794eb.tar.gz
blog-1c123a75e9b17858b783fbc6533417bdfa9794eb.zip
Migrate pages with assets according to zola best practice
https://www.getzola.org/documentation/content/overview/#asset-colocation
Diffstat (limited to 'content/2022-06-18-libclang-c-to-llvm-ir')
-rw-r--r--content/2022-06-18-libclang-c-to-llvm-ir/index.md32
1 files changed, 32 insertions, 0 deletions
diff --git a/content/2022-06-18-libclang-c-to-llvm-ir/index.md b/content/2022-06-18-libclang-c-to-llvm-ir/index.md
new file mode 100644
index 0000000..7d3ee63
--- /dev/null
+++ b/content/2022-06-18-libclang-c-to-llvm-ir/index.md
@@ -0,0 +1,32 @@
++++
+title = "C to LLVM IR in memory using libclang"
+
+[taxonomies]
+tags = ["llvm", "clang", "c++"]
++++
+
+For some experiments with the LLVM just in time (JIT) APIs, I was looking for a
+way to compile in memory from `C -> LLVM IR` and without invoking Clang as a
+child process.
+
+I created a minimal example for my purpose based on the [Clang
+source][src-clang] code and the example given in the blog post [Compiling C++
+Code In Memory With Clang][blog-clang-in-memory].
+
+The code listing below shows the example with detailed comments inlined, hence
+I am not further describing any details here.
+
+> The example was build & tested with LLVM & Clang 13.
+
+```cpp
+{{ include(path="content/2022-06-18-libclang-c-to-llvm-ir/gen-ir.cc") }}
+```
+
+The following Makefile can be used to compile and run the example.
+
+```make
+{{ include(path="content/2022-06-18-libclang-c-to-llvm-ir/Makefile") }}
+```
+
+[src-clang]: https://github.com/llvm/llvm-project/tree/main/clang
+[blog-clang-in-memory]: https://blog.audio-tk.com/2018/09/18/compiling-c-code-in-memory-with-clang/