Patch porting gcc v2 (#124)

* 更改编译器的Include路径,使得include时不需要加`<libc/src/include/>`前缀

* 修改include路径

Co-authored-by: longjin <longjin@RinGoTek.cn>
This commit is contained in:
guanjinquan 2022-12-31 17:35:39 +08:00 committed by GitHub
parent d4f3de93a2
commit 74bde36e01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 117 additions and 112 deletions

View File

@ -1,15 +1,16 @@
{ {
"configurations": [ "configurations": [
{ {
"name": "Linux", "name": "DragonOS",
"includePath": [ "includePath": [
"${workspaceFolder}/**" "${workspaceFolder}/**",
"${workspaceFolder}/user/libs/libc/src/include"
], ],
"defines": [ "defines": [
"__x86_64__", "__x86_64__",
"DEBUG" "DEBUG"
], ],
"compilerPath": "/usr/bin/gcc", "compilerPath": "~/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin/x86_64-elf-gcc",
"cStandard": "gnu17", "cStandard": "gnu17",
"cppStandard": "gnu++14", "cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64" "intelliSenseMode": "linux-gcc-x64"

View File

@ -169,7 +169,8 @@
"stdint-gcc.h": "c", "stdint-gcc.h": "c",
"acpi.h": "c", "acpi.h": "c",
"assert.h": "c", "assert.h": "c",
"sys_version.h": "c" "sys_version.h": "c",
"cmd.h": "c"
}, },
"C_Cpp.errorSquiggles": "Enabled", "C_Cpp.errorSquiggles": "Enabled",
"esbonio.sphinx.confDir": "", "esbonio.sphinx.confDir": "",

View File

@ -47,12 +47,14 @@ all: kernel user
.PHONY: kernel .PHONY: kernel
kernel: kernel:
mkdir -p bin/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) $(MAKE) -C ./kernel all || (sh -c "echo 内核编译失败" && exit 1)
.PHONY: user .PHONY: user
user: user:
mkdir -p bin/user/ mkdir -p bin/user/
mkdir -p bin/tmp/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) $(MAKE) -C ./user all || (sh -c "echo 用户程序编译失败" && exit 1)
.PHONY: clean .PHONY: clean

View File

@ -9,7 +9,7 @@ GARBAGE := $(foreach DIR,$(DIRS),$(addprefix $(DIR)/,$(GARBAGE_PATTERNS)))
tmp_output_dir=$(ROOT_PATH)/bin/tmp/user tmp_output_dir=$(ROOT_PATH)/bin/tmp/user
output_dir=$(ROOT_PATH)/bin/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) current_CFLAGS := $(CFLAGS)
ECHO: ECHO:
@ -22,7 +22,6 @@ $(user_sub_dirs): ECHO sys_api_lib
app: $(user_sub_dirs) app: $(user_sub_dirs)
all: app 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 $(tmp_output_dir) ];then mkdir -p $(tmp_output_dir); fi)
$(shell if [ ! -e $(output_dir) ];then mkdir -p $(output_dir); fi) $(shell if [ ! -e $(output_dir) ];then mkdir -p $(output_dir); fi)

View File

@ -1,9 +1,9 @@
#include "sys_version.h" // 这是系统的版本头文件,在编译过程中自动生成 #include "sys_version.h" // 这是系统的版本头文件,在编译过程中自动生成
#include <libc/src/math.h> #include <math.h>
#include <libc/src/stdio.h> #include <stdio.h>
#include <libc/src/stdlib.h> #include <stdlib.h>
#include <libc/src/time.h> #include <time.h>
#include <libc/src/unistd.h> #include <unistd.h>
void print_ascii_logo() void print_ascii_logo()
{ {

View File

@ -1,17 +1,17 @@
#include "cmd.h" #include "cmd.h"
#include "cmd_help.h" #include "cmd_help.h"
#include "cmd_test.h" #include "cmd_test.h"
#include <libc/src/dirent.h> #include <dirent.h>
#include <libc/src/errno.h> #include <errno.h>
#include <libc/src/fcntl.h> #include <fcntl.h>
#include <libc/src/include/signal.h> #include <signal.h>
#include <libc/src/stddef.h> #include <stddef.h>
#include <libc/src/stdio.h> #include <stdio.h>
#include <libc/src/stdlib.h> #include <stdlib.h>
#include <libc/src/string.h> #include <string.h>
#include <libc/src/sys/stat.h> #include <sys/stat.h>
#include <libc/src/sys/wait.h> #include <sys/wait.h>
#include <libc/src/unistd.h> #include <unistd.h>
#include <libsystem/syscall.h> #include <libsystem/syscall.h>
// 当前工作目录在main_loop中初始化 // 当前工作目录在main_loop中初始化

View File

@ -1,6 +1,7 @@
#include "cmd_help.h" #include "cmd_help.h"
#include <libc/src/stdio.h> #include <stdio.h>
#include <libc/src/stdlib.h> #include <stdlib.h>
struct help_table_item_t struct help_table_item_t
{ {
void (*func)(); void (*func)();

View File

@ -1,8 +1,8 @@
#include "cmd_test.h" #include "cmd_test.h"
#include <libc/src/stdio.h> #include <stdio.h>
#include <libc/src/stdlib.h> #include <stdlib.h>
#include <libc/src/string.h> #include <string.h>
#include <libc/src/unistd.h> #include <unistd.h>
int shell_pipe_test(int argc, char **argv) int shell_pipe_test(int argc, char **argv)
{ {

View File

@ -1,13 +1,13 @@
#include "cmd.h" #include "cmd.h"
#include <libKeyboard/keyboard.h> #include <libKeyboard/keyboard.h>
#include <libc/src/fcntl.h> #include <fcntl.h>
#include <libc/src/printf.h> #include <printf.h>
#include <libc/src/stddef.h> #include <stddef.h>
#include <libc/src/stdio.h> #include <stdio.h>
#include <libc/src/stdlib.h> #include <stdlib.h>
#include <libc/src/string.h> #include <string.h>
#include <libc/src/sys/stat.h> #include <sys/stat.h>
#include <libc/src/unistd.h> #include <unistd.h>
#define pause_cpu() asm volatile("pause\n\t"); #define pause_cpu() asm volatile("pause\n\t");
#define MEM_HISTORY 1024 #define MEM_HISTORY 1024

View File

@ -17,13 +17,12 @@
* *
*/ */
#include <libc/src/math.h> #include <math.h>
#include <libc/src/stdio.h> #include <stdio.h>
#include <libc/src/stdlib.h> #include <stdlib.h>
#include <libc/src/time.h> #include <time.h>
#include <libc/src/unistd.h> #include <unistd.h>
#include <signal.h>
#include <libc/src/include/signal.h>
bool handle_ok = false; bool handle_ok = false;

View File

@ -1,5 +1,6 @@
#include "keyboard.h" #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 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; 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;

View File

@ -1,6 +1,6 @@
all: all:
$(MAKE) -C src all $(MAKE) CFLAGS="$(CFLAGS)" -C src all
clean: clean:
rm -f Cargo.lock rm -f Cargo.lock

View File

@ -1,4 +1,4 @@
#include <libc/src/ctype.h> #include <ctype.h>
int isprint(int c) int isprint(int c)

View File

@ -1,10 +1,10 @@
#include "dirent.h" #include <dirent.h>
#include "unistd.h" #include <unistd.h>
#include "stdio.h" #include <stdio.h>
#include "fcntl.h" #include <fcntl.h>
#include "stddef.h" #include <stddef.h>
#include "stdlib.h" #include <stdlib.h>
#include "string.h" #include <string.h>
#include <libsystem/syscall.h> #include <libsystem/syscall.h>
/** /**

View File

@ -1,2 +1,2 @@
#include "errno.h" #include <errno.h>
int errno = 0; int errno = 0;

View File

@ -1,4 +1,4 @@
#include <libc/src/fcntl.h> #include <fcntl.h>
#include <libsystem/syscall.h> #include <libsystem/syscall.h>
/** /**

View File

@ -1,10 +1,10 @@
#pragma once #pragma once
#include <libc/src/sys/types.h> #include <sys/types.h>
#pragma once #pragma once
#include <libc/src/__libc__.h> #include <__libc__.h>
int isalnum(int c); int isalnum(int c);

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#include <libc/src/sys/types.h> #include <sys/types.h>
/** /**

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#include <libc/src/sys/types.h> #include <sys/types.h>
// ===== 描述long double 的数据比特结构 // ===== 描述long double 的数据比特结构
#if __LDBL_MANT_DIG__ == 53 && __LDBL_MAX_EXP__ == 1024 #if __LDBL_MANT_DIG__ == 53 && __LDBL_MAX_EXP__ == 1024

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#include "stddef.h" #include <stddef.h>
double fabs(double x); double fabs(double x);
float fabsf(float x); float fabsf(float x);

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#include <libc/src/unistd.h> #include <unistd.h>
#define SIGHUP 1 #define SIGHUP 1
#define SIGINT 2 #define SIGINT 2

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <libc/src/sys/types.h> #include <sys/types.h>
#ifdef __cplusplus #ifdef __cplusplus
#define NULL 0 #define NULL 0

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <libc/src/sys/types.h> #include <sys/types.h>
#include <stdarg.h> #include <stdarg.h>
// 字体颜色的宏定义 // 字体颜色的宏定义

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#include <libc/src/sys/types.h> #include <sys/types.h>
/** /**
* @brief * @brief

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <libc/src/sys/types.h> #include <sys/types.h>
void *memset(void *dst, unsigned char C, uint64_t size); void *memset(void *dst, unsigned char C, uint64_t size);
/** /**

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#include <libc/src/sys/types.h> #include <sys/types.h>
/** /**
* @brief * @brief

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <libc/src/include/stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
typedef unsigned char u_char; typedef unsigned char u_char;

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "types.h" #include <sys/types.h>
/** /**
* @brief 退 * @brief 退

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "stddef.h" #include <stddef.h>
// 操作系统定义时间以ns为单位 // 操作系统定义时间以ns为单位
#define CLOCKS_PER_SEC 1000000 #define CLOCKS_PER_SEC 1000000

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <libc/src/include/stdint.h> #include <stdint.h>
#include <libc/src/sys/types.h> #include <sys/types.h>
/** /**
* @brief * @brief

View File

@ -1,9 +1,9 @@
#include <libc/src/stdlib.h> #include <stdlib.h>
#include <libsystem/syscall.h> #include <libsystem/syscall.h>
#include <libc/src/stddef.h> #include <stddef.h>
#include <libc/src/unistd.h> #include <unistd.h>
#include <libc/src/errno.h> #include <errno.h>
#include <libc/src/stdio.h> #include <stdio.h>
#define PAGE_4K_SHIFT 12 #define PAGE_4K_SHIFT 12
#define PAGE_2M_SHIFT 21 #define PAGE_2M_SHIFT 21

View File

@ -1,6 +1,7 @@
#include <libc/src/math.h> #include <math.h>
#include <libc/src/sys/types.h> #include <sys/types.h>
#include "libm.h" #include <libm.h>
double fabs(double x) double fabs(double x)
{ {
union union

View File

@ -1,5 +1,5 @@
#include <libc/src/math.h> #include <math.h>
#include <libc/src/stddef.h> #include <stddef.h>
int64_t pow(int64_t x, int y) int64_t pow(int64_t x, int y)
{ {

View File

@ -1,4 +1,4 @@
#include "libm.h" #include <libm.h>
#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 1 #if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 1
#define EPS __DBL_EPSILON__ #define EPS __DBL_EPSILON__

View File

@ -1,9 +1,9 @@
#include "printf.h" #include <printf.h>
#include <libc/src/math.h> #include <math.h>
#include <libc/src/stdio.h> #include <stdio.h>
#include <libc/src/stdlib.h> #include <stdlib.h>
#include <libc/src/string.h> #include <string.h>
#include <libsystem/syscall.h> #include <libsystem/syscall.h>
static char *write_num(char *str, uint64_t num, int base, int field_width, int precision, int flags); static char *write_num(char *str, uint64_t num, int base, int field_width, int precision, int flags);

View File

@ -1,6 +1,6 @@
#include <libc/src/include/signal.h> #include <signal.h>
#include <libc/src/printf.h> #include <printf.h>
#include <libc/src/stddef.h> #include <stddef.h>
#include <libsystem/syscall.h> #include <libsystem/syscall.h>
#pragma GCC push_options #pragma GCC push_options

View File

@ -1,8 +1,8 @@
#include <libc/src/ctype.h> #include <ctype.h>
#include <libc/src/stdlib.h> #include <stdlib.h>
#include <libc/src/unistd.h> #include <unistd.h>
#include <libsystem/syscall.h> #include <libsystem/syscall.h>
#include <libc/src/include/signal.h> #include <signal.h>
int abs(int i) int abs(int i)
{ {

View File

@ -1,4 +1,4 @@
#include "string.h" #include <string.h>
size_t strlen(const char *s) size_t strlen(const char *s)
{ {

View File

@ -1,4 +1,4 @@
#include "stat.h" #include <sys/stat.h>
#include <libsystem/syscall.h> #include <libsystem/syscall.h>
int mkdir(const char *path, mode_t mode) int mkdir(const char *path, mode_t mode)

View File

@ -1,4 +1,4 @@
#include "wait.h" #include <sys/wait.h>
#include <libsystem/syscall.h> #include <libsystem/syscall.h>
/** /**

View File

@ -1,6 +1,6 @@
#include <libc/src/stdio.h> #include <stdio.h>
#include <libc/src/stdlib.h> #include <stdlib.h>
extern int main(int, char **); extern int main(int, char **);

View File

@ -1,6 +1,6 @@
#include "time.h" #include <time.h>
#include "errno.h" #include <errno.h>
#include "unistd.h" #include <unistd.h>
#include <libsystem/syscall.h> #include <libsystem/syscall.h>
/** /**

View File

@ -1,9 +1,9 @@
#include <libc/src/errno.h> #include <errno.h>
#include <libc/src/fcntl.h> #include <fcntl.h>
#include <libc/src/stddef.h> #include <stddef.h>
#include <libc/src/stdio.h> #include <stdio.h>
#include <libc/src/string.h> #include <string.h>
#include <libc/src/unistd.h> #include <unistd.h>
#include <libsystem/syscall.h> #include <libsystem/syscall.h>
/** /**

View File

@ -1,6 +1,6 @@
#include "syscall.h" #include "syscall.h"
#include <libc/src/stdio.h> #include <stdio.h>
#include <libc/src/errno.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) 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; uint64_t __err_code;

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <libc/src/include/stdint.h> #include <stdint.h>
// 系统调用号 // 系统调用号
#define SYS_NOT_EXISTS 0 #define SYS_NOT_EXISTS 0