llvmc issues on x86_32

According to the FAQ llvmc is considered experimental/unsupported. But
FWIW, here's an issue I found while trying to use it on 32 bit x86 systems.

tools/llvmc/plugins/Base/Base.td hardcodes the -relocation-model=pic
option into invocations of llc:

def llc : Tool<
[(in_language "llvm-bitcode"),
(out_language "assembler"),
(output_suffix "s"),
(cmd_line "llc -relocation-model=pic -f $INFILE -o $OUTFILE"),
(actions (case (switch_on "S"), (stop_compilation)))
]>;

This is nice on 64 bit systems, but generates slow code on 32 bit x86,
and even breaks on 32 bit Windows (using the mingw port); llc spits out
a failed assertion there if invoked with -relocation-model=pic.

I don't see an easy way to disable or override this option when invoking
llvmc on the command line.

My question is, are the llvmc maintainers aware of this, and is there a
workaround which does not require patching up Base.td? I couldn't find
anything in bugzilla.

TIA,
Albert

Hi,

According to the FAQ llvmc is considered experimental/unsupported. But
FWIW, here's an issue I found while trying to use it on 32 bit x86 systems.

I am the primary maintainer of llvmc. First of all, thanks for
your bug report.

tools/llvmc/plugins/Base/Base.td hardcodes the -relocation-model=pic
option into invocations of llc:

This part was copied verbatim from the previous incarnation of
llvmc and wasn't given much thought.

I don't see an easy way to disable or override this option when invoking
llvmc on the command line.

I removed the '-relocation-model' bit from the default invocation
string for llc. To pass arguments to llc, use the new "-Wllc"
option.

Mikhail Glushenkov wrote:

I removed the '-relocation-model' bit from the default invocation
string for llc. To pass arguments to llc, use the new "-Wllc"
option.

I'd say that this is the proper solution, even though it breaks backward
compatibility on x86_64. But given that llvmc is still considered
experimental, better do it now than later. :wink:

Thanks a lot for creating llvmc, it's very useful!

Albert Graef <Dr.Graef <at> t-online.de> writes:

I'd say that this is the proper solution, even though it breaks backward
compatibility on x86_64. But given that llvmc is still considered
experimental, better do it now than later.

A better solution probably would be to add
'-relocation-model=pic' only when we are on x86_64. There is no
easy way to access target information in plugins now, but I've
filed a bug on it:

http://llvm.org/bugs/show_bug.cgi?id=3920

Thanks a lot for creating llvmc, it's very useful!

I'm glad to hear that:)

Mikhail Glushenkov wrote:

A better solution probably would be to add
'-relocation-model=pic' only when we are on x86_64.

That still wouldn't work if you're cross-compiling to x86_32, since once
the option is hardcoded there's no way to remove it from the command
line. And it would be at odds with the rest of the LLVM toolchain which
is pretty agnostic about the particular system it runs on.