hello, I am new for llvm and webassembly, but I tried this:
$crystal --version
Crystal 0.36.1 [c3a3c1823] (2021-02-02)
LLVM: 10.0.0
Default target: x86_64-unknown-linux-gnu
$../llvm/llvm-project/build/bin/llc --version
LLVM (http://llvm.org/):
LLVM version 13.0.0git
DEBUG build with assertions.
Default target: x86_64-unknown-linux-gnu
Host CPU: sandybridge
Registered Targets:
wasm32 - WebAssembly 32-bit
wasm64 - WebAssembly 64-bit
$cat hello.cr
puts "hello world"
$crystal build hello.cr --emit llvm-bc # output hello.bc
$crystal build hello.cr --emit llvm-ir # output hello.ll
$ crystal build hello.cr --emit asm # output hello.s
$ ../binaryen/bin/eosio-s2wasm hello.s -o hello.wast # eosio-s2wasm is from https://github.com/EOSIO/binaryen
[[function element:]]:
==========
.cfi_startproc
subq $184, %rsp
.cfi_def_cfa_offset 192
mo
==========
Aborted (core dumped)
$../llvm/llvm-project/build/bin/llc hello.ll -march=wasm32
<inline asm>:2:13: error: Unexpected token in operand: %
pushq %rdi // push 1st argument (because of initial resume)
^
<inline asm>:3:13: error: Unexpected token in operand: %
pushq %rbx // push callee-saved registers on the stack
^
<inline asm>:4:13: error: Unexpected token in operand: %
pushq %rbp
^
<inline asm>:5:13: error: Unexpected token in operand: %
pushq %r12
^
<inline asm>:6:13: error: Unexpected token in operand: %
pushq %r13
^
<inline asm>:7:13: error: Unexpected token in operand: %
pushq %r14
^
<inline asm>:8:13: error: Unexpected token in operand: %
pushq %r15
^
<inline asm>:9:12: error: Unexpected token in operand: %
movq %rsp, 0(%rdi) // current_context.stack_top = %rsp
^
<inline asm>:10:12: error: Unexpected token in operand: $
movl $1, 8(%rdi) // current_context.resumable = 1
^
<inline asm>:12:12: error: Unexpected token in operand: $
movl $0, 8(%rsi) // new_context.resumable = 0
^
<inline asm>:13:13: error: Expected ,, instead got: (
movq 0(%rsi), %rsp // %rsp = new_context.stack_top
^
<inline asm>:14:12: error: Unexpected token in operand: %
popq %r15 // pop callee-saved registers from the stack
^
<inline asm>:15:12: error: Unexpected token in operand: %
popq %r14
^
<inline asm>:16:12: error: Unexpected token in operand: %
popq %r13
^
<inline asm>:17:12: error: Unexpected token in operand: %
popq %r12
^
<inline asm>:18:12: error: Unexpected token in operand: %
popq %rbp
^
<inline asm>:19:12: error: Unexpected token in operand: %
popq %rbx
^
<inline asm>:20:12: error: Unexpected token in operand: %
popq %rdi // pop 1st argument (for initial resume)
^
LLVM ERROR: Cannot select: intrinsic %llvm.x86.sse2.pause
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: ./llc hello.ll -march=wasm32
1. Running pass 'Function Pass Manager' on module 'hello.ll'.
2. Running pass 'WebAssembly Instruction Selection' on function '@"*Intrinsics::pause:Nil"'
#0 0x000000000290da2b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./llc+0x290da2b)
#1 0x000000000290dae2 PrintStackTraceSignalHandler(void*) (./llc+0x290dae2)
#2 0x000000000290baa9 llvm::sys::RunSignalHandlers() (./llc+0x290baa9)
#3 0x000000000290d473 SignalHandler(int) (./llc+0x290d473)
#4 0x00007f36e3d6cb20 __restore_rt (/lib64/libpthread.so.0+0x12b20)
#5 0x00007f36e2c937ff raise (/lib64/libc.so.6+0x377ff)
#6 0x00007f36e2c7dc35 abort (/lib64/libc.so.6+0x21c35)
#7 0x000000000285d671 llvm::install_bad_alloc_error_handler(void (*)(void*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool), void*) (./llc+0x285d671)
#8 0x000000000285d4b5 llvm::report_fatal_error(llvm::StringRef, bool) (./llc+0x285d4b5)
#9 0x00000000026549f5 std::remove_reference<llvm::SelectionDAGISel::UpdateChains(llvm::SDNode*, llvm::SDValue, llvm::SmallVectorImpl<llvm::SDNode*>&, bool)::'lambda'(llvm::SDNode*, llvm::SDNode*)&>::type&& std::move<llvm::SelectionDAGISel::UpdateChains(llvm::SDNode*, llvm::SDValue, llvm::SmallVectorImpl<llvm::SDNode*>&, bool)::'lambda'(llvm::SDNode*, llvm::SDNode*)&>(llvm::SelectionDAGISel::UpdateChains(llvm::SDNode*, llvm::SDValue, llvm::SmallVectorImpl<llvm::SDNode*>&, bool)::'lambda'(llvm::SDNode*, llvm::SDNode*)&) (./llc+0x26549f5)
#10 0x00000000026541a1 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (./llc+0x26541a1)
#11 0x000000000137adca (anonymous namespace)::WebAssemblyDAGToDAGISel::SelectCode(llvm::SDNode*) (./llc+0x137adca)
#12 0x000000000137c6aa (anonymous namespace)::WebAssemblyDAGToDAGISel::Select(llvm::SDNode*) (./llc+0x137c6aa)
#13 0x0000000002646c81 llvm::SelectionDAGISel::DoInstructionSelection() (./llc+0x2646c81)
#14 0x000000000264606f llvm::SelectionDAGISel::CodeGenAndEmitDAG() (./llc+0x264606f)
#15 0x0000000002644756 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) (./llc+0x2644756)
#16 0x00000000026491c3 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (./llc+0x26491c3)
#17 0x00000000026433d9 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (./llc+0x26433d9)
#18 0x000000000137ad95 (anonymous namespace)::WebAssemblyDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) (./llc+0x137ad95)
#19 0x0000000001a2d892 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (./llc+0x1a2d892)
#20 0x0000000001fd1dbd llvm::FPPassManager::runOnFunction(llvm::Function&) (./llc+0x1fd1dbd)
#21 0x0000000001fd2012 llvm::FPPassManager::runOnModule(llvm::Module&) (./llc+0x1fd2012)
#22 0x0000000001fd23fa (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) (./llc+0x1fd23fa)
#23 0x0000000001fcdbd5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (./llc+0x1fcdbd5)
#24 0x0000000001fd2bd5 llvm::legacy::PassManager::run(llvm::Module&) (./llc+0x1fd2bd5)
#25 0x00000000012d346a compileModule(char**, llvm::LLVMContext&) (./llc+0x12d346a)
#26 0x00000000012d12a9 main (./llc+0x12d12a9)
#27 0x00007f36e2c7f7b3 __libc_start_main (/lib64/libc.so.6+0x237b3)
#28 0x00000000012d036e _start (./llc+0x12d036e)
Aborted (core dumped)
$cat /etc/os-release
NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"