Bug 132 - [Anolis OS 8 loongarch] clang编译.c文件时报错
Summary: [Anolis OS 8 loongarch] clang编译.c文件时报错
Status: VERIFIED FIXED
Alias: None
Product: Anolis OS 8
Classification: Anolis OS
Component: Images&Installations (show other bugs) Images&Installations
Version: 8.4
Hardware: loongarch Linux
: P1-Urgent S2-major
Target Milestone: rc2
Assignee: wenlong
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-17 15:54 UTC by latest
Modified: 2022-01-05 17:19 UTC (History)
3 users (show)

See Also:


Attachments
gcc rpm包 (49.76 MB, application/x-xz)
2021-12-21 15:28 UTC, wenlong
Details

Note You need to log in before you can comment on or make changes to this bug.
Description latest loongson_group 2021-12-17 15:54:12 UTC
【硬件配置】
1、整机 型号:3C5000L
2、处理器:loongson-3A5000L
3、内存信息:128G
12、显卡 型号:集显 
13、网卡 Intel Corporation 82599ES 10-Gigabit


【版本信息】
1、固件版本:
Vendor			: Loongson
Version			: Loongson-UDK2018-V1.4.2-8W
ROM Size		: 63 KB
Release Date		: 11/05/2021
Board Information
Manufacturer		: Loongson
Board Name		: Loongson-LS2C5LE
Family			: LOONGSON3

2.系统版本:anolis-8-loongarch64-dvd1-20211210.1.iso
3.内核版本 :Linux localhost.localdomain 4.19.190-3.an8.loongarch64 #1 SMP Tue Dec 7 17:19:44 UTC 2021 loongarch64 loongarch64 loongarch64 GNU/Linux


【重现概率】:
  必现100%
【测试步骤】
  1.  yum install clang llvm -y
  2. 生成test.c内容如下
     #include <stdio.h>
     int main(){
         printf("hello");
         return 0;
      }
  3.编译
clang test.c -o test



【预期结果】:
编译成功,生成test可执行文件

【实际结果】:
报错如下
/usr/bin/ld: 找不到 crtbegin.o: 没有那个文件或目录
/usr/bin/ld: 找不到 -lgcc
/usr/bin/ld: 找不到 -lgcc_s
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
Comment 1 wenlong loongson_group 2021-12-21 15:28:58 UTC
Created attachment 38 [details]
gcc rpm包
Comment 2 wenlong loongson_group 2021-12-21 15:30:55 UTC
用附件中gcc替换原有gcc,gcc llvm clang因为提供的是二进制,但是gcc构建系统与llvm和clang不一致,导致文件存在差异,更新后解决
Comment 3 geliwei-ali 2021-12-22 12:37:16 UTC
使用新的clang
<mock-chroot> sh-4.4# clang test.c -o test
'la464' is not a recognized processor for this target (ignoring processor)
'la464' is not a recognized processor for this target (ignoring processor)
'la464' is not a recognized processor for this target (ignoring processor)
'la464' is not a recognized processor for this target (ignoring processor)
'la464' is not a recognized processor for this target (ignoring processor)
'la464' is not a recognized processor for this target (ignoring processor)
'la464' is not a recognized processor for this target (ignoring processor)
'la464' is not a recognized processor for this target (ignoring processor)
'la464' is not a recognized processor for this target (ignoring processor)
'la464' is not a recognized processor for this target (ignoring processor)
'la464' is not a recognized processor for this target (ignoring processor)
'la464' is not a recognized processor for this target (ignoring processor)
Stack dump:
0.	Program arguments: /usr/bin/clang-8 -cc1 -triple loongarch64-loongson-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model pic -pic-level 1 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu la464 -target-feature +fp64 -target-abi lp64 -mfloat-abi hard -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib64/clang/8.0.1 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/8.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir / -ferror-limit 19 -fmessage-length 130 -fobjc-runtime=gcc -fdiagnostics-show-option -o /tmp/test-9a900f.o -x c test.c -faddrsig 
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'test.c'.
4.	Running pass 'LoongArch DAG->DAG Pattern Instruction Selection' on function '@main'
/lib64/libLLVM-8.so(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x24)[0xfff3b9f254]
clang-8: error: unable to execute command: Segmentation fault (core dumped)
clang-8: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 8.0.1 (Loognson 8.0.1-1.3.an8)
Target: loongarch64-loongson-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-8: note: diagnostic msg: PLEASE submit a bug report to  and include the crash backtrace, preprocessed source, and associated run script.
clang-8: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-8: note: diagnostic msg: /tmp/test-2f9d6e.c
clang-8: note: diagnostic msg: /tmp/test-2f9d6e.sh
clang-8: note: diagnostic msg: 

********************
<mock-chroot> sh-4.4# cat test.c 
#include <stdio.h>
int main(){
    printf("hello");
    return 0;
}
Comment 4 geliwei-ali 2021-12-22 12:38:32 UTC
(In reply to geliwei-ali from comment #3)
> 使用新的clang
> <mock-chroot> sh-4.4# clang test.c -o test
> 'la464' is not a recognized processor for this target (ignoring processor)
> 'la464' is not a recognized processor for this target (ignoring processor)
> 'la464' is not a recognized processor for this target (ignoring processor)
> 'la464' is not a recognized processor for this target (ignoring processor)
> 'la464' is not a recognized processor for this target (ignoring processor)
> 'la464' is not a recognized processor for this target (ignoring processor)
> 'la464' is not a recognized processor for this target (ignoring processor)
> 'la464' is not a recognized processor for this target (ignoring processor)
> 'la464' is not a recognized processor for this target (ignoring processor)
> 'la464' is not a recognized processor for this target (ignoring processor)
> 'la464' is not a recognized processor for this target (ignoring processor)
> 'la464' is not a recognized processor for this target (ignoring processor)
> Stack dump:
> 0.	Program arguments: /usr/bin/clang-8 -cc1 -triple
> loongarch64-loongson-linux-gnu -emit-obj -mrelax-all -disable-free
> -disable-llvm-verifier -discard-value-names -main-file-name test.c
> -mrelocation-model pic -pic-level 1 -mthread-model posix -mdisable-fp-elim
> -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array
> -target-cpu la464 -target-feature +fp64 -target-abi lp64 -mfloat-abi hard
> -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib64/clang/8.0.1
> -internal-isystem /usr/local/include -internal-isystem
> /usr/lib64/clang/8.0.1/include -internal-externc-isystem /include
> -internal-externc-isystem /usr/include -fdebug-compilation-dir /
> -ferror-limit 19 -fmessage-length 130 -fobjc-runtime=gcc
> -fdiagnostics-show-option -o /tmp/test-9a900f.o -x c test.c -faddrsig 
> 1.	<eof> parser at end of file
> 2.	Code generation
> 3.	Running pass 'Function Pass Manager' on module 'test.c'.
> 4.	Running pass 'LoongArch DAG->DAG Pattern Instruction Selection' on
> function '@main'
> /lib64/libLLVM-8.
> so(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x24)[0xfff3b9f254]
> clang-8: error: unable to execute command: Segmentation fault (core dumped)
> clang-8: error: clang frontend command failed due to signal (use -v to see
> invocation)
> clang version 8.0.1 (Loognson 8.0.1-1.3.an8)
> Target: loongarch64-loongson-linux-gnu
> Thread model: posix
> InstalledDir: /usr/bin
> clang-8: note: diagnostic msg: PLEASE submit a bug report to  and include
> the crash backtrace, preprocessed source, and associated run script.
> clang-8: note: diagnostic msg: 
> ********************
> 
> PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
> Preprocessed source(s) and associated run script(s) are located at:
> clang-8: note: diagnostic msg: /tmp/test-2f9d6e.c
> clang-8: note: diagnostic msg: /tmp/test-2f9d6e.sh
> clang-8: note: diagnostic msg: 
> 
> ********************
> <mock-chroot> sh-4.4# cat test.c 
> #include <stdio.h>
> int main(){
>     printf("hello");
>     return 0;
> }
需要同时升级llvm,问题解决
Comment 5 geliwei-ali 2021-12-23 16:18:36 UTC
已经导入rpm
Comment 6 latest loongson_group 2022-01-04 16:54:52 UTC
RC2版本
yum源compose源http://8.131.87.1/kojifiles/output/an-8-loongarch64-RC2/compose/

复测编译.c文件仍然报错,如下


[root@localhost clang+LLVM]# clang test.c -o test
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
Stack dump:
0.	Program arguments: /usr/bin/clang-8 -cc1 -triple loongarch64-redhat-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model pic -pic-level 1 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu gs464v -target-feature +fp64 -target-abi lp64 -mfloat-abi hard -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib64/clang/8.0.1 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/8.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/loongson/loongnix-testsuite/19-dev_language/clang+LLVM -ferror-limit 19 -fmessage-length 238 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/test-47abaa.o -x c test.c -faddrsig 
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'test.c'.
4.	Running pass 'LoongArch DAG->DAG Pattern Instruction Selection' on function '@main'
#0 0x000000fff45e5a84 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/lib64/libLLVM-8.so+0x985a84)
clang-8: error: unable to execute command: Segmentation fault (core dumped)
clang-8: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 8.0.1 (Loognson 8.0.1-1.1.lns8)
Target: loongarch64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-8: note: diagnostic msg: PLEASE submit a bug report to  and include the crash backtrace, preprocessed source, and associated run script.
clang-8: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-8: note: diagnostic msg: /tmp/test-e53a0b.c
clang-8: note: diagnostic msg: /tmp/test-e53a0b.sh
clang-8: note: diagnostic msg: 

********************
[root@localhost clang+LLVM]# clang -O3 -emit-llvm test.c -c -o test.bc
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
[root@localhost clang+LLVM]# clang -O3 -emit-llvm test.c -S -o test.ll
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)


报“段错误 (核心已转储)”
如下

[root@localhost clang+LLVM]# lli test.bc
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
Stack dump:
0.	Program arguments: lli test.bc 
1.	Running pass 'Function Pass Manager' on module 'test.bc'.
2.	Running pass 'LoongArch DAG->DAG Pattern Instruction Selection' on function '@main'
#0 0x000000fff4b75a84 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/lib64/libLLVM-8.so+0x985a84)
段错误 (核心已转储)


[root@localhost clang+LLVM]# llc test.bc -o test.s
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
'gs464v' is not a recognized processor for this target (ignoring processor)
Stack dump:
0.	Program arguments: llc test.bc -o test.s 
1.	Running pass 'Function Pass Manager' on module 'test.bc'.
2.	Running pass 'LoongArch DAG->DAG Pattern Instruction Selection' on function '@main'
#0 0x000000fff2ac1a84 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/lib64/libLLVM-8.so+0x985a84)
段错误 (核心已转储)
[root@localhost clang+LLVM]#
Comment 7 wenlong loongson_group 2022-01-04 18:20:20 UTC
这个用的是最新提供的gcc,llvm,clang吗
Comment 8 wenlong loongson_group 2022-01-05 17:16:57 UTC
替换最新的gcc、llvm、clang,然后更新repo源之后即可解决
Comment 9 latest loongson_group 2022-01-05 17:19:04 UTC
更新源后复测通过