mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-08 18:26:48 +00:00
Patch porting gcc v2 (#124)
* 更改编译器的Include路径,使得include时不需要加`<libc/src/include/>`前缀 * 修改include路径 Co-authored-by: longjin <longjin@RinGoTek.cn>
This commit is contained in:
parent
d4f3de93a2
commit
74bde36e01
7
.vscode/c_cpp_properties.json
vendored
7
.vscode/c_cpp_properties.json
vendored
@ -1,15 +1,16 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"name": "DragonOS",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
"${workspaceFolder}/**",
|
||||
"${workspaceFolder}/user/libs/libc/src/include"
|
||||
],
|
||||
"defines": [
|
||||
"__x86_64__",
|
||||
"DEBUG"
|
||||
],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"compilerPath": "~/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin/x86_64-elf-gcc",
|
||||
"cStandard": "gnu17",
|
||||
"cppStandard": "gnu++14",
|
||||
"intelliSenseMode": "linux-gcc-x64"
|
||||
|
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@ -169,8 +169,9 @@
|
||||
"stdint-gcc.h": "c",
|
||||
"acpi.h": "c",
|
||||
"assert.h": "c",
|
||||
"sys_version.h": "c"
|
||||
},
|
||||
"sys_version.h": "c",
|
||||
"cmd.h": "c"
|
||||
},
|
||||
"C_Cpp.errorSquiggles": "Enabled",
|
||||
"esbonio.sphinx.confDir": "",
|
||||
"rust-analyzer.cargo.target": "x86_64-unknown-none",
|
||||
|
2
Makefile
2
Makefile
@ -47,12 +47,14 @@ all: kernel user
|
||||
.PHONY: kernel
|
||||
kernel:
|
||||
mkdir -p bin/kernel/
|
||||
@if [ -z $$DragonOS_GCC ]; then echo "\033[31m [错误]尚未安装DragonOS交叉编译器, 请使用tools文件夹下的build_gcc_toolchain.sh脚本安装 \033[0m"; exit 1; fi
|
||||
$(MAKE) -C ./kernel all || (sh -c "echo 内核编译失败" && exit 1)
|
||||
|
||||
.PHONY: user
|
||||
user:
|
||||
mkdir -p bin/user/
|
||||
mkdir -p bin/tmp/user
|
||||
@if [ -z $$DragonOS_GCC ]; then echo "\033[31m [错误]尚未安装DragonOS交叉编译器, 请使用tools文件夹下的build_gcc_toolchain.sh脚本安装 \033[0m"; exit 1; fi
|
||||
$(MAKE) -C ./user all || (sh -c "echo 用户程序编译失败" && exit 1)
|
||||
|
||||
.PHONY: clean
|
||||
|
@ -9,7 +9,7 @@ GARBAGE := $(foreach DIR,$(DIRS),$(addprefix $(DIR)/,$(GARBAGE_PATTERNS)))
|
||||
tmp_output_dir=$(ROOT_PATH)/bin/tmp/user
|
||||
output_dir=$(ROOT_PATH)/bin/user
|
||||
|
||||
CFLAGS := $(GLOBAL_CFLAGS) -I $(shell pwd)/libs
|
||||
CFLAGS := $(GLOBAL_CFLAGS) -I $(shell pwd)/libs -I $(shell pwd)/libs/libc/src/include
|
||||
current_CFLAGS := $(CFLAGS)
|
||||
|
||||
ECHO:
|
||||
@ -22,7 +22,6 @@ $(user_sub_dirs): ECHO sys_api_lib
|
||||
app: $(user_sub_dirs)
|
||||
|
||||
all: app
|
||||
@if [ -z $$DragonOS_GCC ]; then echo "\033[31m [错误]尚未安装DragonOS交叉编译器, 请使用tools文件夹下的build_gcc_toolchain.sh脚本安装 \033[0m"; exit 1; fi
|
||||
$(shell if [ ! -e $(tmp_output_dir) ];then mkdir -p $(tmp_output_dir); fi)
|
||||
$(shell if [ ! -e $(output_dir) ];then mkdir -p $(output_dir); fi)
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "sys_version.h" // 这是系统的版本头文件,在编译过程中自动生成
|
||||
#include <libc/src/math.h>
|
||||
#include <libc/src/stdio.h>
|
||||
#include <libc/src/stdlib.h>
|
||||
#include <libc/src/time.h>
|
||||
#include <libc/src/unistd.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void print_ascii_logo()
|
||||
{
|
||||
|
@ -1,17 +1,17 @@
|
||||
#include "cmd.h"
|
||||
#include "cmd_help.h"
|
||||
#include "cmd_test.h"
|
||||
#include <libc/src/dirent.h>
|
||||
#include <libc/src/errno.h>
|
||||
#include <libc/src/fcntl.h>
|
||||
#include <libc/src/include/signal.h>
|
||||
#include <libc/src/stddef.h>
|
||||
#include <libc/src/stdio.h>
|
||||
#include <libc/src/stdlib.h>
|
||||
#include <libc/src/string.h>
|
||||
#include <libc/src/sys/stat.h>
|
||||
#include <libc/src/sys/wait.h>
|
||||
#include <libc/src/unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <libsystem/syscall.h>
|
||||
|
||||
// 当前工作目录(在main_loop中初始化)
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "cmd_help.h"
|
||||
#include <libc/src/stdio.h>
|
||||
#include <libc/src/stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct help_table_item_t
|
||||
{
|
||||
void (*func)();
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "cmd_test.h"
|
||||
#include <libc/src/stdio.h>
|
||||
#include <libc/src/stdlib.h>
|
||||
#include <libc/src/string.h>
|
||||
#include <libc/src/unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int shell_pipe_test(int argc, char **argv)
|
||||
{
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "cmd.h"
|
||||
#include <libKeyboard/keyboard.h>
|
||||
#include <libc/src/fcntl.h>
|
||||
#include <libc/src/printf.h>
|
||||
#include <libc/src/stddef.h>
|
||||
#include <libc/src/stdio.h>
|
||||
#include <libc/src/stdlib.h>
|
||||
#include <libc/src/string.h>
|
||||
#include <libc/src/sys/stat.h>
|
||||
#include <libc/src/unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <printf.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define pause_cpu() asm volatile("pause\n\t");
|
||||
#define MEM_HISTORY 1024
|
||||
|
@ -17,13 +17,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <libc/src/math.h>
|
||||
#include <libc/src/stdio.h>
|
||||
#include <libc/src/stdlib.h>
|
||||
#include <libc/src/time.h>
|
||||
#include <libc/src/unistd.h>
|
||||
|
||||
#include <libc/src/include/signal.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
bool handle_ok = false;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "keyboard.h"
|
||||
#include <libc/src/unistd.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// 功能键标志变量
|
||||
static bool shift_l = 0, shift_r = 0, ctrl_l = 0, ctrl_r = 0, alt_l = 0, alt_r = 0;
|
||||
static bool gui_l = 0, gui_r = 0, apps = 0, insert = 0, home = 0, pgup = 0, del = 0, end = 0, pgdn = 0, arrow_u = 0, arrow_l = 0, arrow_d = 0, arrow_r = 0;
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
all:
|
||||
$(MAKE) -C src all
|
||||
$(MAKE) CFLAGS="$(CFLAGS)" -C src all
|
||||
|
||||
clean:
|
||||
rm -f Cargo.lock
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <libc/src/ctype.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
int isprint(int c)
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "dirent.h"
|
||||
#include "unistd.h"
|
||||
#include "stdio.h"
|
||||
#include "fcntl.h"
|
||||
#include "stddef.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libsystem/syscall.h>
|
||||
|
||||
/**
|
||||
|
@ -1,2 +1,2 @@
|
||||
#include "errno.h"
|
||||
#include <errno.h>
|
||||
int errno = 0;
|
@ -1,4 +1,4 @@
|
||||
#include <libc/src/fcntl.h>
|
||||
#include <fcntl.h>
|
||||
#include <libsystem/syscall.h>
|
||||
|
||||
/**
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <libc/src/sys/types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <libc/src/__libc__.h>
|
||||
#include <__libc__.h>
|
||||
|
||||
|
||||
int isalnum(int c);
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <libc/src/sys/types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
/**
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <libc/src/sys/types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// ===== 描述long double 的数据比特结构
|
||||
#if __LDBL_MANT_DIG__ == 53 && __LDBL_MAX_EXP__ == 1024
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "stddef.h"
|
||||
#include <stddef.h>
|
||||
|
||||
double fabs(double x);
|
||||
float fabsf(float x);
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <libc/src/unistd.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define SIGHUP 1
|
||||
#define SIGINT 2
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <libc/src/sys/types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <libc/src/sys/types.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
// 字体颜色的宏定义
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <libc/src/sys/types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/**
|
||||
* @brief 获取一块堆内存
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <libc/src/sys/types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
void *memset(void *dst, unsigned char C, uint64_t size);
|
||||
/**
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <libc/src/sys/types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/**
|
||||
* @brief 系统内存信息结构体(单位:字节)
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <libc/src/include/stdint.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef unsigned char u_char;
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
/**
|
||||
* @brief 等待所有子进程退出
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "stddef.h"
|
||||
#include <stddef.h>
|
||||
|
||||
// 操作系统定义时间以ns为单位
|
||||
#define CLOCKS_PER_SEC 1000000
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <libc/src/include/stdint.h>
|
||||
#include <libc/src/sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/**
|
||||
* @brief 关闭文件接口
|
@ -1,9 +1,9 @@
|
||||
#include <libc/src/stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <libsystem/syscall.h>
|
||||
#include <libc/src/stddef.h>
|
||||
#include <libc/src/unistd.h>
|
||||
#include <libc/src/errno.h>
|
||||
#include <libc/src/stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define PAGE_4K_SHIFT 12
|
||||
#define PAGE_2M_SHIFT 21
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <libc/src/math.h>
|
||||
#include <libc/src/sys/types.h>
|
||||
#include "libm.h"
|
||||
#include <math.h>
|
||||
#include <sys/types.h>
|
||||
#include <libm.h>
|
||||
|
||||
double fabs(double x)
|
||||
{
|
||||
union
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <libc/src/math.h>
|
||||
#include <libc/src/stddef.h>
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
|
||||
int64_t pow(int64_t x, int y)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "libm.h"
|
||||
#include <libm.h>
|
||||
|
||||
#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 1
|
||||
#define EPS __DBL_EPSILON__
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "printf.h"
|
||||
#include <printf.h>
|
||||
|
||||
#include <libc/src/math.h>
|
||||
#include <libc/src/stdio.h>
|
||||
#include <libc/src/stdlib.h>
|
||||
#include <libc/src/string.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libsystem/syscall.h>
|
||||
|
||||
static char *write_num(char *str, uint64_t num, int base, int field_width, int precision, int flags);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <libc/src/include/signal.h>
|
||||
#include <libc/src/printf.h>
|
||||
#include <libc/src/stddef.h>
|
||||
#include <signal.h>
|
||||
#include <printf.h>
|
||||
#include <stddef.h>
|
||||
#include <libsystem/syscall.h>
|
||||
|
||||
#pragma GCC push_options
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <libc/src/ctype.h>
|
||||
#include <libc/src/stdlib.h>
|
||||
#include <libc/src/unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <libsystem/syscall.h>
|
||||
#include <libc/src/include/signal.h>
|
||||
#include <signal.h>
|
||||
|
||||
int abs(int i)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "string.h"
|
||||
#include <string.h>
|
||||
|
||||
size_t strlen(const char *s)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "stat.h"
|
||||
#include <sys/stat.h>
|
||||
#include <libsystem/syscall.h>
|
||||
|
||||
int mkdir(const char *path, mode_t mode)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "wait.h"
|
||||
#include <sys/wait.h>
|
||||
#include <libsystem/syscall.h>
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#include <libc/src/stdio.h>
|
||||
#include <libc/src/stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int main(int, char **);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "time.h"
|
||||
#include "errno.h"
|
||||
#include "unistd.h"
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <libsystem/syscall.h>
|
||||
|
||||
/**
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include <libc/src/errno.h>
|
||||
#include <libc/src/fcntl.h>
|
||||
#include <libc/src/stddef.h>
|
||||
#include <libc/src/stdio.h>
|
||||
#include <libc/src/string.h>
|
||||
#include <libc/src/unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <libsystem/syscall.h>
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "syscall.h"
|
||||
#include <libc/src/stdio.h>
|
||||
#include <libc/src/errno.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
long syscall_invoke(uint64_t syscall_id, uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6, uint64_t arg7)
|
||||
{
|
||||
uint64_t __err_code;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <libc/src/include/stdint.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// 系统调用号
|
||||
#define SYS_NOT_EXISTS 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user