[llvm-dev] ORC API C Standard/System Libraries

Lang Hames via llvm-dev llvm-dev at lists.llvm.org
Thu Nov 21 11:56:28 PST 2019


Hi Andrew,

1) I get multiple warnings for the system headers (e.g. stdlib) of the form:
> "warning: macro expansion producing 'defined' has undefined behavior"
> Is there a way to prevent these warnings? Preferably only for the system
> libraries.
> I tried -Wno-expansion-to-defined, -fms-extensions,
> -fms-compatibility-fms, -compatibility-version=14.16.27023. I also tried to
> reference the system library folder by -isystem, -internal-isystem and
> -c-isystem


I'm afraid I don't have any insight on this. If nobody chimes in on this
list it may be worth asking this on the clang-dev mailing list.

2) Disregarding the warnings, I also get the following error message:
> "JIT session error: Symbols not found: { malloc }"


How is your JIT set up? Are you using LLJIT, or a custom JIT class?

Either way, the key is to make sure that process symbols are added to a
JITDylib so that they can be found by JIT'd code. As an example, the code
to do this in LLVM's lli tool is:

J->getMainJITDylib().addGenerator(
      ExitOnErr(orc::DynamicLibrarySearchGenerator::GetForCurrentProcess(
          J->getDataLayout().getGlobalPrefix())));

Cheers,
Lang.


On Tue, Nov 12, 2019 at 12:48 PM Andrew Reece via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi all,
>
> First of all, I want to say that I really appreciate all the work that's
> gone into LLVM, clang and the ORC API. I would be very unlikely to be doing
> my current project if they weren't available.
>
> I'm using the ORC API to JIT some C code (soon to be C++) on Windows.
> (I was on LLVM 8.0.0 but it didn't handle the 'allocator' attribute so I
> upgraded to LLVM 9.0.0.)
>
> The JIT compiling works well for simple files, #included local files and
> object files.
> As soon as I start trying to use system libraries with functions, things
> start to fall down.
> I think this is largely just due to my ignorance of clang in general, but
> any guidance would be greatly appreciated.
>
>
> 1) I get multiple warnings for the system headers (e.g. stdlib) of the
> form:
> "warning: macro expansion producing 'defined' has undefined behavior"
>
> Is there a way to prevent these warnings? Preferably only for the system
> libraries.
> I tried -Wno-expansion-to-defined, -fms-extensions,
> -fms-compatibility-fms, -compatibility-version=14.16.27023. I also tried to
> reference the system library folder by -isystem, -internal-isystem and
> -c-isystem
>
>
> 2) Disregarding the warnings, I also get the following error message:
> "JIT session error: Symbols not found: { malloc }"
>
> I assumed this might be because I wasn't linking the standard library, so
> I tried appending "msvcrt.lib" and "-stdlib=msvcrt.lib" but to no avail.
> Can you use .lib files with clang on Windows?
>
> How do I make sure that the symbols defined in the standard libraries are
> available to my JIT?
>
>
> Thanks for any help you can give!
> All the best,
> Andrew
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191121/80d6f88c/attachment.html>


More information about the llvm-dev mailing list