build-hosted.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ##############################################
  2. # DragonOS hosted gcc build script
  3. #
  4. # This script is used to build userland gcc for DragonOS(Running on Linux)
  5. ##############################################
  6. # 编译前请先设置参数
  7. sys_root=$DRAGONOS_SYSROOT
  8. gcc_path=请填写gcc的路径
  9. # 要安装到的目录
  10. PREFIX=$HOME/opt/dragonos-host-userspace
  11. if [ ! -d ${gcc_path} ]; then
  12. echo "Error: ${gcc_path} not found"
  13. exit 1
  14. fi
  15. if [ ! -d ${sys_root} ]; then
  16. echo "Error: ${sys_root} not found"
  17. exit 1
  18. fi
  19. # 安装依赖
  20. # 注意texinfo和binutils的版本是否匹配
  21. # 注意gmp/mpc/mpfr和gcc/g++的版本是否匹配
  22. sudo apt-get install -y \
  23. g++ \
  24. gcc \
  25. make \
  26. texinfo \
  27. libgmp3-dev \
  28. libmpc-dev \
  29. libmpfr-dev \
  30. flex \
  31. wget
  32. mkdir -p build-gcc || exit 1
  33. mkdir -p ${PREFIX} || exit 1
  34. cd build-gcc
  35. ${gcc_path}/configure --prefix=${PREFIX} --target=x86_64-dragonos --with-sysroot=${sys_root} --disable-werror --disable-shared --disable-bootstrap --enable-languages=c,c++ || exit 1
  36. make all-gcc all-target-libgcc -j $(nproc) || exit 1
  37. make install-gcc install-target-libgcc -j $(nproc) || exit 1
  38. # 这里会报错,暂时不知道为什么
  39. # make all-target-libstdc++-v3 -j $(nproc) || exit 1
  40. # make install-target-libstdc++-v3 -j $(nproc) || exit 1
  41. make clean
  42. cd ..
  43. rm -rf build-gcc