본문 바로가기

운영_설치/리눅스_유닉스

risc-v 용 gnu toolchain 빌드

우분투 20.04의 risc-v 용 toolchain을 사용하니 stdint.h 를 찾지 못하는 에러가 발생했다.

 

 

 

riscv64-unknown-elf-gcc -std=c99 -c -Wall -g -march=rv32imac -mabi=ilp32 -mcmodel=medlow -Iinclude main.c -o main.o
In file included from main.c:1:
/usr/lib/gcc/riscv64-unknown-elf/9.3.0/include/stdint.h:9:16: fatal error: stdint.h: No such file or directory
    9 | # include_next <stdint.h>
      |                ^~~~~~~~~~
compilation terminated.
make: *** [Makefile:75: main.o] Error 1

 

 

패키지명은 gcc-ricsv64-unknown-elf 이고 gcc 버전은 9.3.0 이다.

방법을 찾다 귀찮아서 빌드해서 쓰기로 결정함

 

빌드 방법은 생각보다 간단하다.

 

 

$ git clone https://github.com/riscv/riscv-gnu-toolchain

 

 

 

$ mkdir -p riscv-gnu-toolchain/build

$ cd riscv-gnu-toolchain/build

 

$ ../configure --with-arch=rv32imac --with-abi=ilp32 --prefix=/usr/riscv-gcc

$ make 

 

 

 

 

$ make linux 라고 하면 linux 크로스 컴파일러를 빌드하고 

그냥 $ make 만 하면 newlib 크로스 컴파일러를 빌드 한다고 한다.

 

newlib는 임베디드 시스템에서 사용하기 위한 c 라이브러리라고 하는데 뭐가 빌드에는 뭐가 어떻게 차이나는 건지 모르겠다.

 

 

빌드가 끝나면 prefix로 지정한 디렉토리에 설치되며

gcc(c,as,c++), binutils, gdb, glibc, newlib 이 모두 들어있다.

 

 

 

https://github.com/riscv/riscv-gnu-toolchain

 

 

 

 

bare-metal / newlib / linux mode 구분을 써 놓았는데..

 

https://www.lowrisc.org/docs/riscv_compile/

 

더 헷갈림 



Calendar
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Visits
Today
Yesterday