首页 > 其他分享 >N1064编译链编译

N1064编译链编译

时间:2024-08-19 18:48:32浏览次数:13  
标签:.. -- N1064 编译 disable build linux aarch64

环境ubuntu20.04

Arm官网有源码和编译链。但是没有编译手册。
从安装版本中拿到10.3-2021.07-x86_64-aarch64-none-linux-gnu-manifest.txt
根据里面的记录,去进行配置和编译。
官网下载: https://developer.arm.com/downloads/-/gnu-a

下载文件,存放到download中
$cd toolchain_build;
$mkdir build output src
解压文件
$cd download/
$for f in *.tar*; do tar -xf $f -C ../src; done
$cd ../
这里export TARGET PROJECT SYSROOT
$export TARGET=aarch64-none-linux-gnu
$export PROJECT=$PWD
$export SYSROOT=$PROJECT/output/$TARGET/libc
做准备工作,编译安装gmp mpc mpfr isl 到build/host-libs目录
$chmod u+x build_prerequisites.sh; ./build_prerequisites.sh


$cd build/; mkdir build-binutils build_gcc1 build_gcc2 build_gcc3 build_gcc4 build_glibc
编译binutils
$cd build-binutils
$../../src/binutils/configure --enable-64-bit-bfd   --enable-targets=arm-none-eabi,aarch64_be-none-linux-gnu,aarch64_be-none-elf,aarch64-none-linux-gnu,aarch64-none-linux-gnu_ilp32,aarch64-none-elf --target=aarch64-none-linux-gnu --with-bugurl="https://bugs.linaro.org/" --enable-gold --enable-initfini-array --enable-plugins --disable-doc --disable-gdb --disable-gdbtk --disable-nls --disable-tui --disable-werror --without-gdb --without-python --without-x --prefix=$PROJECT/output  --with-build-sysroot=$SYSROOT --with-sysroot=/aarch64-none-linux-gnu/libc --with-pkgversion='GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)'
$make -j8; make install  
编译gcc1
$cd ../build_gcc1
$../../src/gcc/configure --target=aarch64-none-linux-gnu --prefix=$PROJECT/output --with-sysroot=/aarch64-none-linux-gnu/libc --with-build-sysroot=$SYSROOT --without-headers --with-newlib --with-bugurl="https://bugs.linaro.org/" --without-cloog --without-isl --disable-shared --disable-threads --disable-libatomic --disable-libsanitizer --disable-libssp --disable-libgomp --disable-libmudflap --disable-libquadmath --enable-checking=yes -disable-libstdcxx --disable-libvtv --enable-languages=c,c++ --with-gmp=$PROJECT/build/host-libs/  --with-mpfr=$PROJECT/build/host-libs/ --with-mpc=$PROJECT/build/host-libs/ --enable-fix-cortex-a53-843419 --with-pkgversion='GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)'
$make -j8; make install  

1.gcc1主要生成aarch64-none-linux-gnu-gcc供后续使用。所以下一步需要export PATH。
2.在官方文档上没有-disable-libstdcxx --disable-libvtv和c++,是因为glibc编译时出错
build_glibc/support/links-dso-program.o: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
经查links-dso-program.cc,是用g++编译成links-dso-program.o,而我们此时--enable-languages=c还没有编译出g++, 所以此处冒险在gcc1中把c++给添加上来。

此时在环境变量中添加上刚刚编译出来的aarch64-none-linux-gnu-gcc的路径,后面的编译中会使用到
$export PATH=$PATH:$PROJECT/output/bin

解压linux,并安装,后续编译会使用
$cd ../../src/linux-4.20.13
$make ARCH=arm64 headers_check
$make ARCH=arm64 headers_install INSTALL_HDR_PATH=$PROJECT/output/aarch64-none-linux-gnu/libc/usr/
第一次glibc编译,为gcc2的编译提供一些头文件和库文件
$cd ../../build/build_glibc/
$../../src/glibc_v2.33/configure --enable-shared --with-tls --disable-profile --disable-omitfp --disable-bounded --disable-sanity-checks --prefix=$SYSROOT/usr  --with-headers=$SYSROOT/usr/include --includedir=$SYSROOT/usr/include --with-pkgversion='GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)' --build=x86_64-unknown-linux-gnu --host=aarch64-none-linux-gnu --disable-werror --enable-obsolete-rpc --disable-profile --without-gd --without-cvs --without-selinux
$make install-bootstrap-headers=yes install-headers
$make -j8 csu/subdir_lib;
$install csu/crt1.o csu/crti.o csu/crtn.o $PROJECT/output/$TARGET/lib
$$TARGET-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $PROJECT/output/$TARGET/lib/libc.so
$touch $SYSROOT/usr/include/gnu/stubs.h

报错:
check_fds.c: Assembler messages:
check_fds.c:81: Error: no such instruction: 'brk '
make[2]: *** [../o-iterator.mk:9: /home/test/toolchain_build/build/build_glibc/csu/check_fds.o] Error 1
make[2]: *** Waiting for unfinished jobs....
../sysdeps/unix/sysv/linux/aarch64/__read_tp.S: Assembler messages:
../sysdeps/unix/sysv/linux/aarch64/__read_tp.S:22: Error: no such instruction: 'hint 34'
../sysdeps/unix/sysv/linux/aarch64/__read_tp.S:23: Error: no such instruction: 'mrs x0,tpidr_el0'
../sysdeps/aarch64/nptl/tls.h:95:21: error: ‘__builtin_thread_pointer’ is not supported on this target
95 | ((struct pthread *)__builtin_thread_pointer () - 1)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../csu/libc-start.c:322:30: note: in expansion of macro ‘THREAD_SELF’
322 | struct pthread *self = THREAD_SELF;

解决:在linux安装时执行make ARCH=arm64 headers_check

第二次gcc编译,gcc2
$cd ../build_gcc2
$../../src/gcc/configure --target=aarch64-none-linux-gnu --prefix=$PROJECT/output --with-sysroot=/aarch64-none-linux-gnu/libc --with-build-sysroot=$SYSROOT --with-bugurl="https://bugs.linaro.org/" --enable-shared --disable-libatomic --without-cloog --without-isl --disable-libssp --disable-libgomp --disable-libmudflap --disable-libquadmath --enable-checking=yes --enable-languages=c --with-gmp=$PROJECT/build/host-libs/ --with-mpfr=$PROJECT/build/host-libs/  --with-mpc=$PROJECT/build/host-libs/ --enable-fix-cortex-a53-843419 --with-pkgversion='GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)'
make -j8
make install

注意:必须先执行glibc1并成功,否则会有如下这些错误:
aarch64-none-linux-gnu/libc/usr/include/features.h:497:10: fatal error: gnu/stubs.h: No such file or directory
: cannot find crti.o: No such file or directory
/home/test/toolchain_build/output/aarch64-none-linux-gnu/bin/ld: cannot find -lc
make[2]: *** [Makefile:994: libgcc_s.so] Error 1
make[2]: Leaving directory '/home/test/toolchain_build/build/build_gcc2/aarch64-none-linux-gnu/libgcc'
make[1]: *** [Makefile:11990: all-target-libgcc] Error 2
make[1]: Leaving directory '/home/test/toolchain_build/build/build_gcc2'

第二次glibc的编译,glibc2
$cd ../build_glibc
$make clean
$make -j8; make install
第三次gcc的编译,gcc3
$cd ../build_gcc3
$../../src/gcc/configure --target=aarch64-none-linux-gnu --prefix=$PROJECT/output --with-sysroot=/aarch64-none-linux-gnu/libc --with-build-sysroot=$SYSROOT --with-bugurl="https://bugs.linaro.org/" --enable-gnu-indirect-function --enable-shared --disable-libssp --disable-libmudflap --enable-checking=release --enable-languages=c,c++,fortran --with-gmp=$PROJECT/build/host-libs/ --with-mpfr=$PROJECT/build/host-libs/  --with-mpc=$PROJECT/build/host-libs/  --with-isl=$PROJECT/build/host-libs/ --enable-fix-cortex-a53-843419 --with-pkgversion='GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)'
$cp $SYSROOT/usr/lib/* $PROJECT/output/$TARGET/lib/
$make -j8; make install

报错:cc1: error: no include path in which to search for stdc-predef.h
The directory that should contain system headers does not exist:
解决:这个时候不要怀疑别的,先检查报错的这个路径。
报错:C compiler cannot create executables.
查找对应的config.log。发现如下打印
/../sysdeps/aarch64/start.S:83: undefined reference to '__libc_csu_init', 这个是glibc编出来的库,但是现在找不到。
解决:找不到库,但是实际上已经编译出来了,我们做一下拷贝
cp $SYSROOT/usr/lib* $SYSROOT/../lib/

第四次gcc的编译,gcc4
$cd ../build_gcc4
$../../src/gcc/configure --target=aarch64-none-linux-gnu --prefix=$PROJECT/output  --with-sysroot=$SYSROOT --with-bugurl="https://bugs.linaro.org/" --enable-shared --disable-libssp --disable-libmudflap --enable-checking=yes --enable-languages=c,c++,fortran --with-gmp=$PROJECT/build/host-libs/ --with-mpfr=$PROJECT/build/host-libs/ --with-mpc=$PROJECT/build/host-libs/ --with-isl=$PROJECT/build/host-libs/ --enable-fix-cortex-a53-843419 --with-pkgversion='GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)'
$make -j8; make install
参考文档:

https://docs.slackware.com/howtos:hardware:arm:gcc-10.x_aarch64_cross-compiler
https://jasonblog.github.io/note/raspberry_pi/how_to_build_a_gcc_cross-compiler.html
https://blog.csdn.net/birencs/article/details/124615193
https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/
https://github.com/apritzel/cross/blob/master/README.md
https://github.com/novelinux/compiler-gcc/blob/master/MakeCrossGcc.md
https://www.cnblogs.com/summitzhou/p/12503647.html

标签:..,--,N1064,编译,disable,build,linux,aarch64
From: https://www.cnblogs.com/wangguangyu12217/p/18367897

相关文章

  • ubuntu(linux): 编译安装使用python3.12.5
    一,python官网:https://www.python.org/下载页面:https://www.python.org/downloads/source/如图:二,安装1,下载:wget从命令行下载:liuhongdi@lhdpc:/usr/local/source/python$wgethttps://www.python.org/ftp/python/3.12.5/Python-3.12.5.tgz2,解压:liuhongdi@lhdpc:/......
  • Visual Studio 2013 jsoncpp 0.10.7库编译
    前言全局说明VisualStudio2013jsoncpp编译jsoncpp介绍说明:https://www.cnblogs.com/wutou/p/18367551一、说明环境:Windows7旗舰版VisualStudio2013二、选择根据vs2013工具环境和jsoncpp介绍,这里选用0.10.7版本演示三、准备3.1解压文件进入m......
  • Gradle编译项目Druid找不到tools.jar和jconsole.jar
     原因:jdk11之后不支持druid的两个依赖方法一:<dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.2.5</version>方法二:<!--<exclusions><exclusion><gro......
  • TypeScript学习之旅--编译选项
    本文简单聊一下TS文件的编译,以及TS编译的配置文件入门我们都知道TS文件需要先编译成js文件后才可以运行,编译TS文件可以在命令行执行  tsc ts文件名,得到对应的同名js文件,但每次改完代码后都需要重新执行编译,或者多个ts文件都需要多次编译,给我们的编码工作带来极大不便~编译......
  • 关于MNN工程框架编译出来的静态库和动态库的使用
    一、MNN.lib文件路径如果你看过之前的博客内容,应该可以在编译的的工程当中C:\Users\Administrator\Desktop\MNN\MNN-master\MNN-CPU-OPENCL\lib\x64\lib\x64该路径下面找到debug和release两个文件夹。进入到release文件夹下面有Dynamic和Static两个文件夹,分别代表编译出来的......
  • C语言编程-GCC编译过程
    gcc编译预处理->编译->汇编->链接预处理gcc-Ehelloworld.c-ohelloworld.i头文件展开;不检查语法错误,即可以展开任意文件;宏定义替换;将宏名替换为宏值;替换注释;将注释替换为空行;展开条件编译;根据条件来展开指令;编译gcc-Shelloworld.i-ohelloworld.s逐行检查......
  • Ubuntu 中GCC交叉编译工具链安装
    ​Ubuntu自带的gcc编译器是针对X86架构的,如果要编译的是ARM架构的代码,就需要一个在X86架构的PC上运行,可以编译ARM架构代码的GCC编译器,这个编译器就叫做交叉编译器,总结一下交叉编译器就是:1、它肯定是一个GCC编译器。2、这个GCC编译器是运行在X86架......
  • 【Android驱动12】Modem编译和sim卡配置检测过程
    一,Modem编译1.1查看ReleseNote发现需要查看"Build_Configure_Modem_MOLY"这张表,解压MT67xx_(xxx)_MOLY.LR9.W1444.MD.LWTG.MP.Vx.tar.gz到某文件,并在make目录下查看支持的配置信息1.2执行的命令,开始编译modem,则是./make.sh"SM67xx(Lxx_xxx).mak"new1.3执行perl......
  • 手把手教你利用算法工具链训练、量化、编译、可视化征程 6 参考算法 BEVFormer
    写在前面:关于OE包内参考算法的使用,地平线已经释放了大量文档指导用户完成各类模型的训练、校准、量化、定点过程,但其中有些细节可能会对不是特别熟悉算法工具链的客户造成困扰,本文档致力于消除参考算法使用过程中所有可能存在的模糊操作,引导初学者快速上手参考算法,在实操中树立......
  • brpc linux 下编译构建
    brpc在linux下编译构建,比在mac下还要更复杂些,mac下可以走官方说明编译成功,过程中也需要进行一些配置调整。在linux通过bazel最终实现了brpc编译通过。   相关版本centos版本7,bazel版本2.0.0    brpc版本1.0,gflags、protobuf、leveldb......