A similar function already exists in Rust as LLVMRustThinLTOBufferCreate. I needed it in the C API for my own project so I wrote this patch to add it.
I tried using the new pass manager, but somehow that didn't work: no module summary was created.
This didn't work:
std::string Data; raw_string_ostream OS(Data); ModulePassManager MPM; ModuleAnalysisManager MAM; MPM.addPass(ThinLTOBitcodeWriterPass(OS, nullptr)); MPM.run(*unwrap(M), MAM); return wrap(MemoryBuffer::getMemBufferCopy(OS.str()).release());
clang-format: please reformat the code