回复:[Zephyr-devel] How to compile riscv64 program with 0.10.3 sdk "riscv64-zephyr-elf-gcc" toolchain?


"曹子龙
 

Thank you!

if so,it seems riscv32 toolchain also can take this flag and generate the 64 bit program.

riscv32-zephyr-elf-gcc -march=rv64i -mabi=lp64 -c  main.c -o main

caozilong@Exdroid94:~/WorkSpace/riscvilp32$ file main
main: ELF 64-bit LSB  relocatable, version 1 (SYSV), not stripped

so, it seems still no difference of two sets of toolchain,

曹子龙

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技2路9号

TEL:13824125580

Email:caozilong@...

网址: http://www.allwinnertech.com

 


------------------------------------------------------------------
发件人:Stephanos Ioannidis <root@...>
发送时间:2020年5月11日(星期一) 09:50
收件人:曹子龙 <caozilong@...>; devel <devel@...>
主 题:RE: [Zephyr-devel] How to compile riscv64 program with 0.10.3 sdk "riscv64-zephyr-elf-gcc" toolchain?

Hi,

 

You need to specify the correct ABI type through `-mabi` alongside the `-march` flag.

 

Try `-march=rv64i -mabi=lp64` for instance.

 

Regards,

 

Stephanos

 

From: devel@... <devel@...> On Behalf Of "??? via lists.zephyrproject.org
Sent: Sunday, May 10, 2020 9:28 PM
To: devel <devel@...>
Subject: [Zephyr-devel] How to compile riscv64 program with 0.10.3 sdk "riscv64-zephyr-elf-gcc" toolchain?

 

I try to compile program with "zephyr-sdk-0.10.3/riscv64-zephyr-elf/bin/riscv64-zephyr-elf-gcc " to compile my program,

 

but it seems the result still be 32 bit program:

a.out: ELF 32-bit LSB executable, UCB RISC-V, version 1 (SYSV), statically linked, with debug_info, not stripped

 

and i event try to compile with rv64 flag -march=rv64i

./riscv64-zephyr-elf-gcc -g main.c  -march=rv64i

cc1: error: ABI requires -march=rv32

 it seems still dont work 

 

at the beginning i guess it mybe use a ilp32 abi based on rv64 toolchan, so i try a program like that:

 20 unsigned long long foolbar2(unsigned long long a, unsigned long long b)

 21 {

 22         return a + b;

 23 }

whch unsigned long should be compile to "ld" and "sd" pare means ilp32 abi on RV64ISA ARCH.

but

  95 {          

  96    10194:       fe010113                addi    sp,sp,-32

  97    10198:       00812e23                sw      s0,28(sp)

  98    1019c:       02010413                addi    s0,sp,32

  99    101a0:       fea42423                sw      a0,-24(s0)

 100    101a4:       feb42623                sw      a1,-20(s0)

 101    101a8:       fec42023                sw      a2,-32(s0)

 102    101ac:       fed42223                sw      a3,-28(s0)

 103         return a + b;

 104    101b0:       fe842783                lw      a5,-24(s0)

 105    101b4:       fec42803                lw      a6,-20(s0)

 106    101b8:       fe042583                lw      a1,-32(s0)

 107    101bc:       fe442603                lw      a2,-28(s0)

 108    101c0:       00b786b3                add     a3,a5,a1

 

it purely total no!!!

 

so why? now that an rv32-zephyr-elf-gcc exist, if the iscv64-zephyr-elf-gcc  cat compile the 64 bit program, why it here ? 

 

曹子

珠海全志科技股份有限公司      BU1-PSW

地址:广东省珠海市高新区唐家湾镇科技29

TEL13824125580

Emailcaozilong@...

网址: http://www.allwinnertech.com

 

 


Join devel@lists.zephyrproject.org to automatically receive all group messages.