[llvm] [MCJIT] Fix frem.ll test failure with LLVM_ENABLE_RPMALLOC on Windows (PR #200319)

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 10 22:07:33 PDT 2026


igorkudrin wrote:

> I want to avoid special casing this if we can.
> 
> I don't have a windows machine handy, but I assume that `printf` is exported from the main binary because it's linked from there, and that `fflush` is not?
> 
> What happens if you add something like this to `lli.cpp` instead?
> 
> ```c++
> /// Force C APIs that should be accessible to JIT'd code under lli
> /// to be linked into the main binary.
> static void __attribute__((used)) forceLinkLibCAPIs() {
>   (void)&fflush;
>   // Add future C API here.
> }
> ```

Unfortunately, it's not that simple. `llvm/utils/extract_symbols.py` scans LLVM libraries for symbols to export. When it finds a symbol that is _defined_ in exactly one place, it adds it to the list. `printf()` is defined as an inline function in `...\ucrt\stdio.h`, and as `llvm/lib/Demangle/MicrosoftDemangle.cpp` uses `std::printf()`, a COMDAT symbol `printf` is added to the object file. `LLVMDemangle.lib` is the only library that defines this symbol, so it is added to the export list. `exit` and `fflush` are referenced in many places, including `LLVMSupport.lib`, but are never defined, so they are not exported.

https://github.com/llvm/llvm-project/pull/200319


More information about the llvm-commits mailing list