diff --git a/Applications/About/Makefile b/Applications/About/Makefile index 69a58233de0..96f4fae787d 100644 --- a/Applications/About/Makefile +++ b/Applications/About/Makefile @@ -5,19 +5,18 @@ APP = About ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc -USERLAND_FLAGS = -ffreestanding -fno-stack-protector WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -FLAVOR_FLAGS = -march=i686 -m32 -fno-exceptions -fno-rtti +FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../.. -I. -I../../LibC DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND -CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(USERLAND_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) -CXX = clang -LD = ld +CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) +CXX = i686-elf-g++ +LD = i686-elf-ld AR = ar -LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections +LDFLAGS = -static all: $(APP) diff --git a/Applications/FileManager/Makefile b/Applications/FileManager/Makefile index 35f4111004d..981cfe430b8 100644 --- a/Applications/FileManager/Makefile +++ b/Applications/FileManager/Makefile @@ -6,19 +6,18 @@ APP = FileManager ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc -USERLAND_FLAGS = -ffreestanding -fno-stack-protector WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -FLAVOR_FLAGS = -march=i686 -m32 -fno-exceptions -fno-rtti +FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../.. -I. -I../../LibC DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND -CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(USERLAND_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) -CXX = clang -LD = ld +CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) +CXX = i686-elf-g++ +LD = i686-elf-ld AR = ar -LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections +LDFLAGS = -static all: $(APP) diff --git a/Applications/FontEditor/Makefile b/Applications/FontEditor/Makefile index e65e962f703..70722ae8ccc 100644 --- a/Applications/FontEditor/Makefile +++ b/Applications/FontEditor/Makefile @@ -6,7 +6,6 @@ APP = FontEditor ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc -USERLAND_FLAGS = -ffreestanding -fno-stack-protector WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough FLAVOR_FLAGS = -march=i686 -m32 -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os @@ -14,11 +13,11 @@ INCLUDE_FLAGS = -I../.. -I. -I../../LibC DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND -CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(USERLAND_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) -CXX = clang -LD = ld +CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) +CXX = i686-elf-g++ +LD = i686-elf-ld AR = ar -LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections +LDFLAGS = -static all: $(APP) diff --git a/Applications/Launcher/Makefile b/Applications/Launcher/Makefile index 3158cda285f..e8c5644c2fc 100644 --- a/Applications/Launcher/Makefile +++ b/Applications/Launcher/Makefile @@ -5,7 +5,6 @@ APP = Launcher ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc -USERLAND_FLAGS = -ffreestanding -fno-stack-protector WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough FLAVOR_FLAGS = -march=i686 -m32 -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os @@ -13,11 +12,11 @@ INCLUDE_FLAGS = -I../.. -I. -I../../LibC DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND -CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(USERLAND_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) -CXX = clang -LD = ld +CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) +CXX = i686-elf-g++ +LD = i686-elf-ld AR = ar -LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections +LDFLAGS = -static all: $(APP) diff --git a/Applications/Terminal/Makefile b/Applications/Terminal/Makefile index 9a74f229082..e14dcf55541 100644 --- a/Applications/Terminal/Makefile +++ b/Applications/Terminal/Makefile @@ -6,7 +6,6 @@ APP = Terminal ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc -USERLAND_FLAGS = -ffreestanding -fno-stack-protector WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough FLAVOR_FLAGS = -march=i686 -m32 -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os @@ -14,11 +13,11 @@ INCLUDE_FLAGS = -I../.. -I. -I../../LibC DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND -CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(USERLAND_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) -CXX = clang -LD = ld +CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) +CXX = i686-elf-g++ +LD = i686-elf-ld AR = ar -LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections +LDFLAGS = -static all: $(APP) diff --git a/Kernel/Makefile b/Kernel/Makefile index 6b04393e218..62df5aaa9ec 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -66,9 +66,9 @@ BOOTLOADER = Boot/boot.bin IMAGE = .floppy-image ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc -KERNEL_FLAGS = -ffreestanding -fno-stack-protector -fno-builtin +KERNEL_FLAGS = WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -FLAVOR_FLAGS = -mregparm=3 -march=i686 -m32 -fno-exceptions -fno-rtti +FLAVOR_FLAGS = -mregparm=3 -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I.. -I. #SUGGEST_FLAGS = -Wsuggest-final-types -Wsuggest-final-methods -Wsuggest-override #-Wsuggest-attribute=noreturn @@ -76,9 +76,9 @@ INCLUDE_FLAGS = -I.. -I. DEFINES = -DSERENITY -DKERNEL -DSANITIZE_PTRS CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(KERNEL_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(SUGGEST_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) -CXX = clang -LD = ld -LDFLAGS = -T linker.ld --strip-debug -melf_i386 --gc-sections +CXX = ~/opt/cross/bin/i686-elf-g++ +LD = ~/opt/cross/bin/i686-elf-ld +LDFLAGS = -T linker.ld all: $(KERNEL) $(IMAGE) kernel.map diff --git a/Kernel/makeall.sh b/Kernel/makeall.sh index 5dd42bc9ddf..cecd5a1aaaa 100755 --- a/Kernel/makeall.sh +++ b/Kernel/makeall.sh @@ -16,8 +16,6 @@ $make_cmd -C ../Applications/Terminal clean && \ $make_cmd -C ../Applications/Terminal && \ $make_cmd -C ../Applications/FontEditor clean && \ $make_cmd -C ../Applications/FontEditor && \ -$make_cmd -C ../Applications/Clock clean && \ -$make_cmd -C ../Applications/Clock && \ $make_cmd -C ../Applications/Launcher clean && \ $make_cmd -C ../Applications/Launcher && \ $make_cmd -C ../Applications/FileManager clean && \ diff --git a/LibC/Makefile b/LibC/Makefile index d2ff62ae1a0..a40dbe87d5c 100644 --- a/LibC/Makefile +++ b/LibC/Makefile @@ -6,14 +6,6 @@ AK_OBJS = \ ../AK/StdLibExtras.o \ ../AK/kmalloc.o -SHAREDGRAPHICS_OBJS = \ - ../SharedGraphics/Painter.o \ - ../SharedGraphics/Font.o \ - ../SharedGraphics/Rect.o \ - ../SharedGraphics/GraphicsBitmap.o \ - ../SharedGraphics/CharacterBitmap.o \ - ../SharedGraphics/Color.o - LIBC_OBJS = \ stdio.o \ unistd.o \ @@ -49,24 +41,24 @@ LIBC_OBJS = \ ASM_OBJS = setjmp.no -CPP_OBJS = $(AK_OBJS) $(WIDGETS_OBJS) $(LIBC_OBJS) $(SHAREDGRAPHICS_OBJS) +CPP_OBJS = $(AK_OBJS) $(WIDGETS_OBJS) $(LIBC_OBJS) LIBRARY = LibC.a ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc -LIBC_FLAGS = -ffreestanding -fno-stack-protector -fno-builtin +LIBC_FLAGS = WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -FLAVOR_FLAGS = -march=i686 -m32 -fno-exceptions -fno-rtti +FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I.. -I. DEFINES = -DSERENITY -DUSERLAND -DSANITIZE_PTRS CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(LIBC_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) -CXX = clang -LD = ld +CXX = i686-elf-g++ +LD = i686-elf-ld AR = ar -LDFLAGS = -T linker.ld --strip-debug -melf_i386 --gc-sections +LDFLAGS = -T linker.ld all: $(LIBRARY) diff --git a/LibC/string.cpp b/LibC/string.cpp index dbea2a5b3ba..e56c5498cb0 100644 --- a/LibC/string.cpp +++ b/LibC/string.cpp @@ -102,7 +102,7 @@ int memcmp(const void* v1, const void* v2, size_t n) return 0; } -void* memcpy(void* dest_ptr, const void* src_ptr, dword n) +void* memcpy(void* dest_ptr, const void* src_ptr, size_t n) { if (n >= 1024) return mmx_memcpy(dest_ptr, src_ptr, n); @@ -130,7 +130,7 @@ void* memcpy(void* dest_ptr, const void* src_ptr, dword n) return dest_ptr; } -void* memset(void* dest_ptr, int c, dword n) +void* memset(void* dest_ptr, int c, size_t n) { dword dest = (dword)dest_ptr; // FIXME: Support starting at an unaligned address. @@ -293,7 +293,5 @@ char* strpbrk(const char* s, const char* accept) return nullptr; } - - } diff --git a/LibC/sys/types.h b/LibC/sys/types.h index 8a80a4c340a..17e87cf1b05 100644 --- a/LibC/sys/types.h +++ b/LibC/sys/types.h @@ -17,7 +17,7 @@ typedef uint32_t uid_t; typedef uint32_t gid_t; typedef int16_t pid_t; -typedef uint32_t size_t; +typedef __SIZE_TYPE__ size_t; typedef int32_t ssize_t; typedef uint32_t ino_t; diff --git a/LibGUI/Makefile b/LibGUI/Makefile index ec8abacc1bf..629436e7f37 100644 --- a/LibGUI/Makefile +++ b/LibGUI/Makefile @@ -37,19 +37,18 @@ LIBS = ../LibC/LibC.a LIBRARY = LibGUI.a ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc -LIBC_FLAGS = -ffreestanding -fno-stack-protector -fno-ident WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -FLAVOR_FLAGS = -march=i686 -m32 -fno-exceptions -fno-rtti +FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../LibC -I.. -I. DEFINES = -DSERENITY -DUSERLAND -DSANITIZE_PTRS -DLIBGUI -CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(LIBC_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) -CXX = clang -LD = ld +CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) +CXX = i686-elf-g++ +LD = i686-elf-ld AR = ar -LDFLAGS = -T linker.ld --strip-debug -melf_i386 --gc-sections +LDFLAGS = all: $(LIBRARY) diff --git a/ReadMe.md b/ReadMe.md index 6dca05b7318..638bea43ae9 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -23,11 +23,13 @@ I always wanted to write my own operating system, but I never took it seriously. ## How do I get it to run? -I've only tested this on an Ubuntu 18.10 host with clang, so I'm not sure it works anywhere else. If you'd like to run it, here's how you'd get it to boot: +You need a cross-compiler for the i686-elf target. +I've only tested this on an Ubuntu 18.10 host with GCC, so I'm not sure it works anywhere else. + +If you'd like to run it, here's how you'd get it to boot: cd Kernel ./makeall.sh - sudo ./sync.sh ./run q # Runs in QEMU ./run # Runs in bochs diff --git a/SharedGraphics/Font.cpp b/SharedGraphics/Font.cpp index 2dd0a1b2a8e..3b68b6d6f63 100644 --- a/SharedGraphics/Font.cpp +++ b/SharedGraphics/Font.cpp @@ -120,7 +120,7 @@ bool Font::write_to_file(const String& path) header.glyph_width = m_glyph_width; header.glyph_height = m_glyph_height; header.type = 0; - memcpy(header.name, m_name.characters(), min(m_name.length(), 63u)); + memcpy(header.name, m_name.characters(), min(m_name.length(), (size_t)63)); size_t bytes_per_glyph = sizeof(unsigned) * m_glyph_height; diff --git a/Userland/Makefile b/Userland/Makefile index ee357c30d7f..e49e488b7a7 100644 --- a/Userland/Makefile +++ b/Userland/Makefile @@ -71,19 +71,19 @@ APPS = \ ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc -USERLAND_FLAGS = -ffreestanding -fno-stack-protector +USERLAND_FLAGS = WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -FLAVOR_FLAGS = -march=i686 -m32 -fno-exceptions -fno-rtti +FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I.. -I. -I../LibC DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(USERLAND_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) -CXX = clang -LD = ld +CXX = i686-elf-g++ +LD = i686-elf-ld AR = ar -LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections +LDFLAGS = -static -e _start all: $(OBJS) $(APPS) diff --git a/Userland/sh.cpp b/Userland/sh.cpp index 99c1db9ef21..9ac70d36f83 100644 --- a/Userland/sh.cpp +++ b/Userland/sh.cpp @@ -19,7 +19,7 @@ struct GlobalState { char hostname[32]; pid_t sid; uid_t uid; - termios termios; + struct termios termios; bool was_interrupted { false }; }; static GlobalState* g; @@ -159,7 +159,7 @@ static int sh_mp(int, char**) return 1; } printf("mapped file @ %p\n", data); - printf("contents: %c%c%c%c%c%c%c...\n", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); + printf("contents: %c%c%c%c%c%c%c%c...\n", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); printf("leaving it open :)\n"); return 0; diff --git a/Userland/sysctl.cpp b/Userland/sysctl.cpp index 274a55fd628..b83211ec99a 100644 --- a/Userland/sysctl.cpp +++ b/Userland/sysctl.cpp @@ -52,7 +52,7 @@ int show_all() perror("opendir"); return 1; } - char pathbuf[256]; + char pathbuf[PATH_MAX]; while (auto* de = readdir(dirp)) { if (de->d_name[0] == '.') diff --git a/WindowServer/Makefile b/WindowServer/Makefile index 5f582e6c275..86798c082c4 100644 --- a/WindowServer/Makefile +++ b/WindowServer/Makefile @@ -24,17 +24,16 @@ OBJS = $(SHAREDGRAPHICS_OBJS) $(WINDOWSERVER_OBJS) ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc -USERLAND_FLAGS = -ffreestanding -fno-stack-protector WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -FLAVOR_FLAGS = -march=i686 -m32 -fno-exceptions -fno-rtti +FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I.. -I. -I../LibC DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND -CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(USERLAND_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) -CXX = clang -LD = ld +CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) +CXX = i686-elf-g++ +LD = i686-elf-ld AR = ar LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections