Windows 컴파일 7-64 비트 플랫폼에서 최신 GCC for RISCV에서 기본 컴파일을 수행하는 데 어려움이 있습니다. & RISCV 용 링크.GCC 7.1.1 RISCV 컴파일 (링크) 오류, 호환되지 않음 ABI
도구가 설치 : 7.1.1-2-20170912-2255이 https://github.com/gnu-mcu-eclipse/riscv-none-gcc/releases/
플랫폼에서받은 : 윈도우 7, 64 비트, 아니 Cygwin에서
프로그램 :
#include <stdint.h>
int32_t iBlahblah;
int main (void)
{
while(1)
iBlahblah++;
return 0;
}
명령 행 :
"c:\Program Files\GNU MCU Eclipse\RISC-V Embedded GCC\7.1.1-2-20170912-2255\bin\riscv64-unknown-elf-gcc.exe" -c hello.c -o hello -march=rv32imac -mabi=ilp32 -Os
"c:\Program Files\GNU MCU Eclipse\RISC-V Embedded GCC\7.1.1-2-20170912-2255\bin\riscv64-unknown-elf-gcc.exe" -o hello.elf -march=rv32imac -mabi=ilp32 -Os -Wl,-Map=hello.lst hello.o
출력 :
c:/program files/gnu mcu eclipse/risc-v embedded gcc/7.1.1-2-20170912-2255/bin/../lib/gcc/riscv64-unknown-elf/7.1.1/../../../../riscv64-unknown-elf/bin/ld.exe: hello.o: ABI is incompatible with that of the selected emulation: target emulation `elf64-littleriscv' does not match `elf32-littleriscv'
c:/program files/gnu mcu eclipse/risc-v embedded gcc/7.1.1-2-20170912-2255/bin/../lib/gcc/riscv64-unknown-elf/7.1.1/../../../../riscv64-unknown-elf/bin/ld.exe: failed to merge target specific data of file hello.o
c:/program files/gnu mcu eclipse/risc-v embedded gcc/7.1.1-2-20170912-2255/bin/../lib/gcc/riscv64-unknown-elf/7.1.1/../../../../riscv64-unknown-elf/lib/rv32imac/ilp32\libg.a(lib_a-exit.o): In function `.L0 ': exit.c:(.text.exit+0x1e): undefined reference to `_exit'
c:/program files/gnu mcu eclipse/risc-v embedded gcc/7.1.1-2-20170912-2255/bin/../lib/gcc/riscv64-unknown-elf/7.1.1/../../../../riscv64-unknown-elf/bin/ld.exe: hello.elf(.text): relocation "iBlahblah+0x0 (type R_RISCV_HI20)" goes out of range
c:/program files/gnu mcu eclipse/risc-v embedded gcc/7.1.1-2-20170912-2255/bin/../lib/gcc/riscv64-unknown-elf/7.1.1/../../../../riscv64-unknown-elf/bin/ld.exe: hello.o: file class ELFCLASS64 incompatible with ELFCLASS32
c:/program files/gnu mcu eclipse/risc-v embedded gcc/7.1.1-2-20170912-2255/bin/../lib/gcc/riscv64-unknown-elf/7.1.1/../../../../riscv64-unknown-elf/bin/ld.exe: final link failed: File in wrong format
collect2.exe: error: ld returned 1 exit status
큰 문제는 "ABI가 선택한 에뮬레이션과 호환되지 않습니다"라는 문제를 해결하는 방법입니다. 재배포, 퇴장 등에 관한 다른 문제는 무시해도됩니다. 왜냐하면 제 대형 환경이이를 처리하기 때문입니다 (현재 RISCV가 아닌 많은 플랫폼을 위해 구축 됨).
riscv64에 gcc를 사용하고 32 비트 모드로 컴파일하려고합니다. 하지만이 gcc는 64 비트 모드 용 c 런타임 라이브러리를 링크 단계에 추가합니다 (gcc에 -v 옵션을 추가하여 gcc에서 추가 된 crt 파일을 볼 수 있음). 이것은 잘못되었습니다 (32 비트 엘프 및 64 비트 엘프 객체는 링크 할 수 없습니다. 함께).64 비트 모드의 64 비트 대상에는 gcc를 사용해야합니다. 32 비트 모드의 32 비트 대상 용 gcc (실제로 32 비트 crt가 필요하지만 gcc에 포함될 수 있지만 잘못된 버전 사용) – osgx
@osgx https : // gnu-mcu-eclipse의 설명서 .github.io/toolchain/riscv/install/riscv64-unknown-elf-gcc.exe는 32 비트와 64 비트를 모두 타겟팅 할 수 있습니다. 32 비트 라이브러리는 어떻게해야할까요? –
32 비트 CRT에 대한 올바른 경로를 사용하는 riscv32-unknown-elf-gcc.exe를 사용하십시오. 'riscv64-unknown-elf-gcc.exe -v ...'vs'riscv32-unknown-elf-gcc.exe -v ...'의 출력을 비교하여 CRT가있는 정확한 디렉토리를 찾으십시오. – osgx