unable to interface with target machine

Hi there.

Sorry in advance if this is a silly question.

I've got a test program in my v3c-storyboard project

that generates LLVM assembly for a hello world program.

If I try

   clang -o hello-world hello-world.ll

I get "error: unable to interface with target machine".

But if I

   llvm-as -o hello-world.bc hello-world.ll && "
   "llc -o hello-world.S hello-world.bc && "
   "gcc -o hello-world hello-world.S"

itworks.

What am I missing?

Regards,
Philip Ashmore

I tested it with llvm 3.2svn but I've got to change v3c-storyboard's configure
script to look for llvm-config-3.x instead of llvm-config for the llvm 3.1
Debian package.

It doesn't work with llvm 3.0.

Here's the generated file.

; ModuleID = 'my cool jit'

@0 = private unnamed_addr constant [14 x i8] c"Hello, world!\00"

declare i32 @puts(i8*)

define i32 @main(i32, [0 x i8*]) {
entry:
   %2 = call i32 @puts(i8* getelementptr inbounds ([14 x i8]* @0, i32 0, i32 0))
   ret i32 0
}

Hi Philip,

...

> I've got a test program in my v3c-storyboard project
> v3c-storyboard download | SourceForge.net
> that generates LLVM assembly for a hello world program.
>
> If I try
>
> clang -o hello-world hello-world.ll
>
> I get "error: unable to interface with target machine".

...

; ModuleID = 'my cool jit'

@0 = private unnamed_addr constant [14 x i8] c"Hello, world!\00"

declare i32 @puts(i8*)

define i32 @main(i32, [0 x i8*]) {
entry:
   %2 = call i32 @puts(i8* getelementptr inbounds ([14 x i8]* @0, i32 0, i32 0))
   ret i32 0
}

maybe try putting a target triple in the IR? Perhaps clang needs to know which
machine you want to target (while llc guesses).

Ciao, Duncan.

Hi Philip,

...

> I've got a test program in my v3c-storyboard project
> v3c-storyboard download | SourceForge.net
> that generates LLVM assembly for a hello world program.
>
> If I try
>
> clang -o hello-world hello-world.ll
>
> I get "error: unable to interface with target machine".

...

; ModuleID = 'my cool jit'

@0 = private unnamed_addr constant [14 x i8] c"Hello, world!\00"

declare i32 @puts(i8*)

define i32 @main(i32, [0 x i8*]) {
entry:
   %2 = call i32 @puts(i8* getelementptr inbounds ([14 x i8]* @0, i32 0, i32 0))
   ret i32 0
}

maybe try putting a target triple in the IR? Perhaps clang needs to know which
machine you want to target (while llc guesses).

Is there a way to get the target triple of the machine the code is running on, or barring that, the machine llvm was built on?

Ciao, Duncan.
_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Regards,
Philip

Is there a way to get the target triple of the machine the code is running on,
or barring that, the machine llvm was built on?

clang -v

Ciao, Duncan.

Sorry for not being specific enough - I meant in code.
I tried some clang functions to try to get the triplet using clang functions but it still caused the error.

Sorry but I can't remember which ones I tried - the compromise I ended up with can't be the best way.

Regards,
Philip

I suggest you take a look in include/llvm/Support/Host.h

Ciao, Duncan.

Is there a way to get the target triple of the machine the code is running on,
or barring that, the machine llvm was built on?

clang -v

Ciao, Duncan.
_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Sorry for not being specific enough - I meant in code.
I tried some clang functions to try to get the triplet using clang functions but
it still caused the error.

I suggest you take a look in include/llvm/Support/Host.h

I know about getDefaultTargetTriple().

What I don't know is how to get this information into the llvm::Module so that it gets output with an llvm::raw_os_ostream in a way that clang understands.

If I could use it with llvm-as without it having to make assumptions, to build shared libraries and programs, that would be great too.

Ciao, Duncan.

_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Regards,
Philip

Is there a way to get the target triple of the machine the code is running on,
or barring that, the machine llvm was built on?

clang -v

Ciao, Duncan.
_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Sorry for not being specific enough - I meant in code.
I tried some clang functions to try to get the triplet using clang functions but
it still caused the error.

I suggest you take a look in include/llvm/Support/Host.h

I know about getDefaultTargetTriple().

What I don't know is how to get this information into the llvm::Module so that it gets output with an llvm::raw_os_ostream in a way that clang understands.

If I could use it with llvm-as without it having to make assumptions, to build shared libraries and programs, that would be great too.

Maybe this is related to why llvm::InitializeNativeTarget() fails.
All of this is in my v3c-storyboard project, sb/tests/hello-world3-test.cpp.

I even tried outputting the target triple information myself to the header of the .ll file. No luck.