debian5:/tmp/test# cat Makefile
test: test.o
gcc -o test.exe -g test.o
test.o: test.c
gcc -c -g -O3 -mabi=32 -march=loongson2f test.c
clean:
rm test.exe test.o
参考网址 :
另外,要点在于 准备 中间文件, test.o 上, 首先这里指定了 优化参数 O3, 指定了abi 是 o32( -mabi=32)
而 -march=loongson2f 则说明,编译架构为 loongson (实际上,龙芯2F已经可以兼容r4600处理器,所以也可以是 -march=r4600 )
使用 -march=loongson2f 前后的区别:
file test
test: ELF 32-bit LSB executable, MIPS, MIPS-I version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x1040000, not stripped
file test
test: ELF 32-bit LSB executable, MIPS, MIPS-III version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x1040000, not stripped
感谢:刘世伟 提供的帮助