mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 12:16:31 +00:00
完善libc,构建了OS-specific工具链,编译了基于gcc-11.3.0的DragonOS userland compiler,移植了mpfr,gmp,mpc库 (#134)
* 修改include路径 * 添加了创建libsysapi.a和/bin/sysroot/usr/include/+lib/的代码 * 修补.gitignore * 删除多余项 * 优化脚本可读性 * 新增crt0 crti crtn * 编译binutils所需的东西 * fflush()和fprintf()的简单实现 * 应用程序启动前,调用初始化libc的函数 * 自动创建sysroot * 添加了stderr的初始化 * 修改了stderr的初始化 * 内核添加对stdio的简略处理 * 格式化代码 * 修正打开stdio文件描述符的问题 * bugfix: 修复fprintf忘记释放buf的问题 * 修复shell错误地把入口设置为main而不是_start的问题 * 新增__cxa_atexit (gcc要求libc提供这个) * 增加putchar puts * 更新写入磁盘镜像的脚本,默认无参数时,使用legacy方式安装 * 更新编译脚本 * stdio增加eof的定义 * 新增extern cplusplus * mpfr gmp mpc 构建脚本 * 更新libsysapi.a为libc.a * 加上ferror fopen fclose * 更新移植的软件的构建脚本 * 更改build_gcc_toolchain.sh中的-save参数名为-save-cache Co-authored-by: longjin <longjin@RinGoTek.cn>
This commit is contained in:
1
user/port/binutils/2.38/.gitignore
vendored
Normal file
1
user/port/binutils/2.38/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
build-binutils/
|
41
user/port/binutils/2.38/Dockerfile
Normal file
41
user/port/binutils/2.38/Dockerfile
Normal file
@ -0,0 +1,41 @@
|
||||
# 本Dockerfile用于构建binutils 2.38的交叉编译环境
|
||||
|
||||
FROM ubuntu:jammy
|
||||
|
||||
# Install dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
autoconf2.69 \
|
||||
automake \
|
||||
bison \
|
||||
build-essential \
|
||||
flex \
|
||||
gawk \
|
||||
gettext \
|
||||
git \
|
||||
libgmp-dev \
|
||||
libmpc-dev \
|
||||
libmpfr-dev \
|
||||
libncurses5-dev \
|
||||
libtool \
|
||||
m4 \
|
||||
make \
|
||||
ninja-build \
|
||||
python3 \
|
||||
texinfo \
|
||||
wget \
|
||||
xz-utils \
|
||||
zlib1g-dev \
|
||||
wget \
|
||||
&& rm /usr/bin/autoconf && ln -s /usr/bin/autoconf2.69 /usr/bin/autoconf
|
||||
|
||||
WORKDIR /opt
|
||||
|
||||
# download automake 1.15.1
|
||||
RUN wget http://mirrors.ustc.edu.cn/gnu/automake/automake-1.15.1.tar.xz && \
|
||||
tar -xvf automake-1.15.1.tar.xz && \
|
||||
cd automake-1.15.1 && \
|
||||
./configure --prefix=/usr && \
|
||||
make && \
|
||||
make install && \
|
||||
cd .. && \
|
||||
rm -rf automake-1.15.1 automake-1.15.1.tar.xz
|
25
user/port/binutils/2.38/README.md
Normal file
25
user/port/binutils/2.38/README.md
Normal file
@ -0,0 +1,25 @@
|
||||
# binutils-2.38
|
||||
|
||||
## 说明
|
||||
|
||||
这里是移植到用户态的binutils-2.38,用于DragonOS的用户态编译器。在编译这里之前,请先在项目根目录下运行`make -j $(nproc)`, 以确保编译binutils所依赖的依赖库已经编译好。
|
||||
|
||||
先修改build.sh中的路径,配置好需要的信息,再使用以下命令,即可开始编译:
|
||||
|
||||
```bash
|
||||
bash build.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
请注意,如果您要修改binutils的代码,请先使用以下命令,构建编辑binutils代码配置的环境:
|
||||
|
||||
```bash
|
||||
docker build --no-cache -t dragonos-binutils-build .
|
||||
```
|
||||
|
||||
然后再在binutils目录下执行以下命令,进入容器:
|
||||
|
||||
```bash
|
||||
docker run --rm -it -v $PWD:/workdir -w /workdir dragonos-binutils-build
|
||||
```
|
42
user/port/binutils/2.38/build.sh
Normal file
42
user/port/binutils/2.38/build.sh
Normal file
@ -0,0 +1,42 @@
|
||||
# 编译前请先设置参数
|
||||
sys_root=$DRAGONOS_SYSROOT
|
||||
binutils_path=请填写binutils的路径
|
||||
|
||||
# 要安装到的目录
|
||||
PREFIX=$HOME/opt/dragonos-host-userspace
|
||||
|
||||
|
||||
if [ ! -d ${binutils_path} ]; then
|
||||
echo "Error: ${binutils_path} not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d ${sysroot} ]; then
|
||||
echo "Error: ${sysroot} not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
mkdir -p build-binutils || exit 1
|
||||
mkdir -p ${PREFIX} || exit 1
|
||||
|
||||
# 安装依赖
|
||||
# 注意texinfo和binutils的版本是否匹配
|
||||
# 注意gmp/mpc/mpfr和gcc/g++的版本是否匹配
|
||||
sudo apt-get install -y \
|
||||
g++ \
|
||||
gcc \
|
||||
make \
|
||||
texinfo \
|
||||
libgmp3-dev \
|
||||
libmpc-dev \
|
||||
libmpfr-dev \
|
||||
flex \
|
||||
wget
|
||||
|
||||
cd build-binutils
|
||||
${binutils_path}/configure --prefix=${PREFIX} --target=x86_64-dragonos --with-sysroot=${sysroot} --disable-werror || exit 1
|
||||
make -j $(nproc) || exit 1
|
||||
make install || exit 1
|
||||
make clean || exit 1
|
||||
rm -rf build-binutils
|
1
user/port/binutils/2.38/run.sh
Normal file
1
user/port/binutils/2.38/run.sh
Normal file
@ -0,0 +1 @@
|
||||
docker run --rm -it -v $PWD:/workdir -w /workdir binutils-2.38
|
Reference in New Issue
Block a user