diff --git a/.gitignore b/.gitignore
index 4ad2567e..cd754936 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
iso_tmp_data
artifacts
-initrd_tmp_data
+tmp_rootfs
rootfs/usr/include/*
!rootfs/usr/include/.gitkeep
doxygen-doc
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 877e53be..72207b4f 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -19,12 +19,12 @@
"description": "Make breakpoint pending on future shared library load."
},
{
- "text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
+ "text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/utest",
"description": "/bin/utest (0x00400000)",
"ignoreFailures": true
},
{
- "text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/libc_test",
+ "text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/libc_test",
"description": "/bin/libc_test (0x00600000)",
"ignoreFailures": true
},
@@ -52,12 +52,12 @@
"description": "Make breakpoint pending on future shared library load."
},
{
- "text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
+ "text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/utest",
"description": "/bin/utest (0x00400000)",
"ignoreFailures": true
},
{
- "text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/libc_test",
+ "text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/libc_test",
"description": "/bin/libc_test (0x00600000)",
"ignoreFailures": true
},
@@ -85,12 +85,12 @@
"description": "Make breakpoint pending on future shared library load."
},
{
- "text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
+ "text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/utest",
"description": "/bin/utest (0x00400000)",
"ignoreFailures": true
},
{
- "text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/libc_test",
+ "text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/libc_test",
"description": "/bin/libc_test (0x00600000)",
"ignoreFailures": true
},
@@ -118,12 +118,12 @@
"description": "Make breakpoint pending on future shared library load."
},
{
- "text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
+ "text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/utest",
"description": "/bin/utest (0x00400000)",
"ignoreFailures": true
},
{
- "text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/libc_test",
+ "text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/libc_test",
"description": "/bin/libc_test (0x00600000)",
"ignoreFailures": true
},
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 46012f33..9efb2e37 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -16,5 +16,6 @@
"**/tools/qemu/**": true,
"**/tools/cross/**": true,
"**/doxygen-doc/**": true,
- }
-}
\ No newline at end of file
+ },
+ "cmake.ignoreCMakeListsMissing": true
+}
diff --git a/Drivers/include/syscalls.h b/Drivers/include/syscalls.h
index 1d75bd71..a80a58c4 100644
--- a/Drivers/include/syscalls.h
+++ b/Drivers/include/syscalls.h
@@ -1807,7 +1807,7 @@ typedef enum
/* Time */
/** @copydoc SYS_TIME */
-#define call_time(t) syscall1(SYS_TIME, t)
+#define call_time(t) syscall1(SYS_TIME, (scarg)t)
/** @copydoc SYS_CLOCK_GETTIME */
#define call_clock_gettime(clockid, tp) syscall2(SYS_CLOCK_GETTIME, (scarg)clockid, (scarg)tp)
diff --git a/Kernel/core/console.cpp b/Kernel/core/console.cpp
index a70079df..89d99a98 100644
--- a/Kernel/core/console.cpp
+++ b/Kernel/core/console.cpp
@@ -130,7 +130,7 @@ namespace KernelConsole
bool SetTheme(std::string Theme)
{
- FileNode *rn = fs->GetByPath("/etc/term", thisProcess->Info.RootNode);
+ FileNode *rn = fs->GetByPath("/sys/cfg/term", thisProcess->Info.RootNode);
if (rn == nullptr)
return false;
@@ -274,7 +274,7 @@ namespace KernelConsole
void LateInit()
{
- FileNode *rn = fs->GetByPath("/etc/term", thisProcess->Info.RootNode);
+ FileNode *rn = fs->GetByPath("/sys/cfg/term", thisProcess->Info.RootNode);
if (rn == nullptr)
return;
diff --git a/Kernel/core/panic/diag.cpp b/Kernel/core/panic/diag.cpp
index 815df8e9..6c237dcb 100644
--- a/Kernel/core/panic/diag.cpp
+++ b/Kernel/core/panic/diag.cpp
@@ -115,10 +115,10 @@ nsa void DiagnosticDataCollection()
S_IROTH |
S_IFDIR;
- FileNode *panicDir = fs->ForceCreate(nullptr, "/var/panic", mode);
+ FileNode *panicDir = fs->ForceCreate(nullptr, "/sys/log/panic", mode);
if (!panicDir)
{
- ExPrint("\x1b[0;30;41mFailed to create /var/panic\x1b[0m\n");
+ ExPrint("\x1b[0;30;41mFailed to create /sys/log/panic\x1b[0m\n");
Display->UpdateBuffer();
return;
}
@@ -145,6 +145,6 @@ nsa void DiagnosticDataCollection()
if (!WriteDiagDataToNode(dumpFile))
return;
- ExPrint("You can find the diagnostic file in /var/panic/%s\n", filename);
+ ExPrint("You can find the diagnostic file in /sys/log/panic/%s\n", filename);
Display->UpdateBuffer();
}
diff --git a/Kernel/kernel.cpp b/Kernel/kernel.cpp
index 64d2619f..798631be 100644
--- a/Kernel/kernel.cpp
+++ b/Kernel/kernel.cpp
@@ -41,8 +41,8 @@ __aligned(16) BootInfo bInfo{};
struct KernelConfig Config = {
.AllocatorType = Memory::liballoc11,
.SchedulerType = Multi,
- .DriverDirectory = {'/', 'u', 's', 'r', '/', 'l', 'i', 'b', '/', 'd', 'r', 'i', 'v', 'e', 'r', 's', '\0'},
- .InitPath = {'/', 'b', 'i', 'n', '/', 'i', 'n', 'i', 't', '\0'},
+ .DriverDirectory = {'/', 's', 'y', 's', '/', 'd', 'r', 'v', '\0'},
+ .InitPath = {'/', 's', 'y', 's', '/', 'b', 'i', 'n', '/', 'i', 'n', 'i', 't', '\0'},
.UseLinuxSyscalls = false,
.InterruptsOnCrash = true,
.Cores = 0,
diff --git a/Kernel/subsystem/linux/syscall.cpp b/Kernel/subsystem/linux/syscall.cpp
index f09640e4..552d2c15 100644
--- a/Kernel/subsystem/linux/syscall.cpp
+++ b/Kernel/subsystem/linux/syscall.cpp
@@ -2133,7 +2133,7 @@ static int linux_uname(SysFrm *, struct utsname *buf)
#endif
};
- FileNode *rn = fs->GetByPath("/etc/cross/linux", pcb->Info.RootNode);
+ FileNode *rn = fs->GetByPath("/sys/cfg/cross/linux", pcb->Info.RootNode);
if (rn)
{
struct kstat st
@@ -2177,7 +2177,7 @@ static int linux_uname(SysFrm *, struct utsname *buf)
delete[] sh;
}
else
- warn("Couldn't open /etc/cross/linux");
+ warn("Couldn't open /sys/cfg/cross/linux");
memcpy(pBuf, &uname, sizeof(struct utsname));
return 0;
diff --git a/Makefile b/Makefile
index e13f9afb..2e9bb5c8 100644
--- a/Makefile
+++ b/Makefile
@@ -107,9 +107,40 @@ prepare:
$(MAKE) --quiet -C Drivers prepare
$(MAKE) --quiet -C Userspace prepare
+MKDIR_ROOTFS = mkdir -p rootfs
+mkdir_rootfs:
+ $(MKDIR_ROOTFS)/home/root/apps/
+ $(MKDIR_ROOTFS)/home/root/cfg/
+ $(MKDIR_ROOTFS)/home/root/cache/
+ $(MKDIR_ROOTFS)/home/root/trash/
+ $(MKDIR_ROOTFS)/home/root/desktop/
+ $(MKDIR_ROOTFS)/home/root/documents/
+ $(MKDIR_ROOTFS)/home/root/downloads/
+ $(MKDIR_ROOTFS)/home/root/music/
+ $(MKDIR_ROOTFS)/home/root/pictures/
+ $(MKDIR_ROOTFS)/home/root/videos/
+ $(MKDIR_ROOTFS)/home/root/templates/
+
+ $(MKDIR_ROOTFS)/sys/bin/
+ $(MKDIR_ROOTFS)/sys/lib/
+ $(MKDIR_ROOTFS)/sys/drv/
+ $(MKDIR_ROOTFS)/sys/svc/
+ $(MKDIR_ROOTFS)/sys/cfg/
+ $(MKDIR_ROOTFS)/sys/inc/
+ $(MKDIR_ROOTFS)/sys/res/
+ $(MKDIR_ROOTFS)/sys/log/panic/
+
+ $(MKDIR_ROOTFS)/usr/bin/
+ $(MKDIR_ROOTFS)/usr/lib/
+ $(MKDIR_ROOTFS)/usr/share/
+ $(MKDIR_ROOTFS)/usr/include/
+
+ $(MKDIR_ROOTFS)/tmp/
+
setup:
$(MAKE) prepare
$(MAKE) tools
+ $(MAKE) mkdir_rootfs
setup-no-qemu:
$(MAKE) --quiet -C tools ci
@@ -211,16 +242,21 @@ endif
build_image:
mkdir -p iso_tmp_data
- mkdir -p initrd_tmp_data
- cp -r rootfs/* initrd_tmp_data/
+ mkdir -p tmp_rootfs
+ cp -r rootfs/* tmp_rootfs/
ifeq ($(BUILD_DRIVERS), 1)
- cp -r Drivers/out/* initrd_tmp_data/usr/lib/drivers/
+ cp -r Drivers/out/* tmp_rootfs/sys/drv/
endif
ifeq ($(BUILD_USERSPACE), 1)
- cp -r Userspace/out/* initrd_tmp_data/
+ cp -r Userspace/out/* tmp_rootfs/
endif
-# tar czf rootfs.tar -C initrd_tmp_data/ ./ --format=ustar
- tar cf rootfs.tar -C initrd_tmp_data/ ./ --format=ustar
+ chmod -R 755 tmp_rootfs/sys/
+ chmod -R 755 tmp_rootfs/usr/
+ chmod 755 tmp_rootfs/home/
+ chmod -R 750 tmp_rootfs/home/root/
+ chmod -R 777 tmp_rootfs/tmp/
+# tar czf rootfs.tar -C tmp_rootfs/ --owner=0 --group=0 ./ --format=ustar
+ tar cf rootfs.tar -C tmp_rootfs/ --owner=0 --group=0 ./ --format=ustar
cp Kernel/fennix.elf rootfs.tar \
iso_tmp_data/
ifeq ($(BOOTLOADER), limine)
@@ -329,7 +365,7 @@ qemubios: qemu_vdisk clean_logs
run: build qemu
clean: clean_logs
- rm -rf doxygen-doc iso_tmp_data initrd_tmp_data
+ rm -rf doxygen-doc iso_tmp_data tmp_rootfs
rm -f rootfs.tar $(OSNAME).iso $(OSNAME).img
$(MAKE) -C Kernel clean
$(MAKE) -C Userspace clean
diff --git a/Userspace/.vscode/c_cpp_properties.json b/Userspace/.vscode/c_cpp_properties.json
index a8fb9cf6..4da86846 100644
--- a/Userspace/.vscode/c_cpp_properties.json
+++ b/Userspace/.vscode/c_cpp_properties.json
@@ -6,7 +6,7 @@
"${workspaceFolder}/libc/include/**",
"${workspaceFolder}/coreutils/include/**",
"${workspaceFolder}/libs/include/**",
- "${workspaceFolder}/out/include/**"
+ "${workspaceFolder}/out/usr/include/**"
],
"defines": [
"__debug_vscode__",
@@ -52,7 +52,7 @@
"${workspaceFolder}/libc/include/**",
"${workspaceFolder}/coreutils/include/**",
"${workspaceFolder}/libs/include/**",
- "${workspaceFolder}/out/include/**"
+ "${workspaceFolder}/out/usr/include/**"
],
"defines": [
"__debug_vscode__",
@@ -98,7 +98,7 @@
"${workspaceFolder}/libc/include/**",
"${workspaceFolder}/coreutils/include/**",
"${workspaceFolder}/libs/include/**",
- "${workspaceFolder}/out/include/**"
+ "${workspaceFolder}/out/usr/include/**"
],
"defines": [
"__debug_vscode__",
@@ -124,7 +124,7 @@
"${workspaceFolder}/libc/include/**",
"${workspaceFolder}/coreutils/include/**",
"${workspaceFolder}/libs/include/**",
- "${workspaceFolder}/out/include/**"
+ "${workspaceFolder}/out/usr/include/**"
],
"defines": [
"__debug_vscode__",
diff --git a/Userspace/Makefile b/Userspace/Makefile
index 57abf78b..aecb9b3d 100644
--- a/Userspace/Makefile
+++ b/Userspace/Makefile
@@ -13,7 +13,8 @@ export LDFLAGS := --sysroot=$(WORKSPACE_DIR)/out/ \
-ggdb3 -O0
export CFLAGS := \
--sysroot=$(WORKSPACE_DIR)/out/ \
- -I$(WORKSPACE_DIR)/out/include \
+ -I$(WORKSPACE_DIR)/out/sys/inc \
+ -I$(WORKSPACE_DIR)/out/usr/include \
-DDEBUG -ggdb3 -O0 -fdiagnostics-color=always
else # DEBUG
@@ -21,22 +22,22 @@ else # DEBUG
export LDFLAGS := --sysroot=$(WORKSPACE_DIR)/out/
export CFLAGS := \
--sysroot=$(WORKSPACE_DIR)/out/ \
- -I$(WORKSPACE_DIR)/out/include
+ -I$(WORKSPACE_DIR)/out/sys/inc \
+ -I$(WORKSPACE_DIR)/out/usr/include
endif # DEBUG
create_out:
rm -rf out
- mkdir -p out
- mkdir -p out/bin
- mkdir -p out/lib
- mkdir -p out/include/fennix
+ mkdir -p out/sys/bin
+ mkdir -p out/sys/lib
+ mkdir -p out/sys/inc/fennix
mkdir -p out/usr/bin
mkdir -p out/usr/lib
+ mkdir -p out/usr/include
mkdir -p out/usr/share/doc
mkdir -p out/usr/share/info
- mkdir -p out/usr/include
- cp $(WORKSPACE_DIR)/../Kernel/include/interface/* $(WORKSPACE_DIR)/out/include/fennix/
+ cp $(WORKSPACE_DIR)/../Kernel/include/interface/* $(WORKSPACE_DIR)/out/sys/inc/fennix/
build_coreutils:
mkdir -p cache/coreutils
@@ -44,8 +45,8 @@ build_coreutils:
cmake $(WORKSPACE_DIR)/coreutils \
-DCMAKE_INSTALL_PREFIX:PATH=$(WORKSPACE_DIR)/out \
-DCMAKE_SYSROOT=$(WORKSPACE_DIR)/out \
- -DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/include \
- -DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/include \
+ -DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/sys/inc $(WORKSPACE_DIR)/out/usr/include \
+ -DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/sys/inc $(WORKSPACE_DIR)/out/usr/include \
&& \
$(MAKE) -j$(shell nproc) && \
$(MAKE) install
@@ -63,7 +64,7 @@ build_libc:
cmake $(WORKSPACE_DIR)/libc \
-DCMAKE_INSTALL_PREFIX:PATH=$(WORKSPACE_DIR)/out \
-DCMAKE_SYSROOT=$(WORKSPACE_DIR)/out \
- -DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/include \
+ -DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/sys/inc $(WORKSPACE_DIR)/out/usr/include \
-DTARGET_OS=fennix \
-DTARGET_ARCH=$(OSARCH) \
&& \
diff --git a/Userspace/apps/sys/init/Makefile b/Userspace/apps/sys/init/Makefile
index 2b439d37..5a1fe973 100644
--- a/Userspace/apps/sys/init/Makefile
+++ b/Userspace/apps/sys/init/Makefile
@@ -11,7 +11,7 @@ FILENAME = $(notdir $(shell pwd))
WARNCFLAG = -Wall -Wextra
build: $(FILENAME).elf
- cp $(FILENAME).elf $(WORKSPACE_DIR)/out/bin/$(FILENAME)
+ cp $(FILENAME).elf $(WORKSPACE_DIR)/out/sys/bin/$(FILENAME)
$(FILENAME).elf: $(OBJ)
$(info Linking $@)
diff --git a/Userspace/apps/sys/init/init.c b/Userspace/apps/sys/init/init.c
index 1c15d8f4..f106741a 100644
--- a/Userspace/apps/sys/init/init.c
+++ b/Userspace/apps/sys/init/init.c
@@ -65,8 +65,8 @@ int main()
signal(SIGTERM, HandleSignal);
signal(SIGINT, HandleSignal);
- char *shellArgs[] = {"/bin/sh", NULL};
- StartProcess("/bin/sh", shellArgs);
+ char *shellArgs[] = {"/sys/bin/sh", NULL};
+ StartProcess("/sys/bin/sh", shellArgs);
// char *dummyServiceArgs[] = {"/usr/bin/dummy_service", NULL};
// StartProcess("/usr/bin/dummy_service", dummyServiceArgs);
diff --git a/Userspace/apps/sys/sh/Makefile b/Userspace/apps/sys/sh/Makefile
deleted file mode 100644
index 2b439d37..00000000
--- a/Userspace/apps/sys/sh/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-default:
- $(error Do not run this Makefile directly!)
-
-S_SOURCES = $(shell find ./ -type f -name '*.S')
-C_SOURCES = $(shell find ./ -type f -name '*.c')
-CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
-
-OBJ = $(S_SOURCES:.S=.o) $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o)
-
-FILENAME = $(notdir $(shell pwd))
-WARNCFLAG = -Wall -Wextra
-
-build: $(FILENAME).elf
- cp $(FILENAME).elf $(WORKSPACE_DIR)/out/bin/$(FILENAME)
-
-$(FILENAME).elf: $(OBJ)
- $(info Linking $@)
- $(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -o $@
-
-%.o: %.c $(HEADERS)
- $(info Compiling $<)
- $(CC) $(CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
-
-%.o: %.cpp $(HEADERS)
- $(info Compiling $<)
- $(CXX) $(CFLAGS) $(WARNCFLAG) -std=c++20 -fexceptions -c $< -o $@ -fno-rtti
-
-%.o: %.S
- $(info Compiling $<)
- $(AS) -o $@ $<
-
-clean:
- rm -f $(OBJ) $(FILENAME).elf
diff --git a/Userspace/apps/sys/sh/sh.c b/Userspace/apps/sys/sh/sh.c
deleted file mode 100644
index 38d1ef42..00000000
--- a/Userspace/apps/sys/sh/sh.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- This file is part of Fennix Userspace.
-
- Fennix Userspace is free software: you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of
- the License, or (at your option) any later version.
-
- Fennix Userspace is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Fennix Userspace. If not, see .
-*/
-#include
-#include
-#include
-#include
-#include
-#include
-
-#define MAX_INPUT_SIZE 1024
-#define MAX_ARG_SIZE 100
-
-void print_prompt()
-{
- printf("$ ");
- fflush(stdout);
-}
-
-void read_input(char *input)
-{
- if (fgets(input, MAX_INPUT_SIZE, stdin) == NULL)
- {
- perror("fgets");
- exit(EXIT_FAILURE);
- }
- input[strcspn(input, "\n")] = '\0';
-}
-
-void parse_input(char *input, char **args)
-{
- int i = 0;
- args[i] = strtok(input, " ");
- while (args[i] != NULL)
- {
- i++;
- args[i] = strtok(NULL, " ");
- }
-}
-
-void execute_command(char **args)
-{
- pid_t pid = fork();
- if (pid < 0)
- {
- perror("fork");
- exit(EXIT_FAILURE);
- }
- else if (pid == 0)
- {
- if (execvp(args[0], args) < 0)
- {
- perror("execvp");
- exit(EXIT_FAILURE);
- }
- }
- else
- {
- int status;
- waitpid(pid, &status, 0);
- if (WIFEXITED(status))
- {
- printf("Child exited with status %d\n", WEXITSTATUS(status));
- }
- else if (WIFSIGNALED(status))
- {
- printf("Child terminated by signal %d\n", WTERMSIG(status));
- }
- }
-}
-
-void handle_signal(int sig)
-{
- if (sig == SIGINT)
- {
- printf("\nCaught signal %d (SIGINT). Type 'exit' to quit the shell.\n", sig);
- print_prompt();
- fflush(stdout);
- }
-}
-
-int main()
-{
- char input[MAX_INPUT_SIZE];
- char *args[MAX_ARG_SIZE];
-
- signal(SIGINT, handle_signal);
-
- while (1)
- {
- print_prompt();
- read_input(input);
- if (strcmp(input, "exit") == 0)
- break;
- parse_input(input, args);
- if (args[0] != NULL)
- execute_command(args);
- }
-
- return 0;
-}
diff --git a/Userspace/apps/test/cross_test/Makefile b/Userspace/apps/test/cross_test/Makefile
index 770a06b2..1d9259dd 100644
--- a/Userspace/apps/test/cross_test/Makefile
+++ b/Userspace/apps/test/cross_test/Makefile
@@ -13,7 +13,7 @@ ifneq ($(shell uname -s), Linux)
endif
$(info Compiling $(FILENAME)linux)
gcc linux_glibc.c $(CFLAGS) -o $(FILENAME)linux
- cp $(FILENAME)linux $(WORKSPACE_DIR)/out/bin/$(FILENAME)linux
+ cp $(FILENAME)linux $(WORKSPACE_DIR)/out/sys/bin/$(FILENAME)linux
$(FILENAME)win.exe:
ifneq ($(shell uname -s), Linux)
@@ -22,7 +22,7 @@ ifneq ($(shell uname -s), Linux)
endif
$(info Compiling $(FILENAME)win)
x86_64-w64-mingw32-gcc win_mingw.c $(CFLAGS) -o $(FILENAME)win.exe
- cp $(FILENAME)win.exe $(WORKSPACE_DIR)/out/bin/$(FILENAME)win.exe
+ cp $(FILENAME)win.exe $(WORKSPACE_DIR)/out/sys/bin/$(FILENAME)win.exe
build: $(FILENAME)linux $(FILENAME)win.exe
diff --git a/Userspace/apps/test/libc_test/Makefile b/Userspace/apps/test/libc_test/Makefile
index cb74a87d..c223108d 100644
--- a/Userspace/apps/test/libc_test/Makefile
+++ b/Userspace/apps/test/libc_test/Makefile
@@ -11,7 +11,7 @@ FILENAME = $(notdir $(shell pwd))
WARNCFLAG = -Wall -Wextra
build: $(FILENAME).elf
- cp $(FILENAME).elf $(WORKSPACE_DIR)/out/bin/$(FILENAME)
+ cp $(FILENAME).elf $(WORKSPACE_DIR)/out/sys/bin/$(FILENAME)
# Use static linking
LDFLAGS += -ggdb3 -g -static -fno-pic -fno-pie -Wl,-static -Wl,-Ttext=0x00600000
diff --git a/Userspace/apps/test/utest/Makefile b/Userspace/apps/test/utest/Makefile
index 13dee6ab..dd9dce6d 100644
--- a/Userspace/apps/test/utest/Makefile
+++ b/Userspace/apps/test/utest/Makefile
@@ -11,7 +11,7 @@ FILENAME = $(notdir $(shell pwd))
WARNCFLAG = -Wall -Wextra
build: $(FILENAME).elf
- cp $(FILENAME).elf $(WORKSPACE_DIR)/out/bin/$(FILENAME)
+ cp $(FILENAME).elf $(WORKSPACE_DIR)/out/sys/bin/$(FILENAME)
# Use static linking
LDFLAGS += -static -fno-pic -fno-pie -Wl,-static
diff --git a/Userspace/apps/test/utest/userspace_test.c b/Userspace/apps/test/utest/userspace_test.c
index d215bd94..fa109f36 100644
--- a/Userspace/apps/test/utest/userspace_test.c
+++ b/Userspace/apps/test/utest/userspace_test.c
@@ -344,7 +344,7 @@ void test_file()
{
printf("- Testing file operations\n");
- FILE *test = fopen("/etc/passwd", "r");
+ FILE *test = fopen("/sys/cfg/passwd", "r");
if (test == NULL)
{
perror("fopen");
@@ -353,7 +353,7 @@ void test_file()
return;
}
- printf("/etc/passwd contents: ");
+ printf("/sys/cfg/passwd contents: ");
char ch;
while (1)
{
@@ -373,7 +373,7 @@ void test_stat()
printf("- Testing stat\n");
struct stat st;
- if (stat("/etc/passwd", &st) == -1)
+ if (stat("/sys/cfg/passwd", &st) == -1)
{
perror("stat");
fflush(stdout);
@@ -385,7 +385,7 @@ void test_stat()
printf("File mode: %o\n", st.st_mode);
printf("File inode: %ld\n", st.st_ino);
- int fd = open("/etc/passwd", O_RDONLY);
+ int fd = open("/sys/cfg/passwd", O_RDONLY);
if (fd == -1)
{
perror("open");
@@ -407,7 +407,7 @@ void test_stat()
printf("File inode: %ld\n", st.st_ino);
close(fd);
- if (lstat("/etc/passwd", &st) == -1)
+ if (lstat("/sys/cfg/passwd", &st) == -1)
{
perror("lstat");
fflush(stdout);
diff --git a/Userspace/coreutils/CMakeLists.txt b/Userspace/coreutils/CMakeLists.txt
index f9440128..860d9b28 100644
--- a/Userspace/coreutils/CMakeLists.txt
+++ b/Userspace/coreutils/CMakeLists.txt
@@ -31,7 +31,7 @@ foreach(file ${SINGLE_SOURCE})
PROGRAM_NAME="${name}"
PROGRAM_VERSION="${PROJECT_VERSION}"
)
- install(TARGETS ${name} DESTINATION bin)
+ install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_PREFIX}/sys/bin)
endforeach()
file(GLOB_RECURSE GROUP_SOURCES "src/*/*.c")
@@ -47,14 +47,14 @@ foreach(name IN LISTS GROUP_MAP_)
PROGRAM_NAME="${name}"
PROGRAM_VERSION="${PROJECT_VERSION}"
)
- install(TARGETS ${name} DESTINATION bin)
+ install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_PREFIX}/sys/bin)
endforeach()
if(UNIX AND TARGET test)
install(CODE "execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink
test
- \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/[\"
+ \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/sys/bin/[\"
)")
endif()
@@ -62,6 +62,6 @@ if(UNIX AND TARGET sh)
install(CODE "execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink
sh
- \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/fsh\"
+ \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/sys/bin/fsh\"
)")
endif()
diff --git a/Userspace/libc/CMakeLists.txt b/Userspace/libc/CMakeLists.txt
index d5c11111..5d161b90 100644
--- a/Userspace/libc/CMakeLists.txt
+++ b/Userspace/libc/CMakeLists.txt
@@ -7,8 +7,8 @@ if(NOT DEFINED ENV{WORKSPACE_DIR})
message(STATUS "Compiling standalone")
if(NOT DEFINED ENV{CMAKE_INSTALL_PREFIX})
- set(CMAKE_INSTALL_PREFIX "/usr")
- message(STATUS "Using default install prefix: /usr")
+ set(CMAKE_INSTALL_PREFIX "/")
+ message(STATUS "Using default install prefix: /")
else()
message(STATUS "Using custom install prefix: $ENV{CMAKE_INSTALL_PREFIX}")
endif()
@@ -18,8 +18,8 @@ else()
message(STATUS "Compiling within workspace")
if(NOT DEFINED ENV{CMAKE_INSTALL_PREFIX})
- set(CMAKE_INSTALL_PREFIX "$ENV{WORKSPACE_DIR}/out")
- message(STATUS "Using default install prefix: $ENV{WORKSPACE_DIR}/out")
+ set(CMAKE_INSTALL_PREFIX "$ENV{WORKSPACE_DIR}/out/sys")
+ message(STATUS "Using default install prefix: $ENV{WORKSPACE_DIR}/out/sys")
else()
message(STATUS "Using custom install prefix: $ENV{CMAKE_INSTALL_PREFIX}")
endif()
@@ -105,18 +105,24 @@ add_subdirectory(interpreter)
add_subdirectory(src)
add_subdirectory(libs)
+if(DEFINED ENV{WORKSPACE_DIR})
+ set(INC_OUTPUT "inc")
+else()
+ set(INC_OUTPUT "include")
+endif()
+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
- DESTINATION include
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/${INC_OUTPUT}
FILES_MATCHING
PATTERN "*")
install(DIRECTORY ${ABIS_GENERIC}/
- DESTINATION ${CMAKE_INSTALL_PREFIX}/include/
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/${INC_OUTPUT}
FILES_MATCHING
PATTERN "*")
install(DIRECTORY ${ABIS_PATH}/
- DESTINATION ${CMAKE_INSTALL_PREFIX}/include/
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/${INC_OUTPUT}
FILES_MATCHING
PATTERN "*")
diff --git a/Userspace/libc/include/pwd.h b/Userspace/libc/include/pwd.h
index 07d2df90..964dc7fc 100644
--- a/Userspace/libc/include/pwd.h
+++ b/Userspace/libc/include/pwd.h
@@ -26,7 +26,7 @@ extern "C"
#include
/**
- * /etc/passwd
+ * /sys/cfg/passwd
* name:passwd:uid:gid:gecos:dir:shell
*
* Example
diff --git a/Userspace/libc/src/std/pwd.c b/Userspace/libc/src/std/pwd.c
index d92caa01..6d304600 100644
--- a/Userspace/libc/src/std/pwd.c
+++ b/Userspace/libc/src/std/pwd.c
@@ -33,7 +33,7 @@ export struct passwd *getpwent(void)
if (pwfile == NULL)
{
- pwfile = fopen("/etc/passwd", "r");
+ pwfile = fopen("/sys/cfg/passwd", "r"); /* FIXME: this path should be OS dependent */
if (pwfile == NULL)
return NULL;
}
diff --git a/Userspace/libc/src/std/unistd.c b/Userspace/libc/src/std/unistd.c
index 0fed008b..09cb4784 100644
--- a/Userspace/libc/src/std/unistd.c
+++ b/Userspace/libc/src/std/unistd.c
@@ -209,7 +209,7 @@ export int gethostname(char *name, size_t namelen)
return 0;
}
- int fd = open("/etc/hostname", O_RDONLY);
+ int fd = open("/sys/cfg/hostname", O_RDONLY); /* FIXME: this path should be OS dependent */
if (fd == -1)
return -1;
diff --git a/Userspace/libs/Makefile b/Userspace/libs/Makefile
index 80586046..f300d035 100644
--- a/Userspace/libs/Makefile
+++ b/Userspace/libs/Makefile
@@ -1,51 +1,16 @@
MAKE_TARGETS := build clean
DIRECTORIES := $(sort $(filter-out ./include/,$(dir $(wildcard ./*/))))
-FFI_VERSION = 3.4.4
-XML2_VERSION = 2.12.10
-EXPAT_VERSION = 2.7.0
-
-FFI_ARCHIVE = /tmp/libffi-$(FFI_VERSION).tar.gz
-XML2_ARCHIVE = /tmp/libxml2-$(XML2_VERSION).tar.xz
-EXPAT_ARCHIVE = /tmp/expat-$(EXPAT_VERSION).tar.gz
-
.PHONY: $(MAKE_TARGETS) $(DIRECTORIES) prepare
build: copy_includes $(DIRECTORIES)
clean: $(DIRECTORIES)
copy_includes:
- cp -a $(CURDIR)/include/. $(WORKSPACE_DIR)/out/include
+ cp -a $(CURDIR)/include/. $(WORKSPACE_DIR)/out/usr/include
prepare:
- rm -rf ffi/libffi-src xml2/libxml2-src expat/libexpat-src
-
- mkdir -p ffi/libffi-src
- if [ ! -f $(FFI_ARCHIVE) ]; then \
- wget https://github.com/libffi/libffi/releases/download/v$(FFI_VERSION)/libffi-$(FFI_VERSION).tar.gz -O $(FFI_ARCHIVE); \
- fi
- cd ffi && \
- tar xf $(FFI_ARCHIVE) && \
- cp -r libffi-$(FFI_VERSION)/* libffi-src/ && \
- rm -rf libffi-$(FFI_VERSION)
-
- mkdir -p xml2/libxml2-src
- if [ ! -f $(XML2_ARCHIVE) ]; then \
- wget https://download.gnome.org/sources/libxml2/2.12/libxml2-$(XML2_VERSION).tar.xz -O $(XML2_ARCHIVE); \
- fi
- cd xml2 && \
- tar xf $(XML2_ARCHIVE) && \
- cp -r libxml2-$(XML2_VERSION)/* libxml2-src/ && \
- rm -rf libxml2-$(XML2_VERSION)
-
- mkdir -p expat/libexpat-src
- if [ ! -f $(EXPAT_ARCHIVE) ]; then \
- wget https://github.com/libexpat/libexpat/releases/download/R_2_7_0/expat-$(EXPAT_VERSION).tar.gz -O $(EXPAT_ARCHIVE); \
- fi
- cd expat && \
- tar xf $(EXPAT_ARCHIVE) && \
- cp -r expat-$(EXPAT_VERSION)/* libexpat-src/ && \
- rm -rf expat-$(EXPAT_VERSION)
+ $(info Nothing to prepare)
$(DIRECTORIES):
$(MAKE) -C $@ $(MAKECMDGOALS)
diff --git a/Userspace/libs/example/Makefile b/Userspace/libs/example/Makefile
index 711bb9df..83354ce4 100644
--- a/Userspace/libs/example/Makefile
+++ b/Userspace/libs/example/Makefile
@@ -4,7 +4,7 @@ default:
DYNAMIC_NAME := lib$(notdir $(shell pwd)).so
STATIC_NAME := lib$(notdir $(shell pwd)).a
-OUTPUT_DIR=$(WORKSPACE_DIR)/out/lib/
+OUTPUT_DIR=$(WORKSPACE_DIR)/out/usr/lib/
SYSROOT = --sysroot=$(WORKSPACE_DIR)/out/
S_SOURCES = $(shell find ./ -type f -name '*.S')
@@ -12,7 +12,7 @@ C_SOURCES = $(shell find ./ -type f -name '*.c')
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
OBJ = ${S_SOURCES:.S=.o} ${C_SOURCES:.c=.o} ${CXX_SOURCES:.cpp=.o}
-CFLAGS := -fvisibility=hidden -fPIC -I../include -I$(WORKSPACE_DIR)/out/include -DLIBC_GIT_COMMIT='"$(shell git rev-parse HEAD)"'
+CFLAGS := -fvisibility=hidden -fPIC -I../include -I$(WORKSPACE_DIR)/out/sys/inc -DLIBC_GIT_COMMIT='"$(shell git rev-parse HEAD)"'
ifeq ($(DEBUG), 1)
CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always
diff --git a/Userspace/libs/expat/.gitignore b/Userspace/libs/expat/.gitignore
deleted file mode 100644
index 7cb7f41e..00000000
--- a/Userspace/libs/expat/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-libexpat-src
diff --git a/Userspace/libs/expat/Makefile b/Userspace/libs/expat/Makefile
deleted file mode 100644
index 08388392..00000000
--- a/Userspace/libs/expat/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-build:
- mkdir -p $(WORKSPACE_DIR)/cache/expat
- if [ ! -f "$(WORKSPACE_DIR)/cache/expat/.configured" ]; then \
- cd $(WORKSPACE_DIR)/cache/expat && \
- $(CURDIR)/libexpat-src/configure \
- --host=x86_64-none-elf \
- --prefix=/usr \
- --libdir=/usr/lib \
- --enable-static \
- --disable-shared \
- --without-docbook \
- --without-xmlwf \
- --without-examples \
- --without-tests \
- CC="$(CC)" \
- CXX="$(CXX)" \
- AR="$(AR)" \
- CFLAGS="-nostdinc -I$(WORKSPACE_DIR)/out/include" \
- CXXFLAGS="-nostdinc++ -I$(WORKSPACE_DIR)/out/include" \
- LDFLAGS="-nostdlib -L$(WORKSPACE_DIR)/out/lib -lc" && \
- touch .configured; \
- fi
- $(MAKE) -C $(WORKSPACE_DIR)/cache/expat -j$(shell nproc)
- $(MAKE) -C $(WORKSPACE_DIR)/cache/expat install DESTDIR=$(WORKSPACE_DIR)/out
- cd $(WORKSPACE_DIR)/cache/expat && \
- ./libtool --finish $(WORKSPACE_DIR)/out/usr/lib
-
-clean:
- $(info Nothing to clean)
diff --git a/Userspace/libs/ffi/.gitignore b/Userspace/libs/ffi/.gitignore
deleted file mode 100644
index 3c925a9b..00000000
--- a/Userspace/libs/ffi/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-libffi-src
diff --git a/Userspace/libs/ffi/Makefile b/Userspace/libs/ffi/Makefile
deleted file mode 100644
index 2ba54ef0..00000000
--- a/Userspace/libs/ffi/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-build:
- mkdir -p $(WORKSPACE_DIR)/cache/ffi
- if [ ! -f "$(WORKSPACE_DIR)/cache/ffi/.configured" ]; then \
- cd $(WORKSPACE_DIR)/cache/ffi && \
- $(CURDIR)/libffi-src/configure \
- --host=x86_64-none-elf \
- --prefix=/usr \
- --libdir=/usr/lib \
- --enable-static \
- --disable-shared \
- --disable-docs \
- --disable-multi-os-directory \
- CC="$(CC)" \
- CXX="$(CXX)" \
- AR="$(AR)" \
- CFLAGS="-nostdinc -I$(WORKSPACE_DIR)/out/include" \
- CXXFLAGS="-nostdinc++ -I$(WORKSPACE_DIR)/out/include" \
- LDFLAGS="-nostdlib -L$(WORKSPACE_DIR)/out/lib -lc" && \
- touch .configured; \
- fi
- $(MAKE) -C $(WORKSPACE_DIR)/cache/ffi -j$(shell nproc)
- $(MAKE) -C $(WORKSPACE_DIR)/cache/ffi install DESTDIR=$(WORKSPACE_DIR)/out
- cd $(WORKSPACE_DIR)/cache/ffi && \
- ./libtool --finish $(WORKSPACE_DIR)/out/usr/lib
-
-clean:
- $(info Nothing to clean)
diff --git a/Userspace/libs/gcc/Makefile b/Userspace/libs/gcc/Makefile
index 878ec9c0..5db5cf3c 100644
--- a/Userspace/libs/gcc/Makefile
+++ b/Userspace/libs/gcc/Makefile
@@ -1,6 +1,6 @@
NAME=gcc
OBJECT_NAME=lib$(NAME).a
-OUTPUT_DIR=$(WORKSPACE_DIR)/out/lib/
+OUTPUT_DIR=$(WORKSPACE_DIR)/out/sys/lib/
CRTBEGIN_PATH = $(shell $(CC) -print-file-name=libgcc.a)
build: $(OBJECT_NAME)
diff --git a/Userspace/libs/xml2/.gitignore b/Userspace/libs/xml2/.gitignore
deleted file mode 100644
index 875a3f18..00000000
--- a/Userspace/libs/xml2/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-libxml2-src
-
diff --git a/Userspace/libs/xml2/Makefile b/Userspace/libs/xml2/Makefile
deleted file mode 100644
index 62cee08e..00000000
--- a/Userspace/libs/xml2/Makefile
+++ /dev/null
@@ -1,47 +0,0 @@
-build:
- mkdir -p $(WORKSPACE_DIR)/cache/xml2
- if [ ! -f "$(WORKSPACE_DIR)/cache/xml2/.configured" ]; then \
- cd $(WORKSPACE_DIR)/cache/xml2 && \
- $(CURDIR)/libxml2-src/configure \
- --host=x86_64-none-elf \
- --prefix=/usr \
- --libdir=/usr/lib \
- --enable-static \
- --disable-shared \
- --without-python \
- --without-debug \
- --without-docbook \
- --without-ftp \
- --without-http \
- --without-html \
- --without-legacy \
- --without-pattern \
- --without-push \
- --without-regexps \
- --without-sax1 \
- --without-schemas \
- --without-schematron \
- --without-threads \
- --without-valid \
- --without-xinclude \
- --without-xpath \
- --without-xptr \
- --without-modules \
- --without-zlib \
- --without-lzma \
- --without-coverage \
- CC="$(CC)" \
- CXX="$(CXX)" \
- AR="$(AR)" \
- CFLAGS="-nostdinc -I$(WORKSPACE_DIR)/out/include" \
- CXXFLAGS="-nostdinc++ -I$(WORKSPACE_DIR)/out/include" \
- LDFLAGS="-nostdlib -L$(WORKSPACE_DIR)/out/lib -lc" && \
- touch .configured; \
- fi
- $(MAKE) -C $(WORKSPACE_DIR)/cache/xml2 -j$(shell nproc)
- $(MAKE) -C $(WORKSPACE_DIR)/cache/xml2 install DESTDIR=$(WORKSPACE_DIR)/out
- cd $(WORKSPACE_DIR)/cache/xml2 && \
- ./libtool --finish $(WORKSPACE_DIR)/out/usr/lib
-
-clean:
- $(info Nothing to clean)
diff --git a/rootfs/bin/.gitkeep b/rootfs/bin/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/rootfs/home/.gitkeep b/rootfs/home/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/rootfs/include/.gitkeep b/rootfs/include/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/rootfs/lib/.gitkeep b/rootfs/lib/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/rootfs/root/.gitkeep b/rootfs/root/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/rootfs/etc/audio/devices.cfg b/rootfs/sys/cfg/audio/devices.cfg
similarity index 100%
rename from rootfs/etc/audio/devices.cfg
rename to rootfs/sys/cfg/audio/devices.cfg
diff --git a/rootfs/etc/cross/linux b/rootfs/sys/cfg/cross/linux
similarity index 100%
rename from rootfs/etc/cross/linux
rename to rootfs/sys/cfg/cross/linux
diff --git a/rootfs/etc/group b/rootfs/sys/cfg/group
similarity index 100%
rename from rootfs/etc/group
rename to rootfs/sys/cfg/group
diff --git a/rootfs/etc/hostname b/rootfs/sys/cfg/hostname
similarity index 100%
rename from rootfs/etc/hostname
rename to rootfs/sys/cfg/hostname
diff --git a/rootfs/etc/hosts b/rootfs/sys/cfg/hosts
similarity index 100%
rename from rootfs/etc/hosts
rename to rootfs/sys/cfg/hosts
diff --git a/rootfs/etc/ntp b/rootfs/sys/cfg/ntp
similarity index 100%
rename from rootfs/etc/ntp
rename to rootfs/sys/cfg/ntp
diff --git a/rootfs/etc/passwd b/rootfs/sys/cfg/passwd
similarity index 100%
rename from rootfs/etc/passwd
rename to rootfs/sys/cfg/passwd
diff --git a/rootfs/etc/term b/rootfs/sys/cfg/term
similarity index 100%
rename from rootfs/etc/term
rename to rootfs/sys/cfg/term
diff --git a/rootfs/usr/bin/.gitkeep b/rootfs/usr/bin/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/rootfs/usr/include/.gitkeep b/rootfs/usr/include/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/rootfs/usr/lib/drivers/.gitkeep b/rootfs/usr/lib/drivers/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/rootfs/usr/share/.gitkeep b/rootfs/usr/share/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/rootfs/var/.gitkeep b/rootfs/var/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/rootfs/var/panic/.gitkeep b/rootfs/var/panic/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/tools/Makefile b/tools/Makefile
index d16075e4..81081c20 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -86,7 +86,6 @@ __patch_cross_gcc: __clone_gcc
$(info > TOOLS: Running autoconf for gcc/libstdc++-v3)
cd $(GCC_CLONE_PATH)/libstdc++-v3 && autoconf
-
__patch_cross_qemu: __clone_qemu
$(info > TOOLS: Patching qemu)
cd $(QEMU_CLONE_PATH) && git apply $(CURDIR)/qemu.patch
@@ -166,6 +165,10 @@ __do_gcc:
--enable-static-link \
--disable-tls \
--disable-pie \
+ --enable-libada \
+ --enable-libgm2 \
+ --enable-libssp \
+ --enable-libstdcxx \
&& \
$(MAKE) --quiet all-gcc -j$(shell nproc) && \
$(MAKE) --quiet all-target-libgcc -j$(shell nproc) && \
diff --git a/tools/binutils-gdb.patch b/tools/binutils-gdb.patch
index 4d1d5d86..d0fe856e 100644
--- a/tools/binutils-gdb.patch
+++ b/tools/binutils-gdb.patch
@@ -44,7 +44,7 @@ index 6553aac1..39008568 100644
bpf-*-*)
echo "*** Configuration $targ is not fully supported." >&2
diff --git a/binutils/readelf.c b/binutils/readelf.c
-index 5d1cf9c3..2606967f 100644
+index 5d1cf9c3..f09b448f 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -20909,6 +20909,30 @@ get_gnu_elf_note_type (unsigned e_type)
@@ -144,8 +144,8 @@ index 5d1cf9c3..2606967f 100644
+
+ case NT_FNX_ARCH:
+ {
-+ /* TODO */
-+ printf (_(" Unimplemented NT_FNX_ARCH note\n"));
++ /* TODO */
++ printf (_(" Unimplemented NT_FNX_ARCH note\n"));
+ }
+ break;
+
@@ -288,10 +288,18 @@ index 6a9833e5..bf4c134d 100644
eelf_x86_64_sol2.c \
ehppa64linux.c \
diff --git a/ld/Makefile.in b/ld/Makefile.in
-index 8639e782..24738803 100644
+index 8639e782..f82ec216 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
-@@ -676,6 +676,7 @@ ALL_EMULATION_SOURCES = \
+@@ -543,6 +543,7 @@ pdfdir = @pdfdir@
+ prefix = @prefix@
+ program_transform_name = @program_transform_name@
+ psdir = @psdir@
++runstatedir = @runstatedir@
+ sbindir = @sbindir@
+ sharedstatedir = @sharedstatedir@
+ srcdir = @srcdir@
+@@ -676,6 +677,7 @@ ALL_EMULATION_SOURCES = \
earcv2elfx.c \
earm_wince_pe.c \
earmelf.c \
@@ -299,7 +307,7 @@ index 8639e782..24738803 100644
earmelf_fbsd.c \
earmelf_fuchsia.c \
earmelf_haiku.c \
-@@ -790,6 +791,7 @@ ALL_EMULATION_SOURCES = \
+@@ -790,6 +792,7 @@ ALL_EMULATION_SOURCES = \
eelf_i386.c \
eelf_i386_be.c \
eelf_i386_fbsd.c \
@@ -307,7 +315,7 @@ index 8639e782..24738803 100644
eelf_i386_haiku.c \
eelf_i386_ldso.c \
eelf_i386_sol2.c \
-@@ -893,6 +895,7 @@ ALL_64_EMULATION_SOURCES = \
+@@ -893,6 +896,7 @@ ALL_64_EMULATION_SOURCES = \
eaarch64elf32.c \
eaarch64elf32b.c \
eaarch64elfb.c \
@@ -315,7 +323,7 @@ index 8639e782..24738803 100644
eaarch64fbsd.c \
eaarch64fbsdb.c \
eaarch64haiku.c \
-@@ -973,6 +976,7 @@ ALL_64_EMULATION_SOURCES = \
+@@ -973,6 +977,7 @@ ALL_64_EMULATION_SOURCES = \
eelf_x86_64.c \
eelf_x86_64_cloudabi.c \
eelf_x86_64_fbsd.c \
@@ -323,7 +331,7 @@ index 8639e782..24738803 100644
eelf_x86_64_haiku.c \
eelf_x86_64_sol2.c \
ehppa64linux.c \
-@@ -1279,6 +1283,7 @@ distclean-compile:
+@@ -1279,6 +1284,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64elfb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64fbsd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64fbsdb.Po@am__quote@
@@ -331,7 +339,7 @@ index 8639e782..24738803 100644
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64haiku.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64linux.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64linux32.Po@am__quote@
-@@ -1301,6 +1306,7 @@ distclean-compile:
+@@ -1301,6 +1307,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earm_wince_pe.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_fbsd.Po@am__quote@
@@ -339,7 +347,7 @@ index 8639e782..24738803 100644
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_fuchsia.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_haiku.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_linux.Po@am__quote@
-@@ -1480,6 +1486,7 @@ distclean-compile:
+@@ -1480,6 +1487,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_be.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_fbsd.Po@am__quote@
@@ -347,7 +355,7 @@ index 8639e782..24738803 100644
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_haiku.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_ldso.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_sol2.Po@am__quote@
-@@ -1490,6 +1497,7 @@ distclean-compile:
+@@ -1490,6 +1498,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_cloudabi.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_fbsd.Po@am__quote@
@@ -356,7 +364,7 @@ index 8639e782..24738803 100644
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_sol2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eh8300elf.Po@am__quote@
diff --git a/ld/configure.tgt b/ld/configure.tgt
-index f937f78b..3aa8c738 100644
+index f937f78b..57858cc8 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -92,6 +92,9 @@ aarch64-*-elf | aarch64-*-rtems* | aarch64-*-genode*)
@@ -407,7 +415,7 @@ index f937f78b..3aa8c738 100644
;;
+*-*-fennix*)
-+ NATIVE_LIB_DIRS='/lib /usr/lib'
++ NATIVE_LIB_DIRS='/sys/lib /usr/lib'
+ ;;
+
*-*-freebsd*)
diff --git a/tools/gcc.patch b/tools/gcc.patch
index fd10cb80..3a312da6 100644
--- a/tools/gcc.patch
+++ b/tools/gcc.patch
@@ -21,25 +21,26 @@ index 38f3d037a..e15a98ae9 100755
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
diff --git a/gcc/config.gcc b/gcc/config.gcc
-index 95c91ee02..cbcaac06b 100644
+index 95c91ee02..c887980e0 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
-@@ -825,6 +825,14 @@ case ${target} in
+@@ -825,6 +825,15 @@ case ${target} in
rust_target_objs="${rust_target_objs} dragonfly-rust.o"
target_has_targetrustm=yes
;;
+*-*-fennix*)
++ extra_options="$extra_options gnu-user.opt"
+ tmake_file="t-fennix "
+ gas=yes
+ gnu_ld=yes
+ default_use_cxa_atexit=yes
+ use_gcc_stdint=provide
-+ native_system_header_dir=/include
++ native_system_header_dir=/usr/include
+ ;;
*-*-freebsd*)
# This is the generic ELF configuration of FreeBSD. Later
# machine-specific sections may refine and add to this
-@@ -1227,6 +1235,16 @@ aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
+@@ -1227,6 +1236,16 @@ aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
done
TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
;;
@@ -56,7 +57,7 @@ index 95c91ee02..cbcaac06b 100644
aarch64*-*-freebsd*)
tm_file="${tm_file} elfos.h ${fbsd_tm_file}"
tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-freebsd.h"
-@@ -1358,6 +1376,30 @@ arm-wrs-vxworks7*)
+@@ -1358,6 +1377,30 @@ arm-wrs-vxworks7*)
target_cpu_cname="generic-armv7-a"
need_64bit_hwint=yes
;;
@@ -87,7 +88,7 @@ index 95c91ee02..cbcaac06b 100644
arm*-*-freebsd*) # ARM FreeBSD EABI
tm_file="elfos.h ${fbsd_tm_file} arm/elf.h"
case $target in
-@@ -1953,6 +1995,14 @@ x86_64-*-dragonfly*)
+@@ -1953,6 +1996,14 @@ x86_64-*-dragonfly*)
tm_file="${tm_file} i386/unix.h i386/att.h elfos.h dragonfly.h dragonfly-stdint.h i386/x86-64.h i386/dragonfly.h"
tmake_file="${tmake_file} i386/t-crtstuff"
;;
@@ -183,10 +184,10 @@ index 000000000..f93866693
+# .
diff --git a/gcc/config/fennix.h b/gcc/config/fennix.h
new file mode 100644
-index 000000000..4cd35f5a0
+index 000000000..136b89d25
--- /dev/null
+++ b/gcc/config/fennix.h
-@@ -0,0 +1,77 @@
+@@ -0,0 +1,83 @@
+/* Base configuration file for all Fennix targets.
+ Copyright (C) 2016-2024 Free Software Foundation, Inc.
+
@@ -235,8 +236,14 @@ index 000000000..4cd35f5a0
+ } \
+ %{static:crtend.o%s}"
+
-+#undef STANDARD_STARTFILE_PREFIX
-+#define STANDARD_STARTFILE_PREFIX "/lib/"
++// #undef STANDARD_STARTFILE_PREFIX
++// #define STANDARD_STARTFILE_PREFIX "/lib/"
++
++#undef STANDARD_STARTFILE_PREFIX_1
++#define STANDARD_STARTFILE_PREFIX_1 "/sys/lib/"
++
++#undef STANDARD_STARTFILE_PREFIX_2
++#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
+
+#undef LINK_SPEC
+#define LINK_SPEC \
@@ -249,7 +256,7 @@ index 000000000..4cd35f5a0
+ } \
+ %{!static: \
+ %{!dynamic-linker: \
-+ -dynamic-linker=/lib/ld.so \
++ -dynamic-linker=/sys/lib/ld.so \
+ } \
+ } \
+ -z max-page-size=4096"
@@ -342,220 +349,198 @@ index e75a7af64..10d8017b0 100644
tmake_file="${tmake_file} i386/t-freebsd i386/t-crtstuff"
md_unwind_header=i386/freebsd-unwind.h
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
-index 21abaeb07..8dcc519be 100755
+index 21abaeb07..fdafb5656 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
-@@ -38122,6 +38122,3224 @@ done
+@@ -893,6 +893,7 @@ infodir
+ docdir
+ oldincludedir
+ includedir
++runstatedir
+ localstatedir
+ sharedstatedir
+ sysconfdir
+@@ -1027,6 +1028,7 @@ datadir='${datarootdir}'
+ sysconfdir='${prefix}/etc'
+ sharedstatedir='${prefix}/com'
+ localstatedir='${prefix}/var'
++runstatedir='${localstatedir}/run'
+ includedir='${prefix}/include'
+ oldincludedir='/usr/include'
+ docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+@@ -1279,6 +1281,15 @@ do
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
- ;;
++ -runstatedir | --runstatedir | --runstatedi | --runstated \
++ | --runstate | --runstat | --runsta | --runst | --runs \
++ | --run | --ru | --r)
++ ac_prev=runstatedir ;;
++ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
++ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
++ | --run=* | --ru=* | --r=*)
++ runstatedir=$ac_optarg ;;
++
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+@@ -1416,7 +1427,7 @@ fi
+ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
+ datadir sysconfdir sharedstatedir localstatedir includedir \
+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+- libdir localedir mandir
++ libdir localedir mandir runstatedir
+ do
+ eval ac_val=\$$ac_var
+ # Remove trailing slashes.
+@@ -1569,6 +1580,7 @@ Fine tuning of the installation directories:
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
++ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+@@ -5080,7 +5092,7 @@ else
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
++#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+@@ -5126,7 +5138,7 @@ else
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
++#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+@@ -5150,7 +5162,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
++#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+@@ -5195,7 +5207,7 @@ else
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
++#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+@@ -5219,7 +5231,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
++#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+@@ -12280,7 +12292,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 12283 "configure"
++#line 12295 "configure"
+ #include "confdefs.h"
-+ *-fennix*)
+ #if HAVE_DLFCN_H
+@@ -12386,7 +12398,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 12389 "configure"
++#line 12401 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -16182,7 +16194,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
+ # Fake what AC_TRY_COMPILE does.
+
+ cat > conftest.$ac_ext << EOF
+-#line 16185 "configure"
++#line 16197 "configure"
+ int main()
+ {
+ typedef bool atomic_type;
+@@ -16217,7 +16229,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
+ rm -f conftest*
+
+ cat > conftest.$ac_ext << EOF
+-#line 16220 "configure"
++#line 16232 "configure"
+ int main()
+ {
+ typedef short atomic_type;
+@@ -16252,7 +16264,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
+ rm -f conftest*
+
+ cat > conftest.$ac_ext << EOF
+-#line 16255 "configure"
++#line 16267 "configure"
+ int main()
+ {
+ // NB: _Atomic_word not necessarily int.
+@@ -16288,7 +16300,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
+ rm -f conftest*
+
+ cat > conftest.$ac_ext << EOF
+-#line 16291 "configure"
++#line 16303 "configure"
+ int main()
+ {
+ typedef long long atomic_type;
+@@ -16444,7 +16456,7 @@ $as_echo "mutex" >&6; }
+ # unnecessary for this test.
+
+ cat > conftest.$ac_ext << EOF
+-#line 16447 "configure"
++#line 16459 "configure"
+ int main()
+ {
+ _Decimal32 d1;
+@@ -16486,7 +16498,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+ # unnecessary for this test.
+
+ cat > conftest.$ac_ext << EOF
+-#line 16489 "configure"
++#line 16501 "configure"
+ template
+ struct same
+ { typedef T2 type; };
+@@ -35067,24 +35079,3268 @@ done
+
+ CXXFLAGS="$ac_save_CXXFLAGS"
+
+- $as_echo "#define _GLIBCXX_USE_DEV_RANDOM 1" >>confdefs.h
++ $as_echo "#define _GLIBCXX_USE_DEV_RANDOM 1" >>confdefs.h
+
-+ # All these tests are for C++; save the language and the compiler flags.
-+ # The CXXFLAGS thing is suspicious, but based on similar bits previously
-+ # found in GLIBCXX_CONFIGURE.
++ $as_echo "#define _GLIBCXX_USE_RANDOM_TR1 1" >>confdefs.h
+
-+ ac_ext=cpp
-+ac_cpp='$CXXCPP $CPPFLAGS'
-+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-+
-+ ac_test_CXXFLAGS="${CXXFLAGS+set}"
-+ ac_save_CXXFLAGS="$CXXFLAGS"
-+
-+ # Check for -ffunction-sections -fdata-sections
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for g++ that supports -ffunction-sections -fdata-sections" >&5
-+$as_echo_n "checking for g++ that supports -ffunction-sections -fdata-sections... " >&6; }
-+ CXXFLAGS='-g -Werror -ffunction-sections -fdata-sections'
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h. */
-+int foo; void bar() { };
-+int
-+main ()
-+{
-+
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+if ac_fn_cxx_try_compile "$LINENO"; then :
-+ ac_fdsections=yes
-+else
-+ ac_fdsections=no
-+fi
-+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-+ if test "$ac_test_CXXFLAGS" = set; then
-+ CXXFLAGS="$ac_save_CXXFLAGS"
-+ else
-+ # this is the suspicious part
-+ CXXFLAGS=''
-+ fi
-+ if test x"$ac_fdsections" = x"yes"; then
-+ SECTION_FLAGS='-ffunction-sections -fdata-sections'
-+ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_fdsections" >&5
-+$as_echo "$ac_fdsections" >&6; }
-+
-+ ac_ext=c
-+ac_cpp='$CPP $CPPFLAGS'
-+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-+ac_compiler_gnu=$ac_cv_c_compiler_gnu
++ # We don't yet support AIX's TLS ABI.
++ #GCC_CHECK_TLS
+
+
++ $as_echo "#define HAVE_USELOCALE 1" >>confdefs.h
+
++ ;;
+
-+ # If we're not using GNU ld, then there's no point in even trying these
-+ # tests. Check for that first. We should have already tested for gld
-+ # by now (in libtool), but require it now just to be safe...
-+ test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
-+ test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
-+
-+
-+
-+ # The name set by libtool depends on the version of libtool. Shame on us
-+ # for depending on an impl detail, but c'est la vie. Older versions used
-+ # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
-+ # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
-+ # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
-+ # set (hence we're using an older libtool), then set it.
-+ if test x${with_gnu_ld+set} != xset; then
-+ if test x${ac_cv_prog_gnu_ld+set} != xset; then
-+ # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
-+ with_gnu_ld=no
-+ else
-+ with_gnu_ld=$ac_cv_prog_gnu_ld
-+ fi
-+ fi
-+
-+ # Start by getting the version number. I think the libtool test already
-+ # does some of this, but throws away the result.
-+ glibcxx_ld_is_gold=no
-+ glibcxx_ld_is_mold=no
-+ if test x"$with_gnu_ld" = x"yes"; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
-+$as_echo_n "checking for ld version... " >&6; }
-+
-+ if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
-+ glibcxx_ld_is_gold=yes
-+ elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
-+ glibcxx_ld_is_mold=yes
-+ fi
-+ ldver=`$LD --version 2>/dev/null |
-+ sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
-+
-+ glibcxx_gnu_ld_version=`echo $ldver | \
-+ $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_gnu_ld_version" >&5
-+$as_echo "$glibcxx_gnu_ld_version" >&6; }
-+ fi
-+
-+ # Set --gc-sections.
-+ glibcxx_have_gc_sections=no
-+ if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
-+ if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
-+ glibcxx_have_gc_sections=yes
-+ fi
-+ else
-+ glibcxx_gcsections_min_ld=21602
-+ if test x"$with_gnu_ld" = x"yes" &&
-+ test $glibcxx_gnu_ld_version -gt $glibcxx_gcsections_min_ld ; then
-+ glibcxx_have_gc_sections=yes
-+ fi
-+ fi
-+ if test "$glibcxx_have_gc_sections" = "yes"; then
-+ # Sufficiently young GNU ld it is! Joy and bunny rabbits!
-+ # NB: This flag only works reliably after 2.16.1. Configure tests
-+ # for this are difficult, so hard wire a value that should work.
-+
-+ ac_test_CFLAGS="${CFLAGS+set}"
-+ ac_save_CFLAGS="$CFLAGS"
-+ CFLAGS='-Wl,--gc-sections'
-+
-+ # Check for -Wl,--gc-sections
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld that supports -Wl,--gc-sections" >&5
-+$as_echo_n "checking for ld that supports -Wl,--gc-sections... " >&6; }
-+ if test x$gcc_no_link = xyes; then
-+ as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
-+fi
-+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h. */
-+ int one(void) { return 1; }
-+ int two(void) { return 2; }
-+
-+int
-+main ()
-+{
-+ two();
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+if ac_fn_c_try_link "$LINENO"; then :
-+ ac_gcsections=yes
-+else
-+ ac_gcsections=no
-+fi
-+rm -f core conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
-+ if test "$ac_gcsections" = "yes"; then
-+ rm -f conftest.c
-+ touch conftest.c
-+ if $CC -c conftest.c; then
-+ if $LD --gc-sections -o conftest conftest.o 2>&1 | \
-+ grep "Warning: gc-sections option ignored" > /dev/null; then
-+ ac_gcsections=no
-+ fi
-+ fi
-+ rm -f conftest.c conftest.o conftest
-+ fi
-+ if test "$ac_gcsections" = "yes"; then
-+ SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
-+ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_gcsections" >&5
-+$as_echo "$ac_gcsections" >&6; }
-+
-+ if test "$ac_test_CFLAGS" = set; then
-+ CFLAGS="$ac_save_CFLAGS"
-+ else
-+ # this is the suspicious part
-+ CFLAGS=''
-+ fi
-+ fi
-+
-+ # Set -z,relro.
-+ # Note this is only for shared objects.
-+ ac_ld_relro=no
-+ if test x"$with_gnu_ld" = x"yes"; then
-+ # cygwin and mingw uses PE, which has no ELF relro support,
-+ # multi target ld may confuse configure machinery
-+ case "$host" in
-+ *-*-cygwin*)
-+ ;;
-+ *-*-mingw*)
-+ ;;
-+ *)
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld that supports -Wl,-z,relro" >&5
-+$as_echo_n "checking for ld that supports -Wl,-z,relro... " >&6; }
-+ cxx_z_relo=`$LD -v --help 2>/dev/null | grep "z relro"`
-+ if test -n "$cxx_z_relo"; then
-+ OPT_LDFLAGS="-Wl,-z,relro"
-+ ac_ld_relro=yes
-+ fi
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ld_relro" >&5
-+$as_echo "$ac_ld_relro" >&6; }
-+ esac
-+ fi
-+
-+ # Set linker optimization flags.
-+ if test x"$with_gnu_ld" = x"yes"; then
-+ OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
-+ fi
-+
-+
-+
++ *-darwin*)
++ # Darwin versions vary, but the linker should work in a cross environment,
++ # so we just check for all the features here.
++ # Check for available headers.
+
++ # Don't call GLIBCXX_CHECK_LINKER_FEATURES, Darwin doesn't have a GNU ld
+
+ ac_test_CXXFLAGS="${CXXFLAGS+set}"
+ ac_save_CXXFLAGS="$CXXFLAGS"
@@ -3565,11 +3550,286 @@ index 21abaeb07..8dcc519be 100755
+
+ CXXFLAGS="$ac_save_CXXFLAGS"
+
-+ ;;
-+
- *-freebsd*)
- SECTION_FLAGS='-ffunction-sections -fdata-sections'
+- $as_echo "#define _GLIBCXX_USE_RANDOM_TR1 1" >>confdefs.h
++ for ac_func in uselocale
++do :
++ ac_fn_c_check_func "$LINENO" "uselocale" "ac_cv_func_uselocale"
++if test "x$ac_cv_func_uselocale" = xyes; then :
++ cat >>confdefs.h <<_ACEOF
++#define HAVE_USELOCALE 1
++_ACEOF
+
+- # We don't yet support AIX's TLS ABI.
+- #GCC_CHECK_TLS
++fi
++done
+
++ ;;
+
+- $as_echo "#define HAVE_USELOCALE 1" >>confdefs.h
++ *djgpp)
++ # GLIBCXX_CHECK_MATH_SUPPORT
++ $as_echo "#define HAVE_ISINF 1" >>confdefs.h
++
++ $as_echo "#define HAVE_ISNAN 1" >>confdefs.h
++
++ $as_echo "#define HAVE_FINITE 1" >>confdefs.h
++
++ $as_echo "#define HAVE_SINCOS 1" >>confdefs.h
++
++ $as_echo "#define HAVE_HYPOT 1" >>confdefs.h
+
+ ;;
+
+- *-darwin*)
+- # Darwin versions vary, but the linker should work in a cross environment,
+- # so we just check for all the features here.
+- # Check for available headers.
++ *-fennix*)
++
++ # All these tests are for C++; save the language and the compiler flags.
++ # The CXXFLAGS thing is suspicious, but based on similar bits previously
++ # found in GLIBCXX_CONFIGURE.
++
++ ac_ext=cpp
++ac_cpp='$CXXCPP $CPPFLAGS'
++ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
++ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
++ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
++
++ ac_test_CXXFLAGS="${CXXFLAGS+set}"
++ ac_save_CXXFLAGS="$CXXFLAGS"
++
++ # Check for -ffunction-sections -fdata-sections
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for g++ that supports -ffunction-sections -fdata-sections" >&5
++$as_echo_n "checking for g++ that supports -ffunction-sections -fdata-sections... " >&6; }
++ CXXFLAGS='-g -Werror -ffunction-sections -fdata-sections'
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++int foo; void bar() { };
++int
++main ()
++{
++
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_cxx_try_compile "$LINENO"; then :
++ ac_fdsections=yes
++else
++ ac_fdsections=no
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ if test "$ac_test_CXXFLAGS" = set; then
++ CXXFLAGS="$ac_save_CXXFLAGS"
++ else
++ # this is the suspicious part
++ CXXFLAGS=''
++ fi
++ if test x"$ac_fdsections" = x"yes"; then
++ SECTION_FLAGS='-ffunction-sections -fdata-sections'
++ fi
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_fdsections" >&5
++$as_echo "$ac_fdsections" >&6; }
++
++ ac_ext=c
++ac_cpp='$CPP $CPPFLAGS'
++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
++ac_compiler_gnu=$ac_cv_c_compiler_gnu
++
++
++
++
++ # If we're not using GNU ld, then there's no point in even trying these
++ # tests. Check for that first. We should have already tested for gld
++ # by now (in libtool), but require it now just to be safe...
++ test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
++ test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
++
++
++
++ # The name set by libtool depends on the version of libtool. Shame on us
++ # for depending on an impl detail, but c'est la vie. Older versions used
++ # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
++ # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
++ # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
++ # set (hence we're using an older libtool), then set it.
++ if test x${with_gnu_ld+set} != xset; then
++ if test x${ac_cv_prog_gnu_ld+set} != xset; then
++ # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
++ with_gnu_ld=no
++ else
++ with_gnu_ld=$ac_cv_prog_gnu_ld
++ fi
++ fi
++
++ # Start by getting the version number. I think the libtool test already
++ # does some of this, but throws away the result.
++ glibcxx_ld_is_gold=no
++ glibcxx_ld_is_mold=no
++ if test x"$with_gnu_ld" = x"yes"; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
++$as_echo_n "checking for ld version... " >&6; }
++
++ if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
++ glibcxx_ld_is_gold=yes
++ elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
++ glibcxx_ld_is_mold=yes
++ fi
++ ldver=`$LD --version 2>/dev/null |
++ sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
++
++ glibcxx_gnu_ld_version=`echo $ldver | \
++ $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_gnu_ld_version" >&5
++$as_echo "$glibcxx_gnu_ld_version" >&6; }
++ fi
++
++ # Set --gc-sections.
++ glibcxx_have_gc_sections=no
++ if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
++ if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
++ glibcxx_have_gc_sections=yes
++ fi
++ else
++ glibcxx_gcsections_min_ld=21602
++ if test x"$with_gnu_ld" = x"yes" &&
++ test $glibcxx_gnu_ld_version -gt $glibcxx_gcsections_min_ld ; then
++ glibcxx_have_gc_sections=yes
++ fi
++ fi
++ if test "$glibcxx_have_gc_sections" = "yes"; then
++ # Sufficiently young GNU ld it is! Joy and bunny rabbits!
++ # NB: This flag only works reliably after 2.16.1. Configure tests
++ # for this are difficult, so hard wire a value that should work.
++
++ ac_test_CFLAGS="${CFLAGS+set}"
++ ac_save_CFLAGS="$CFLAGS"
++ CFLAGS='-Wl,--gc-sections'
++
++ # Check for -Wl,--gc-sections
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld that supports -Wl,--gc-sections" >&5
++$as_echo_n "checking for ld that supports -Wl,--gc-sections... " >&6; }
++ if test x$gcc_no_link = xyes; then
++ as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
++fi
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++ int one(void) { return 1; }
++ int two(void) { return 2; }
++
++int
++main ()
++{
++ two();
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_link "$LINENO"; then :
++ ac_gcsections=yes
++else
++ ac_gcsections=no
++fi
++rm -f core conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++ if test "$ac_gcsections" = "yes"; then
++ rm -f conftest.c
++ touch conftest.c
++ if $CC -c conftest.c; then
++ if $LD --gc-sections -o conftest conftest.o 2>&1 | \
++ grep "Warning: gc-sections option ignored" > /dev/null; then
++ ac_gcsections=no
++ fi
++ fi
++ rm -f conftest.c conftest.o conftest
++ fi
++ if test "$ac_gcsections" = "yes"; then
++ SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
++ fi
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_gcsections" >&5
++$as_echo "$ac_gcsections" >&6; }
++
++ if test "$ac_test_CFLAGS" = set; then
++ CFLAGS="$ac_save_CFLAGS"
++ else
++ # this is the suspicious part
++ CFLAGS=''
++ fi
++ fi
++
++ # Set -z,relro.
++ # Note this is only for shared objects.
++ ac_ld_relro=no
++ if test x"$with_gnu_ld" = x"yes"; then
++ # cygwin and mingw uses PE, which has no ELF relro support,
++ # multi target ld may confuse configure machinery
++ case "$host" in
++ *-*-cygwin*)
++ ;;
++ *-*-mingw*)
++ ;;
++ *)
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld that supports -Wl,-z,relro" >&5
++$as_echo_n "checking for ld that supports -Wl,-z,relro... " >&6; }
++ cxx_z_relo=`$LD -v --help 2>/dev/null | grep "z relro"`
++ if test -n "$cxx_z_relo"; then
++ OPT_LDFLAGS="-Wl,-z,relro"
++ ac_ld_relro=yes
++ fi
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ld_relro" >&5
++$as_echo "$ac_ld_relro" >&6; }
++ esac
++ fi
++
++ # Set linker optimization flags.
++ if test x"$with_gnu_ld" = x"yes"; then
++ OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
++ fi
++
++
++
+
+- # Don't call GLIBCXX_CHECK_LINKER_FEATURES, Darwin doesn't have a GNU ld
+
+ ac_test_CXXFLAGS="${CXXFLAGS+set}"
+ ac_save_CXXFLAGS="$CXXFLAGS"
+@@ -38094,32 +41350,6 @@ done
+
+ CXXFLAGS="$ac_save_CXXFLAGS"
+
+-
+- for ac_func in uselocale
+-do :
+- ac_fn_c_check_func "$LINENO" "uselocale" "ac_cv_func_uselocale"
+-if test "x$ac_cv_func_uselocale" = xyes; then :
+- cat >>confdefs.h <<_ACEOF
+-#define HAVE_USELOCALE 1
+-_ACEOF
+-
+-fi
+-done
+-
+- ;;
+-
+- *djgpp)
+- # GLIBCXX_CHECK_MATH_SUPPORT
+- $as_echo "#define HAVE_ISINF 1" >>confdefs.h
+-
+- $as_echo "#define HAVE_ISNAN 1" >>confdefs.h
+-
+- $as_echo "#define HAVE_FINITE 1" >>confdefs.h
+-
+- $as_echo "#define HAVE_SINCOS 1" >>confdefs.h
+-
+- $as_echo "#define HAVE_HYPOT 1" >>confdefs.h
+-
+ ;;
+
+ *-freebsd*)
diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
index b3269cb88..de1f886b9 100644
--- a/libstdc++-v3/crossconfig.m4