You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wink@ssi-primary:~/prgs/test$ spike pk hello
Hello World
But clang fails using the suggested command line from here:
wink@ssi-primary:~/prgs/test$ clang -target riscv -mriscv=RV64IAMFD -S hello.c -o hello.S
In file included from hello.c:1:
In file included from /usr/include/stdio.h:27:
In file included from /usr/include/features.h:341:
/usr/include/stdc-predef.h:30:10: fatal error: 'bits/predefs.h' file not found
include <bits/predefs.h>
^
1 error generated.
It seems the include paths aren't setup correctly, so I looked around and adding "-nostdinc -I/opt/riscv/riscv-elf/include -I/opt/riscv/lib/clang/3.3/include" worked, but I have a feeling there is a better and more correct way:
I built clang and the gcc tools on my Ubuntu 13-04 linux box with a fork riscv-tools from yesterday.
The gcc tools compile and spike runs hello.c:
wink@ssi-primary:~/prgs/test$ cat hello.c
include <stdio.h>
int main() {
printf("Hello World\n");
}
wink@ssi-primary:~/prgs/test$ riscv-gcc -o hello hello.c
wink@ssi-primary:~/prgs/test$ spike pk hello
Hello World
But clang fails using the suggested command line from here:
wink@ssi-primary:~/prgs/test$ clang -target riscv -mriscv=RV64IAMFD -S hello.c -o hello.S
In file included from hello.c:1:
In file included from /usr/include/stdio.h:27:
In file included from /usr/include/features.h:341:
/usr/include/stdc-predef.h:30:10: fatal error: 'bits/predefs.h' file not found
include <bits/predefs.h>
1 error generated.
It seems the include paths aren't setup correctly, so I looked around and adding "-nostdinc -I/opt/riscv/riscv-elf/include -I/opt/riscv/lib/clang/3.3/include" worked, but I have a feeling there is a better and more correct way:
wink@ssi-primary:~/prgs/test$ clang -target riscv -mriscv=RV64IAMFD -nostdinc -I/opt/riscv/riscv-elf/include -I/opt/riscv/lib/clang/3.3/include -S hello.c -o hello.S
wink@ssi-primary:~/prgs/test$ cat hello.S
.file "hello.c"
.text
.globl main
.align 4
.type main,@function
main:
addi x14, x14, -32
sd x1, 24(x14)
sd x31, 16(x14)
sd x2, 8(x14)
add x2, x0, x14
lui x16, %hi(.L.str)
addi x18, x16, %lo(.L.str)
jal printf
sw x16, 4(x2)
addiw x16, x0, 0
add x14, x0, x2
ld x2, 8(x14)
ld x31, 16(x14)
ld x1, 24(x14)
addi x14, x14, 32
ret
.Ltmp3:
.size main, .Ltmp3-main
.L.str:
.asciz "Hello World\n"
.size .L.str, 13
wink@ssi-primary:~/prgs/test$ riscv-gcc -o hello.riscv hello.S
wink@ssi-primary:~/prgs/test$ spike pk hello.riscv
Hello World
Let me know if there is more information is needed.
The text was updated successfully, but these errors were encountered: