[LLVMdev] LLVM Win32 Issue
Morten Ofstad
morten at hue.no
Mon Feb 25 02:37:45 PST 2008
Chuck Rose III wrote:
> Hola Aaron,
>
> Just having that code didn't work since the linker still stripped it
> out, so I have that function called from the code in the system that
> actually is being used by our app.
>
> Kinda grubby, but I include:
>
> #include "llvm/lib/Target/X86/X86TargetMachine.h"
>
> Which is in the LLVM lib, not the LLVM inc directory. This little
> maneuver made our Mac builds really unhappy, so we conditionally compile
> all this goo.
>
> I don't remember needing to do anything other than include the lib, the
> header above, and the bit of code I sent around.
>
> I'm sure there are better ways to do this and I'd love to hear about
> them if you discover something cool.
If you have a look in X86TargetMachine.cpp you should find the following (unless someone removed it, I put it there
around the time of LLVM 1.5):
/// X86TargetMachineModule - Note that this is used on hosts that cannot link
/// in a library unless there are references into the library. In particular,
/// it seems that it is not possible to get things to work on Win32 without
/// this. Though it is unused, do not remove it.
extern "C" int X86TargetMachineModule;
int X86TargetMachineModule = 0;
... combined with the Linker->Input->Force Symbol References field in the visual studio project property pages of your
project you will get the desired effect. Nnote that the symbol is named _X86TargetMachineModule when you look at it from
the outside, so you need to put this in the Force Symbol References.
m.
More information about the llvm-dev
mailing list