diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-11-09 14:29:00 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-11-09 14:29:00 +0100 |
commit | 4914f3b8378e090d8ce54cd318dedc47783cf2eb (patch) | |
tree | 709510f0df1c338b36bbbb6962c7887449e997a9 | |
parent | ebf308d413640c2bc405ac7bf5930f2aa4e7e1d8 (diff) | |
download | serenity-4914f3b8378e090d8ce54cd318dedc47783cf2eb.zip |
Build LibC and Userland with clang as well.
-rw-r--r-- | AK/kmalloc.cpp | 30 | ||||
-rw-r--r-- | AK/kmalloc.h | 30 | ||||
-rw-r--r-- | LibC/Makefile | 6 | ||||
-rw-r--r-- | LibC/sys/cdefs.h | 3 | ||||
-rw-r--r-- | Userland/Makefile | 4 | ||||
-rw-r--r-- | Userland/false.cpp | 4 | ||||
-rw-r--r-- | Userland/id.cpp | 2 | ||||
-rw-r--r-- | Userland/true.cpp | 4 |
8 files changed, 46 insertions, 37 deletions
diff --git a/AK/kmalloc.cpp b/AK/kmalloc.cpp index 3a5200dc23..c3926b6df0 100644 --- a/AK/kmalloc.cpp +++ b/AK/kmalloc.cpp @@ -46,6 +46,36 @@ void* kmalloc_eternal(size_t size) } +void* operator new(size_t size) +{ + return kmalloc(size); +} + +void* operator new[](size_t size) +{ + return kmalloc(size); +} + +void operator delete(void* ptr) +{ + return kfree(ptr); +} + +void operator delete[](void* ptr) +{ + return kfree(ptr); +} + +void operator delete(void* ptr, size_t) +{ + return kfree(ptr); +} + +void operator delete[](void* ptr, size_t) +{ + return kfree(ptr); +} + #else extern "C" { diff --git a/AK/kmalloc.h b/AK/kmalloc.h index f62b6ea677..c28dddcae4 100644 --- a/AK/kmalloc.h +++ b/AK/kmalloc.h @@ -27,36 +27,6 @@ void* kmalloc_eternal(size_t) MALLOC_ATTR; } -inline void* operator new(size_t size) -{ - return kmalloc(size); -} - -inline void* operator new[](size_t size) -{ - return kmalloc(size); -} - -inline void operator delete(void* ptr) -{ - return kfree(ptr); -} - -inline void operator delete[](void* ptr) -{ - return kfree(ptr); -} - -inline void operator delete(void* ptr, size_t) -{ - return kfree(ptr); -} - -inline void operator delete[](void* ptr, size_t) -{ - return kfree(ptr); -} - inline void* operator new(size_t, void* p) { return p; } inline void* operator new[](size_t, void* p) { return p; } #endif diff --git a/LibC/Makefile b/LibC/Makefile index fd35ae7286..fa584a4c6f 100644 --- a/LibC/Makefile +++ b/LibC/Makefile @@ -34,14 +34,14 @@ 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 -FLAVOR_FLAGS = -fomit-frame-pointer -mregparm=3 -march=i386 -m32 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -fmerge-all-constants -fno-unroll-loops -falign-functions=1 -falign-jumps=1 -falign-loops=1 -fno-pie -fno-pic -OPTIMIZATION_FLAGS = -Os -fno-asynchronous-unwind-tables +FLAVOR_FLAGS = -fomit-frame-pointer -mregparm=3 -march=i386 -m32 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic +OPTIMIZATION_FLAGS = -Oz -fno-asynchronous-unwind-tables INCLUDE_FLAGS = -I.. -I. DEFINES = -DSERENITY -DUSERLAND -DSANITIZE_PTRS CXXFLAGS = $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(LIBC_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) -CXX = g++-8 +CXX = clang LD = ld AR = ar LDFLAGS = -T linker.ld --strip-debug -melf_i386 --gc-sections --build-id=none -z norelro -z now diff --git a/LibC/sys/cdefs.h b/LibC/sys/cdefs.h index cee02fafc0..4c5f129ff8 100644 --- a/LibC/sys/cdefs.h +++ b/LibC/sys/cdefs.h @@ -16,3 +16,6 @@ #undef __P #define __P(a) a + +extern "C" int main(int, char**); + diff --git a/Userland/Makefile b/Userland/Makefile index 93b6529643..cbd895b1f3 100644 --- a/Userland/Makefile +++ b/Userland/Makefile @@ -45,13 +45,13 @@ STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc USERLAND_FLAGS = -ffreestanding -fno-stack-protector -fno-ident WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings FLAVOR_FLAGS = -march=i386 -mregparm=3 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic -OPTIMIZATION_FLAGS = -Os -fno-asynchronous-unwind-tables +OPTIMIZATION_FLAGS = -Oz -fno-asynchronous-unwind-tables INCLUDE_FLAGS = -I.. -I. -I../LibC DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(USERLAND_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) -CXX = g++-8 +CXX = clang LD = ld AR = ar LDFLAGS = -static --strip-debug -melf_i386 --build-id=none -z norelro -z now -e _start --gc-sections diff --git a/Userland/false.cpp b/Userland/false.cpp index 2227c3aa8f..6e17027f35 100644 --- a/Userland/false.cpp +++ b/Userland/false.cpp @@ -1,4 +1,6 @@ -int main() +#include <sys/cdefs.h> + +int main(int, char**) { return 1; } diff --git a/Userland/id.cpp b/Userland/id.cpp index 5b906669dc..4a399c7197 100644 --- a/Userland/id.cpp +++ b/Userland/id.cpp @@ -4,6 +4,8 @@ #include <grp.h> #include <alloca.h> +extern "C" int main(int, char**); + int main(int argc, char** argv) { (void) argc; diff --git a/Userland/true.cpp b/Userland/true.cpp index 905869dfa3..ec75811a19 100644 --- a/Userland/true.cpp +++ b/Userland/true.cpp @@ -1,4 +1,6 @@ -int main() +#include <sys/cdefs.h> + +int main(int, char**) { return 0; } |