Jelajahi Sumber

Merge remote-tracking branch 'origin/master' into dev-dadk-0.2.0

longjin 7 bulan lalu
induk
melakukan
e21d34f785

+ 1 - 1
docs/kernel/container/index.rst

@@ -10,4 +10,4 @@
    :maxdepth: 2
 
    namespaces/index
-   filesystem/unionfs/index
+   ../filesystem/unionfs/index

+ 1 - 1
docs/kernel/container/namespaces/index.rst

@@ -1,5 +1,5 @@
 ====================================
-名空间
+名空间
 ====================================
 
 DragonOS的namespaces目前支持pid_namespace和mnt_namespace 预计之后会继续完善

+ 3 - 3
docs/kernel/container/namespaces/mnt_namespace.md

@@ -1,10 +1,10 @@
-# 挂载名空间
+# 挂载名空间
 
 ## 底层架构
 
 pcb -> nsproxy -> mnt_namespace
 
-每一个挂载文件系统都有自立独立的挂载点,表现在数据结构上是一个挂载的红黑树,每一个名空间中挂载是独立的,所以文件系统的挂载和卸载不会影响别的
+每一个挂载文件系统都有自立独立的挂载点,表现在数据结构上是一个挂载的红黑树,每一个名空间中挂载是独立的,所以文件系统的挂载和卸载不会影响别的
 
 ## 系统调用接口
  
@@ -14,6 +14,6 @@ pcb -> nsproxy -> mnt_namespace
 - unshare 
     - 使用 CLONE_NEWPID 标志调用 unshare() 后,后续创建的所有子进程都将在新的命名空间中运行。
 - setns
-    - 将进程加入到指定的名空间
+    - 将进程加入到指定的名空间
 - chroot 
     - 将当前进程的根目录更改为指定的路径,提供文件系统隔离。

+ 5 - 3
docs/kernel/container/namespaces/pid_namespace.md

@@ -1,8 +1,10 @@
-# 进程名空间
+# 进程名空间
 :::{note} 本文作者:操丰毅 1553389239@qq.com
 
-2024年10月30日 :::
-pid_namespace 是内核中的一种名称空间,用于实现进程隔离,允许在不同的名称空间中运行的进程有独立的pid试图
+2024年10月30日
+:::
+
+pid_namespace 是内核中的一种命名空间,用于实现进程隔离,允许在不同的命名空间中运行的进程有独立的pid视图
 
 ## 底层架构
 

+ 1 - 0
docs/userland/appdev/index.rst

@@ -8,3 +8,4 @@
 
    rust-quick-start
    c-cpp-quick-start
+   DADK文档 <https://docs.dragonos.org.cn/p/dadk/>

+ 8 - 2
kernel/Cargo.toml

@@ -17,7 +17,7 @@ members = [
 [features]
 default = ["backtrace", "kvm", "fatfs", "fatfs-secure", "static_keys_test"]
 # 内核栈回溯
-backtrace = []
+backtrace = ["dep:unwinding"]
 # kvm
 kvm = []
 
@@ -68,11 +68,17 @@ lru = "0.12.3"
 
 rbpf = { path = "crates/rbpf" }
 printf-compat = { version = "0.1.1", default-features = false }
+
 static-keys = "=0.6.1"
+unwinding = { git = "https://git.mirrors.dragonos.org.cn/DragonOS-Community/unwinding", rev = "4eb845da62", default-features = false,  optional = true, features = [
+    "unwinder",
+    "fde-gnu-eh-frame-hdr",
+    "panic",
+    "personality"
+]}
 
 # target为x86_64时,使用下面的依赖
 [target.'cfg(target_arch = "x86_64")'.dependencies]
-mini-backtrace = { git = "https://git.mirrors.dragonos.org.cn/DragonOS-Community/mini-backtrace.git", rev = "e0b1d90940" }
 multiboot2 = { git = "https://git.mirrors.dragonos.org.cn/DragonOS-Community/multiboot2", rev = "05739aab40" }
 raw-cpuid = "11.0.1"
 x86 = "=0.52.0"

+ 3 - 9
kernel/Makefile

@@ -6,7 +6,7 @@ include ./env.mk
 ifeq ($(ARCH), x86_64)
 	export TARGET_JSON=arch/x86_64/x86_64-unknown-none.json
 else ifeq ($(ARCH), riscv64)
-	export TARGET_JSON=riscv64gc-unknown-none-elf
+	export TARGET_JSON=arch/riscv64/riscv64gc-unknown-none-elf.json
 endif
 
 export CARGO_ZBUILD=-Z build-std=core,alloc,compiler_builtins -Z build-std-features=compiler-builtins-mem
@@ -27,19 +27,13 @@ clean:
 fmt:
 	RUSTFLAGS="$(RUSTFLAGS)" cargo fmt --all $(FMT_CHECK)
 ifeq ($(ARCH), x86_64)
-	RUSTFLAGS="$(RUSTFLAGS)" cargo clippy --all-features
+	RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 clippy --all-features
 endif
 
 
 .PHONY: check
 check: ECHO
-# @echo "Checking kernel... ARCH=$(ARCH)"
-# @exit 1
-ifeq ($(ARCH), x86_64)
-	RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 check --workspace $(CARGO_ZBUILD) --message-format=json --target ./src/$(TARGET_JSON)
-else ifeq ($(ARCH), riscv64)
-	RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 check --workspace $(CARGO_ZBUILD) --message-format=json --target $(TARGET_JSON)
-endif
+	$(MAKE) -C src check ARCH=$(ARCH)
 
 test:
 # 测试内核库

+ 1 - 1
kernel/crates/unified-init/Cargo.toml

@@ -11,4 +11,4 @@ path = "src/main.rs"
 [dependencies]
 unified-init-macros = { path = "macros" }
 linkme = "=0.3.27"
-system_error = { path = "../system_error" }
+system_error = { path = "../system_error" }

+ 6 - 0
kernel/crates/unified-init/src/main.rs

@@ -2,6 +2,8 @@
 //! 然后在当前目录执行 `cargo expand --bin unified-init-expand`
 //! 就可以看到把proc macro展开后的代码了
 #![no_std]
+#![allow(internal_features)]
+#![feature(lang_items)]
 
 fn main() {
     todo!()
@@ -14,6 +16,10 @@ pub fn panic(_info: &core::panic::PanicInfo) -> ! {
     loop {}
 }
 
+#[cfg(target_os = "none")]
+#[lang = "eh_personality"]
+unsafe extern "C" fn eh_personality() {}
+
 #[cfg(test)]
 mod tests {
     use system_error::SystemError;

+ 26 - 6
kernel/src/Makefile

@@ -14,11 +14,9 @@ CFLAGS_UNWIND =
 LDFLAGS_UNWIND =
 RUSTFLAGS_UNWIND =
 ifeq ($(UNWIND_ENABLE), yes)
-    CFLAGS_UNWIND = -funwind-tables
-ifeq ($(ARCH), x86_64)
-    LDFLAGS_UNWIND = --eh-frame-hdr
-    RUSTFLAGS_UNWIND = -Cforce-unwind-tables -Clink-arg=-Wl,eh_frame.ld
-endif
+	CFLAGS_UNWIND = -funwind-tables
+	LDFLAGS_UNWIND = --eh-frame-hdr
+	RUSTFLAGS_UNWIND = -Cforce-unwind-tables -Clink-arg=-Wl,eh_frame.ld -Cpanic=unwind
 endif
 
 RUSTFLAGS += $(RUSTFLAGS_UNWIND)
@@ -58,7 +56,6 @@ ECHO:
 	@echo "$@"
 
 $(kernel_subdirs): ECHO
-
 	$(MAKE) -C $@ all CFLAGS="$(CFLAGS)" ASFLAGS="$(ASFLAGS)"  kernel_root_path="$(shell pwd)"
 
 kernel: $(kernel_subdirs) kernel_rust
@@ -66,7 +63,26 @@ kernel: $(kernel_subdirs) kernel_rust
 __link_riscv64_kernel:
 	@echo "Linking kernel..."
 	$(LD) -b elf64-littleriscv -z muldefs $(LDFLAGS_UNWIND) -o kernel $(shell find . -name "*.o") ../target/riscv64gc-unknown-none-elf/release/libdragonos_kernel.a -T arch/riscv64/link.ld --no-relax
+	# 生成kallsyms
+	current_dir=$(pwd)
+
+	@dbg='debug';for x in $$dbg; do \
+		cd $$x;\
+		$(MAKE) generate_kallsyms kernel_root_path="$(shell pwd)"||exit 1;\
+		cd ..;\
+	done
+
+# 重新链接
+	@echo "Re-Linking kernel..."
+	@echo $(shell find . -name "*.o")
+	$(LD) -b elf64-littleriscv -z muldefs $(LDFLAGS_UNWIND) -o kernel $(shell find . -name "*.o") ../target/riscv64gc-unknown-none-elf/release/libdragonos_kernel.a ./debug/kallsyms.o  -T arch/riscv64/link.ld --no-relax
+	@echo "Generating kernel ELF file..."
+
+ifeq ($(UNWIND_ENABLE), yes)
+	$(OBJCOPY) -I elf64-littleriscv -O elf64-littleriscv kernel ../../bin/kernel/kernel.elf
+else
 	$(OBJCOPY) -I elf64-littleriscv -O elf64-littleriscv -R ".eh_frame" kernel ../../bin/kernel/kernel.elf
+endif
 	@rm kernel
 	$(MAKE) __dragon_stub PAYLOAD_ELF="$(shell pwd)/../../bin/kernel/kernel.elf"
 
@@ -111,3 +127,7 @@ clean:
 		cd $$subdir && $(MAKE) clean;\
 		cd .. ;\
 	done
+
+.PHONY: check
+check:
+	RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 $(CARGO_ZBUILD) check --workspace --message-format=json --target $(TARGET_JSON)

+ 3 - 0
kernel/src/arch/riscv64/link.ld

@@ -28,6 +28,7 @@ SECTIONS
 
 	. = ALIGN(4096);
 	text_start_pa = .;
+	__executable_start = .;
 	.text (text_start_pa): AT(text_start_pa - KERNEL_VMA)
 	{
 		_text = .;
@@ -39,6 +40,7 @@ SECTIONS
 		*(.text.*)
 
 		_etext = .;
+		__etext = .;
 	}
 	. = ALIGN(32768);
 	data_start_pa = .;
@@ -60,6 +62,7 @@ SECTIONS
 		_rodata = .;	
 		*(.rodata)
 		*(.rodata.*)
+		*(.gcc_except_table .gcc_except_table.*)
 		_erodata = .;
 	}
 

+ 28 - 0
kernel/src/arch/riscv64/riscv64gc-unknown-none-elf.json

@@ -0,0 +1,28 @@
+{
+  "arch": "riscv64",
+  "code-model": "medium",
+  "cpu": "generic-rv64",
+  "crt-objects-fallback": "false",
+  "data-layout": "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128",
+  "eh-frame-header": false,
+  "emit-debug-gdb-scripts": false,
+  "features": "+m,+a,+f,+d,+c",
+  "linker": "rust-lld",
+  "linker-flavor": "gnu-lld",
+  "llvm-abiname": "lp64d",
+  "llvm-target": "riscv64",
+  "max-atomic-width": 64,
+  "metadata": {
+    "description": "Bare RISC-V (RV64IMAFDC ISA)",
+    "host_tools": false,
+    "std": false,
+    "tier": 2
+  },
+  "panic-strategy": "abort",
+  "relocation-model": "static",
+  "supported-sanitizers": [
+    "shadow-call-stack",
+    "kernel-address"
+  ],
+  "target-pointer-width": "64"
+}

+ 13 - 5
kernel/src/arch/riscv64/syscall/mod.rs

@@ -35,9 +35,17 @@ pub(super) fn syscall_handler(syscall_num: usize, frame: &mut TrapFrame) -> () {
     }
 
     let args = [frame.a0, frame.a1, frame.a2, frame.a3, frame.a4, frame.a5];
-    syscall_return!(
-        Syscall::handle(syscall_num, &args, frame).unwrap_or_else(|e| e.to_posix_errno() as usize),
-        frame,
-        false
-    );
+    let mut syscall_handle = || -> usize {
+        #[cfg(feature = "backtrace")]
+        {
+            Syscall::catch_handle(syscall_num, &args, frame)
+                .unwrap_or_else(|e| e.to_posix_errno() as usize)
+        }
+        #[cfg(not(feature = "backtrace"))]
+        {
+            Syscall::handle(syscall_num, &args, frame)
+                .unwrap_or_else(|e| e.to_posix_errno() as usize)
+        }
+    };
+    syscall_return!(syscall_handle(), frame, false);
 }

+ 3 - 0
kernel/src/arch/x86_64/link.lds

@@ -26,6 +26,7 @@ SECTIONS
 	. = ALIGN(32768);
 	. += KERNEL_VMA;
 	text_start_pa = .;
+	__executable_start = .;
 	.text (text_start_pa): AT(text_start_pa - KERNEL_VMA)
 	{
 		_text = .;
@@ -37,6 +38,7 @@ SECTIONS
 		*(.text.*)
 
 		_etext = .;
+		__etext = .;
 	}
 	. = ALIGN(32768);
 	data_start_pa = .;
@@ -59,6 +61,7 @@ SECTIONS
 		*(.rodata.*)
 		*(.note.gnu.*)
 		*(.fixup)
+		*(.gcc_except_table .gcc_except_table.*)
 		_erodata = .;
 	}
 

+ 13 - 6
kernel/src/arch/x86_64/syscall/mod.rs

@@ -117,12 +117,19 @@ pub extern "sysv64" fn syscall_handler(frame: &mut TrapFrame) {
         }
         _ => {}
     }
-    syscall_return!(
-        Syscall::handle(syscall_num, &args, frame).unwrap_or_else(|e| e.to_posix_errno() as usize)
-            as u64,
-        frame,
-        show
-    );
+    let mut syscall_handle = || -> u64 {
+        #[cfg(feature = "backtrace")]
+        {
+            Syscall::catch_handle(syscall_num, &args, frame)
+                .unwrap_or_else(|e| e.to_posix_errno() as usize) as u64
+        }
+        #[cfg(not(feature = "backtrace"))]
+        {
+            Syscall::handle(syscall_num, &args, frame)
+                .unwrap_or_else(|e| e.to_posix_errno() as usize) as u64
+        }
+    };
+    syscall_return!(syscall_handle(), frame, show);
 }
 
 /// 系统调用初始化

+ 1 - 0
kernel/src/debug/mod.rs

@@ -1,3 +1,4 @@
 pub mod jump_label;
 pub mod klog;
 pub mod kprobe;
+pub mod panic;

+ 27 - 0
kernel/src/debug/panic/hook.rs

@@ -0,0 +1,27 @@
+use unwinding::abi::{UnwindContext, UnwindReasonCode, _Unwind_GetIP};
+use unwinding::panic::UserUnwindTrace;
+
+extern "C" {
+    fn lookup_kallsyms(addr: u64, level: i32) -> i32;
+}
+
+/// User hook for unwinding
+///
+/// During stack backtrace, the user can print the function location of the current stack frame.
+pub struct Tracer;
+pub struct CallbackData {
+    pub counter: usize,
+}
+impl UserUnwindTrace for Tracer {
+    type Arg = CallbackData;
+
+    fn trace(ctx: &UnwindContext<'_>, arg: *mut Self::Arg) -> UnwindReasonCode {
+        let data = unsafe { &mut *(arg) };
+        data.counter += 1;
+        let pc = _Unwind_GetIP(ctx);
+        unsafe {
+            lookup_kallsyms(pc as u64, data.counter as i32);
+        }
+        UnwindReasonCode::NO_REASON
+    }
+}

+ 46 - 0
kernel/src/debug/panic/mod.rs

@@ -0,0 +1,46 @@
+#[cfg(feature = "backtrace")]
+mod hook;
+use core::panic::PanicInfo;
+
+/// 全局的panic处理函数
+///
+#[cfg(target_os = "none")]
+#[panic_handler]
+#[no_mangle]
+pub fn panic(info: &PanicInfo) -> ! {
+    use log::error;
+
+    use crate::process;
+
+    error!("Kernel Panic Occurred.");
+
+    match info.location() {
+        Some(loc) => {
+            println!(
+                "Location:\n\tFile: {}\n\tLine: {}, Column: {}",
+                loc.file(),
+                loc.line(),
+                loc.column()
+            );
+        }
+        None => {
+            println!("No location info");
+        }
+    }
+    println!("Message:\n\t{}", info.message());
+    #[cfg(feature = "backtrace")]
+    {
+        let mut data = hook::CallbackData { counter: 0 };
+        println!("Rust Panic Backtrace:");
+        let _res = unwinding::panic::begin_panic_with_hook::<hook::Tracer>(
+            alloc::boxed::Box::new(()),
+            &mut data,
+        );
+        // log::error!("panic unreachable: {:?}", res.0);
+    }
+    println!(
+        "Current PCB:\n\t{:?}",
+        process::ProcessManager::current_pcb()
+    );
+    process::ProcessManager::exit(usize::MAX);
+}

+ 0 - 52
kernel/src/lib.rs

@@ -37,8 +37,6 @@
 #[macro_use]
 extern crate std;
 
-use core::panic::PanicInfo;
-
 /// 导出x86_64架构相关的代码,命名为arch模块
 #[macro_use]
 mod arch;
@@ -94,56 +92,6 @@ extern crate wait_queue_macros;
 
 use crate::mm::allocator::kernel_allocator::KernelAllocator;
 
-#[cfg(all(feature = "backtrace", target_arch = "x86_64"))]
-extern crate mini_backtrace;
-
-extern "C" {
-    fn lookup_kallsyms(addr: u64, level: i32) -> i32;
-}
-
 // 声明全局的分配器
 #[cfg_attr(not(test), global_allocator)]
 pub static KERNEL_ALLOCATOR: KernelAllocator = KernelAllocator;
-
-/// 全局的panic处理函数
-#[cfg(target_os = "none")]
-#[panic_handler]
-#[no_mangle]
-pub fn panic(info: &PanicInfo) -> ! {
-    use log::error;
-    use process::ProcessManager;
-
-    error!("Kernel Panic Occurred.");
-
-    match info.location() {
-        Some(loc) => {
-            println!(
-                "Location:\n\tFile: {}\n\tLine: {}, Column: {}",
-                loc.file(),
-                loc.line(),
-                loc.column()
-            );
-        }
-        None => {
-            println!("No location info");
-        }
-    }
-    println!("Message:\n\t{}", info.message());
-
-    #[cfg(all(feature = "backtrace", target_arch = "x86_64"))]
-    {
-        unsafe {
-            let bt = mini_backtrace::Backtrace::<16>::capture();
-            println!("Rust Panic Backtrace:");
-            let mut level = 0;
-            for frame in bt.frames {
-                lookup_kallsyms(frame as u64, level);
-                level += 1;
-            }
-        };
-    }
-
-    println!("Current PCB:\n\t{:?}", (ProcessManager::current_pcb()));
-
-    ProcessManager::exit(usize::MAX);
-}

+ 14 - 0
kernel/src/syscall/mod.rs

@@ -74,6 +74,20 @@ impl Syscall {
 
         return r;
     }
+    /// 系统调用分发器,用于分发系统调用。
+    ///
+    /// 与[handle]不同,这个函数会捕获系统调用处理函数的panic,返回错误码。
+    #[cfg(feature = "backtrace")]
+    pub fn catch_handle(
+        syscall_num: usize,
+        args: &[usize],
+        frame: &mut TrapFrame,
+    ) -> Result<usize, SystemError> {
+        let res = unwinding::panic::catch_unwind(|| Self::handle(syscall_num, args, frame));
+        res.unwrap_or_else(|_| loop {
+            core::hint::spin_loop();
+        })
+    }
     /// @brief 系统调用分发器,用于分发系统调用。
     ///
     /// 这个函数内,需要根据系统调用号,调用对应的系统调用处理函数。

+ 0 - 6
user/Makefile

@@ -1,10 +1,5 @@
 user_sub_dirs = apps
 
-SUBDIR_ROOTS := . 
-DIRS := . $(shell find $(SUBDIR_ROOTS) -type d)
-GARBAGE_PATTERNS := *.o *.a
-GARBAGE := $(foreach DIR,$(DIRS),$(addprefix $(DIR)/,$(GARBAGE_PATTERNS)))
-
 DADK_VERSION=$(shell dadk -V | awk 'END {print $$2}')
 # 最小的DADK版本
 MIN_DADK_VERSION = 0.1.11
@@ -63,7 +58,6 @@ copy_sysconfig:
 
 .PHONY: clean
 clean:
-	rm -rf $(GARBAGE)
 	$(MAKE) dadk_clean
 	@list='$(user_sub_dirs)'; for subdir in $$list; do \
 		echo "Clean in dir: $$subdir";\

+ 0 - 15
user/port/README.md

@@ -1,15 +0,0 @@
-# port目录
----
-
-本目录移植到DragonOS的应用程序。
-
-可以包含以下类型的文件:
-
-- 移植的patch,以及编译脚本、编译用的Dockerfile等
-- 把子目录作为git仓库的submodule
-
-## 注意
-
-编译好libc之后,要把sysroot/usr/lib的文件,复制到$HOME/opt/dragonos-host-userspace/x86_64-dragonos/lib. 因为ld会从这里面找链接的东西。
-
-目前由于DragonOS的libc还不完善,所以尚未能使用用户态交叉编译器来编译flex。

+ 0 - 1
user/port/binutils/2.38/.gitignore

@@ -1 +0,0 @@
-build-binutils/

+ 0 - 41
user/port/binutils/2.38/Dockerfile

@@ -1,41 +0,0 @@
-# 本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

+ 0 - 25
user/port/binutils/2.38/README.md

@@ -1,25 +0,0 @@
-# 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
-```

+ 0 - 42
user/port/binutils/2.38/build.sh

@@ -1,42 +0,0 @@
-# 编译前请先设置参数
-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 ${sys_root} ]; then
-    echo "Error: ${sys_root} 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=${sys_root} --disable-werror || exit 1
-make -j $(nproc) || exit 1
-make install || exit 1
-make clean || exit 1
-rm -rf build-binutils

+ 0 - 1
user/port/binutils/2.38/run.sh

@@ -1 +0,0 @@
-docker run --rm -it -v $PWD:/workdir -w /workdir binutils-2.38

+ 0 - 17
user/port/build.sh

@@ -1,17 +0,0 @@
-source pkg-config.sh
-path=(
-    gmp/6.2.1
-    mpfr/4.1.1
-    mpc/1.2.1
-    flex/2.6.4
-)
-
-current_path=$(pwd)
-
-for i in ${path[@]}; do
-    echo "Building $i"
-    cd $i
-    ./build.sh || exit 1
-    cd $current_path
-done
-cd $current_path

+ 0 - 1
user/port/flex/2.6.4/.gitignore

@@ -1 +0,0 @@
-build/

+ 0 - 37
user/port/flex/2.6.4/build.sh

@@ -1,37 +0,0 @@
-
-# 编译前请先设置参数
-sys_root=$DRAGONOS_SYSROOT
-src_path=请填写flex的路径
-
-current_path=$(pwd)
-# 要安装到的目录
-PREFIX=/usr
-
-
-if [ ! -d ${src_path} ]; then
-    echo "Error: ${src_path} not found"
-    exit 1
-fi
-
-if [ ! -d ${sysroot} ]; then
-    echo "Error: ${sysroot} not found"
-    exit 1
-fi
-
-cd ${src_path}
-autoreconf --install
-autoconf
-sed -i 's/ios[*]/ios* | dragonos* /' build-aux/config.sub
-
-cd ${current_path}
-
-mkdir -p build || exit 1
-mkdir -p ${PREFIX} || exit 1
-
-cd build
-${src_path}/configure --prefix=${PREFIX} --host=x86_64-dragonos || exit 1
-make -j $(nproc) || exit 1
-make DESTDIR=${sys_root} install|| exit 1
-make clean
-cd ..
-rm -rf build

+ 0 - 1
user/port/gcc/11.3.0/.gitignore

@@ -1 +0,0 @@
-build-gcc/

+ 0 - 51
user/port/gcc/11.3.0/build-hosted.sh

@@ -1,51 +0,0 @@
-##############################################
-# DragonOS hosted gcc build script
-#
-# This script is used to build userland gcc for DragonOS(Running on Linux)
-##############################################
-
-# 编译前请先设置参数
-sys_root=$DRAGONOS_SYSROOT
-gcc_path=请填写gcc的路径
-
-# 要安装到的目录
-PREFIX=$HOME/opt/dragonos-host-userspace
-
-
-if [ ! -d ${gcc_path} ]; then
-    echo "Error: ${gcc_path} not found"
-    exit 1
-fi
-
-if [ ! -d ${sys_root} ]; then
-    echo "Error: ${sys_root} not found"
-    exit 1
-fi
-
-# 安装依赖
-# 注意texinfo和binutils的版本是否匹配
-# 注意gmp/mpc/mpfr和gcc/g++的版本是否匹配
-sudo apt-get install -y \
-    g++ \
-    gcc \
-    make \
-    texinfo \
-    libgmp3-dev \
-    libmpc-dev \
-    libmpfr-dev \
-    flex \
-    wget
-
-mkdir -p build-gcc || exit 1
-mkdir -p ${PREFIX} || exit 1
-
-cd build-gcc
-${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
-make all-gcc all-target-libgcc -j $(nproc) || exit 1
-make install-gcc install-target-libgcc -j $(nproc)  || exit 1
-# 这里会报错,暂时不知道为什么
-# make all-target-libstdc++-v3 -j $(nproc) || exit 1
-# make install-target-libstdc++-v3 -j $(nproc) || exit 1
-make clean
-cd ..
-rm -rf build-gcc

+ 0 - 28
user/port/gmp/6.2.1/build.sh

@@ -1,28 +0,0 @@
-# 编译前请先设置参数
-sys_root=$DRAGONOS_SYSROOT
-gmp_path=请填写gmp的路径
-
-# 要安装到的目录
-PREFIX=/usr
-
-
-if [ ! -d ${gmp_path} ]; then
-    echo "Error: ${gmp_path} not found"
-    exit 1
-fi
-
-if [ ! -d ${sysroot} ]; then
-    echo "Error: ${sysroot} not found"
-    exit 1
-fi
-
-mkdir -p build-gmp || exit 1
-mkdir -p ${PREFIX} || exit 1
-
-cd build-gmp
-${gmp_path}/configure --prefix=${PREFIX} --host=x86_64-dragonos  || exit 1
-make -j $(nproc) || exit 1
-make DESTDIR=${sys_root} install|| exit 1
-make clean
-cd ..
-rm -rf build-gmp

+ 0 - 35
user/port/mpc/1.2.1/build.sh

@@ -1,35 +0,0 @@
-# 编译前请先设置参数
-sys_root=$DRAGONOS_SYSROOT
-mpc_path=请填写mpc的路径
-
-# 要安装到的目录
-PREFIX=/usr
-current_path=$(pwd)
-
-if [ ! -d ${mpc_path} ]; then
-    echo "Error: ${mpc_path} not found"
-    exit 1
-fi
-
-if [ ! -d ${sysroot} ]; then
-    echo "Error: ${sysroot} not found"
-    exit 1
-fi
-
-cd ${mpc_path}
-autoreconf --install || exit 1
-autoconf
-sed -i 's/ios[*]/ios* | dragonos* /' build-aux/config.sub
-
-cd ${current_path}
-
-mkdir -p build || exit 1
-mkdir -p ${PREFIX} || exit 1
-
-cd build
-${mpc_path}/configure --prefix=${PREFIX} --host=x86_64-dragonos --target=x86_64-dragonos --with-mpfr=$sys_root/usr --with-gmp=$sys_root/usr || exit 1
-make -j $(nproc) || exit 1
-make DESTDIR=${sys_root} install || exit 1
-make clean
-cd ..
-rm -rf build

+ 0 - 37
user/port/mpfr/4.1.1/build.sh

@@ -1,37 +0,0 @@
-
-# 编译前请先设置参数
-sys_root=$DRAGONOS_SYSROOT
-src_path=请填写mpfr的路径
-
-current_path=$(pwd)
-# 要安装到的目录
-PREFIX=/usr
-
-
-if [ ! -d ${src_path} ]; then
-    echo "Error: ${src_path} not found"
-    exit 1
-fi
-
-if [ ! -d ${sysroot} ]; then
-    echo "Error: ${sysroot} not found"
-    exit 1
-fi
-
-cd ${src_path}
-autoreconf --install
-autoconf
-sed -i 's/ios[*]/ios* | dragonos* /' config.sub
-
-cd ${current_path}
-
-mkdir -p build || exit 1
-mkdir -p ${PREFIX} || exit 1
-
-cd build
-${src_path}/configure --prefix=${PREFIX} --host=x86_64-dragonos  || exit 1
-make -j $(nproc) || exit 1
-make DESTDIR=${sys_root} install|| exit 1
-make clean
-cd ..
-rm -rf build

+ 0 - 15
user/port/pkg-config.sh

@@ -1,15 +0,0 @@
-#!/bin/sh
-# Fill these in appropriately:
-ROOT_PATH=$(dirname $(dirname $(pwd)))
-DRAGONOS_SYSROOT=$ROOT_PATH/bin/sysroot
-
-
-
-export PKG_CONFIG_SYSROOT_DIR=$DRAGONOS_SYSROOT
-export PKG_CONFIG_LIBDIR=$DRAGONOS_SYSROOT/usr/lib/pkgconfig
-# TODO: If it works this should probably just be set to the empty string.
-# export PKG_CONFIG_PATH=$PKG_CONFIG_LIBDIR
-# Use --static here if your OS only has static linking.
-# TODO: Perhaps it's a bug in the libraries if their pkg-config files doesn't
-#       record that only static libraries were built.
-# exec pkg-config --static "$@"