cross compiling to sparc with llvm

Hi,

I’m trying to use llvm/clang to cross compile to sparcv9. The following works with a -march=sparc, but yields errors for sparcv9. Are there some other flags that need to be specified?

Thanks,
Tarun

clang -m64 -emit-llvm test.c -c -o test.bc
llc -march=sparcv9 test.bc -o hello.s
ExpandIntegerResult #0: 0x8a6c478: i64 = GlobalAddress<[4 x i8]* @.str> 0 [ORD=1] [ID=0]

Do not know how to expand the result of this operator!
UNREACHABLE executed at ~/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:947!
0 libLLVM-2.8svn.so 0xf6f82ef8
1 libLLVM-2.8svn.so 0xf6f82d90
2 0xf776c400 __kernel_sigreturn + 0
3 libc.so.6 0xf5a1cd52 abort + 386
4 libLLVM-2.8svn.so 0xf6f56ee9
5 libLLVM-2.8svn.so 0xf6e43cf2
6 libLLVM-2.8svn.so 0xf6e5206a
7 libLLVM-2.8svn.so 0xf6e5615a llvm::SelectionDAG::LegalizeTypes() + 68
8 libLLVM-2.8svn.so 0xf6ef3a58 llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 1022
9 libLLVM-2.8svn.so 0xf6ef312f llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::Instruction const>, llvm::ilist_iterator<llvm::Instruction const>, bool&) + 219
10 libLLVM-2.8svn.so 0xf6ef4f8a llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 1476
11 libLLVM-2.8svn.so 0xf6ef2874 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 600
12 libLLVM-2.8svn.so 0xf691cae1 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 87
13 libLLVM-2.8svn.so 0xf6af88b1 llvm::FPPassManager::runOnFunction(llvm::Function&) + 313
14 libLLVM-2.8svn.so 0xf6af8a6b llvm::FPPassManager::runOnModule(llvm::Module&) + 109
15 libLLVM-2.8svn.so 0xf6af8d56 llvm::MPPassManager::runOnModule(llvm::Module&) + 400
16 libLLVM-2.8svn.so 0xf6af920c llvm::PassManagerImpl::run(llvm::Module&) + 122
17 libLLVM-2.8svn.so 0xf6af96fd llvm::PassManager::run(llvm::Module&) + 39
18 llc 0x0805894a main + 2268
19 libc.so.6 0xf5a05bd6 __libc_start_main + 230
20 llc 0x08057761
Stack dump:
0. Program arguments: llc -march=sparcv9 test.bc -o hello.s

  1. Running pass ‘Function Pass Manager’ on module ‘test.bc’.
  2. Running pass ‘SPARC DAG->DAG Pattern Instruction Selection’ on function ‘@main
    Aborted

Hi Tarun,

I'm trying to use llvm/clang to cross compile to sparcv9. The following works
with a -march=sparc, but yields errors for sparcv9. Are there some other flags
that need to be specified?

Thanks,
Tarun

> clang -m64 -emit-llvm test.c -c -o test.bc

this is not the right way to cross-compile because all headers, macros etc will
be for your host machine (eg: endianness, size of integer types, inline asm and
so on) not for the target machine.

Ciao, Duncan.

PS: Hopefully a clanger will explain the right way to cross-compile.