diff --git a/emerald-gcc.sh b/emerald-gcc.sh
new file mode 100755
index 0000000..2102f65
--- /dev/null
+++ b/emerald-gcc.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+EMERALD_SCRIPT_DIR=$(dirname "$(realpath "$0")")
+
+GCC_VER=11.3.0
+GCC_SHA256=b47cf2818691f5b1e21df2bb38c795fac2cfbd640ede2d0a5e1c89e338a3ac39
+
+EMERALD_BUILD_DIR="$EMERALD_SCRIPT_DIR"/build
+EMERALD_DL_DIR="$EMERALD_SCRIPT_DIR"/dl
+source "$EMERALD_SCRIPT_DIR"/common.sh
+
+# Make sure build and dl directory exists
+mkdir -vp "$EMERALD_BUILD_DIR" "$EMERALD_DL_DIR"
+
+# Getting source
+download https://ftp.gnu.org/gnu/gcc/gcc-"$GCC_VER"/gcc-"$GCC_VER".tar.xz "$EMERALD_DL_DIR"/gcc-"$GCC_VER".tar.xz "$GCC_SHA256"
+
+if [ ! -d "$EMERALD_BUILD_DIR"/gcc-"$GCC_VER" ]; then
+ tar --directory="$EMERALD_BUILD_DIR" -xJf "$EMERALD_DL_DIR"/gcc-"$GCC_VER".tar.xz
+fi
+
+cd "$EMERALD_BUILD_DIR"/gcc-"$GCC_VER"
+
+# Apply patches
+find "$EMERALD_SCRIPT_DIR"/patches/gcc/"$GCC_VER" -type f -name '*.patch' -exec patch -p0 -i {} \;
+
+./contrib/download_prerequisites
+
+# Its suggested to run configure from a seperate directory
+mkdir -vp build && cd "$_"
+
+# Configuration
+../configure --target="$TARGET" --prefix="$PREFIX" \
+ --enable-plugins --without-headers \
+ --with-gnu-as --with-gnu-ld \
+ --enable-languages=c,c++ --with-pkgversion='Emerald' \
+ --enable-default-pie --enable-gnu-indirect-function \
+ --disable-libsanitizer --disable-nls
+
+# Building
+make -j4
+export PATH="$PREFIX/bin:$PATH"
+make install-strip -j1
diff --git a/emerald-sysroot.sh b/emerald-sysroot.sh
new file mode 100755
index 0000000..ffa3490
--- /dev/null
+++ b/emerald-sysroot.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+EMERALD_SCRIPT_DIR=$(dirname "$(realpath "$0")")
+source "$EMERALD_SCRIPT_DIR"/common.sh
+
+SYSROOT=https://perosar.tilde.team/dl/android-ndk-sysroot-aarch64.tar.xz
+
+DIR=$(mktemp -d)
+cd "$DIR"
+
+curl "$SYSROOT" | tar -xJf -
+
+mkdir -vp "$PREFIX"/"$TARGET"/sys-include "$PREFIX"/"$TARGET"/lib
+
+cp -R include/* "$PREFIX"/"$TARGET"/sys-include
+cp -R lib/* "$PREFIX"/"$TARGET"/lib
+
+# pthread functionality is provided by libc on android.
+echo "INPUT(-lc)" > "$PREFIX"/"$TARGET"/lib/libpthread.a
diff --git a/patches/gcc/11.3.0/gcc-config-aarch64-aarch64-linux-android.h.patch b/patches/gcc/11.3.0/gcc-config-aarch64-aarch64-linux-android.h.patch
new file mode 100644
index 0000000..7e2e2e1
--- /dev/null
+++ b/patches/gcc/11.3.0/gcc-config-aarch64-aarch64-linux-android.h.patch
@@ -0,0 +1,69 @@
+--- /dev/null 2022-03-10 14:56:30.584000000 +1100
++++ gcc/config/aarch64/aarch64-linux-android.h 2022-04-26 15:48:56.533607085 +1000
+@@ -0,0 +1,66 @@
++/* Machine description for AArch64 architecture.
++ Copyright (C) 2014 Free Software Foundation, Inc.
++
++ This file is part of GCC.
++
++ GCC 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, or (at your option)
++ any later version.
++
++ GCC 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 GCC; see the file COPYING3. If not see
++ . */
++
++#ifndef GCC_AARCH64_LINUX_ANDROID_H
++#define GCC_AARCH64_LINUX_ANDROID_H
++
++
++#undef TARGET_OS_CPP_BUILTINS
++#define TARGET_OS_CPP_BUILTINS() \
++ do \
++ { \
++ GNU_USER_TARGET_OS_CPP_BUILTINS(); \
++ ANDROID_TARGET_OS_CPP_BUILTINS(); \
++ } \
++ while (0)
++
++#undef LINK_SPEC
++#define LINK_SPEC \
++ LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \
++ LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
++
++#undef CC1_SPEC
++#define CC1_SPEC \
++ LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
++ GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC("-fpic"))
++
++#define CC1PLUS_SPEC \
++ LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC)
++
++#undef LIB_SPEC
++#define LIB_SPEC \
++ LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LIB_SPEC, \
++ GNU_USER_TARGET_NO_PTHREADS_LIB_SPEC " " ANDROID_LIB_SPEC)
++
++#undef STARTFILE_SPEC
++#define STARTFILE_SPEC \
++ LINUX_OR_ANDROID_LD (GNU_USER_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC)
++
++#undef ENDFILE_SPEC
++#define ENDFILE_SPEC \
++ LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC)
++
++#ifdef IN_LIBGCC2
++#define LIBGCC2_UNWIND_ATTRIBUTE __attribute__((visibility("default")))
++#endif
++
++#define STARTFILE_PREFIX_SPEC \
++ "/usr/lib/"
++
++#endif /* GCC_AARCH64_LINUX_ANDROID_H */
diff --git a/patches/gcc/11.3.0/gcc-config-aarch64-aarch64-linux.h.patch b/patches/gcc/11.3.0/gcc-config-aarch64-aarch64-linux.h.patch
new file mode 100644
index 0000000..6315028
--- /dev/null
+++ b/patches/gcc/11.3.0/gcc-config-aarch64-aarch64-linux.h.patch
@@ -0,0 +1,20 @@
+--- gcc/config/aarch64/aarch64-linux.h.bak 2022-04-26 15:37:28.201223209 +1000
++++ gcc/config/aarch64/aarch64-linux.h 2022-04-26 15:40:40.671532123 +1000
+@@ -21,7 +21,16 @@
+ #ifndef GCC_AARCH64_LINUX_H
+ #define GCC_AARCH64_LINUX_H
+
+-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
++#ifndef RUNTIME_ROOT_PREFIX
++#define RUNTIME_ROOT_PREFIX ""
++#endif
++
++#define GLIBC_DYNAMIC_LINKER RUNTIME_ROOT_PREFIX "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
++
++#ifdef BIONIC_DYNAMIC_LINKER
++#undef BIONIC_DYNAMIC_LINKER
++#endif
++#define BIONIC_DYNAMIC_LINKER RUNTIME_ROOT_PREFIX "/system/bin/linker64"
+
+ #undef MUSL_DYNAMIC_LINKER
+ #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
diff --git a/patches/gcc/11.3.0/gcc-config-linux-android.h.patch b/patches/gcc/11.3.0/gcc-config-linux-android.h.patch
new file mode 100644
index 0000000..87a4b78
--- /dev/null
+++ b/patches/gcc/11.3.0/gcc-config-linux-android.h.patch
@@ -0,0 +1,26 @@
+--- gcc/config/linux-android.h.bak 2022-04-26 15:52:59.964626084 +1000
++++ gcc/config/linux-android.h 2022-04-26 15:59:36.466061086 +1000
+@@ -44,15 +44,18 @@
+ "%{" NOANDROID "|tno-android-ld:" LINUX_SPEC ";:" ANDROID_SPEC "}"
+
+ #define ANDROID_LINK_SPEC \
+- "%{shared: -Bsymbolic}"
++ "%{shared: -Bsymbolic} -z noexecstack -z relro -z now"
+
+-#define ANDROID_CC1_SPEC \
++#define ANDROID_CC1_SPEC(ANDROID_PIC_DEFAULT) \
+ "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} " \
+- "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}"
++ "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: " ANDROID_PIC_DEFAULT "}}}}"
+
+ #define ANDROID_CC1PLUS_SPEC \
+- "%{!fexceptions:%{!fno-exceptions: -fno-exceptions}} " \
+- "%{!frtti:%{!fno-rtti: -fno-rtti}}"
++ "%{!fexceptions:%{!fno-exceptions: -fexceptions}} " \
++ "%{!frtti:%{!fno-rtti: -frtti}}"
++
++#define ANDROID_ASM_SPEC \
++ "--noexecstack"
+
+ #define ANDROID_LIB_SPEC \
+ "%{!static: -ldl}"
diff --git a/patches/gcc/11.3.0/gcc-config.gcc.patch b/patches/gcc/11.3.0/gcc-config.gcc.patch
new file mode 100644
index 0000000..1291320
--- /dev/null
+++ b/patches/gcc/11.3.0/gcc-config.gcc.patch
@@ -0,0 +1,22 @@
+--- gcc/config.gcc.bak 2022-04-26 15:19:45.302214622 +1000
++++ gcc/config.gcc 2022-04-26 15:26:29.605836585 +1000
+@@ -1136,14 +1136,18 @@
+ extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
+ ;;
+ aarch64*-*-linux*)
+- tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h"
++ tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h"
+ tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-linux.h"
++ extra_options="${extra_options} linux-android.opt"
+ tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-linux"
+ tm_defines="${tm_defines} TARGET_DEFAULT_ASYNC_UNWIND_TABLES=1"
+ case $target in
+ aarch64_be-*)
+ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
+ ;;
++ aarch64*-*-linux-android*)
++ tm_file="${tm_file} aarch64/aarch64-linux-android.h"
++ ;;
+ esac
+ aarch64_multilibs="${with_multilib_list}"
+ if test "$aarch64_multilibs" = "default"; then
diff --git a/patches/gcc/11.3.0/gcc-system.h.patch b/patches/gcc/11.3.0/gcc-system.h.patch
new file mode 100644
index 0000000..fe2c3c0
--- /dev/null
+++ b/patches/gcc/11.3.0/gcc-system.h.patch
@@ -0,0 +1,153 @@
+--- gcc/system.h.bak 2022-04-26 16:18:06.956629449 +1000
++++ gcc/system.h 2022-04-26 16:21:36.747332234 +1000
+@@ -50,150 +50,6 @@
+ #define NULL 0
+ #endif
+
+-/* Use the unlocked open routines from libiberty. */
+-
+-/* Some of these are #define on some systems, e.g. on AIX to redirect
+- the names to 64bit capable functions for LARGE_FILES support. These
+- redefs are pointless here so we can override them. */
+-
+-#undef fopen
+-#undef freopen
+-
+-#define fopen(PATH, MODE) fopen_unlocked (PATH, MODE)
+-#define fdopen(FILDES, MODE) fdopen_unlocked (FILDES, MODE)
+-#define freopen(PATH, MODE, STREAM) freopen_unlocked (PATH, MODE, STREAM)
+-
+-/* The compiler is not a multi-threaded application and therefore we
+- do not have to use the locking functions. In fact, using the locking
+- functions can cause the compiler to be significantly slower under
+- I/O bound conditions (such as -g -O0 on very large source files).
+-
+- HAVE_DECL_PUTC_UNLOCKED actually indicates whether or not the stdio
+- code is multi-thread safe by default. If it is set to 0, then do
+- not worry about using the _unlocked functions.
+-
+- fputs_unlocked, fwrite_unlocked, and fprintf_unlocked are
+- extensions and need to be prototyped by hand (since we do not
+- define _GNU_SOURCE). */
+-
+-#if defined HAVE_DECL_PUTC_UNLOCKED && HAVE_DECL_PUTC_UNLOCKED
+-
+-# ifdef HAVE_PUTC_UNLOCKED
+-# undef putc
+-# define putc(C, Stream) putc_unlocked (C, Stream)
+-# endif
+-# ifdef HAVE_PUTCHAR_UNLOCKED
+-# undef putchar
+-# define putchar(C) putchar_unlocked (C)
+-# endif
+-# ifdef HAVE_GETC_UNLOCKED
+-# undef getc
+-# define getc(Stream) getc_unlocked (Stream)
+-# endif
+-# ifdef HAVE_GETCHAR_UNLOCKED
+-# undef getchar
+-# define getchar() getchar_unlocked ()
+-# endif
+-# ifdef HAVE_FPUTC_UNLOCKED
+-# undef fputc
+-# define fputc(C, Stream) fputc_unlocked (C, Stream)
+-# endif
+-
+-#ifdef __cplusplus
+-extern "C" {
+-#endif
+-
+-# ifdef HAVE_CLEARERR_UNLOCKED
+-# undef clearerr
+-# define clearerr(Stream) clearerr_unlocked (Stream)
+-# if defined (HAVE_DECL_CLEARERR_UNLOCKED) && !HAVE_DECL_CLEARERR_UNLOCKED
+-extern void clearerr_unlocked (FILE *);
+-# endif
+-# endif
+-# ifdef HAVE_FEOF_UNLOCKED
+-# undef feof
+-# define feof(Stream) feof_unlocked (Stream)
+-# if defined (HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED
+-extern int feof_unlocked (FILE *);
+-# endif
+-# endif
+-# ifdef HAVE_FILENO_UNLOCKED
+-# undef fileno
+-# define fileno(Stream) fileno_unlocked (Stream)
+-# if defined (HAVE_DECL_FILENO_UNLOCKED) && !HAVE_DECL_FILENO_UNLOCKED
+-extern int fileno_unlocked (FILE *);
+-# endif
+-# endif
+-# ifdef HAVE_FFLUSH_UNLOCKED
+-# undef fflush
+-# define fflush(Stream) fflush_unlocked (Stream)
+-# if defined (HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED
+-extern int fflush_unlocked (FILE *);
+-# endif
+-# endif
+-# ifdef HAVE_FGETC_UNLOCKED
+-# undef fgetc
+-# define fgetc(Stream) fgetc_unlocked (Stream)
+-# if defined (HAVE_DECL_FGETC_UNLOCKED) && !HAVE_DECL_FGETC_UNLOCKED
+-extern int fgetc_unlocked (FILE *);
+-# endif
+-# endif
+-# ifdef HAVE_FGETS_UNLOCKED
+-# undef fgets
+-# define fgets(S, n, Stream) fgets_unlocked (S, n, Stream)
+-# if defined (HAVE_DECL_FGETS_UNLOCKED) && !HAVE_DECL_FGETS_UNLOCKED
+-extern char *fgets_unlocked (char *, int, FILE *);
+-# endif
+-# endif
+-# ifdef HAVE_FPUTS_UNLOCKED
+-# undef fputs
+-# define fputs(String, Stream) fputs_unlocked (String, Stream)
+-# if defined (HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED
+-extern int fputs_unlocked (const char *, FILE *);
+-# endif
+-# endif
+-# ifdef HAVE_FERROR_UNLOCKED
+-# undef ferror
+-# define ferror(Stream) ferror_unlocked (Stream)
+-# if defined (HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED
+-extern int ferror_unlocked (FILE *);
+-# endif
+-# endif
+-# ifdef HAVE_FREAD_UNLOCKED
+-# undef fread
+-# define fread(Ptr, Size, N, Stream) fread_unlocked (Ptr, Size, N, Stream)
+-# if defined (HAVE_DECL_FREAD_UNLOCKED) && !HAVE_DECL_FREAD_UNLOCKED
+-extern size_t fread_unlocked (void *, size_t, size_t, FILE *);
+-# endif
+-# endif
+-# ifdef HAVE_FWRITE_UNLOCKED
+-# undef fwrite
+-# define fwrite(Ptr, Size, N, Stream) fwrite_unlocked (Ptr, Size, N, Stream)
+-# if defined (HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED
+-extern size_t fwrite_unlocked (const void *, size_t, size_t, FILE *);
+-# endif
+-# endif
+-# ifdef HAVE_FPRINTF_UNLOCKED
+-# undef fprintf
+-/* We can't use a function-like macro here because we don't know if
+- we have varargs macros. */
+-# define fprintf fprintf_unlocked
+-# if defined (HAVE_DECL_FPRINTF_UNLOCKED) && !HAVE_DECL_FPRINTF_UNLOCKED
+-extern int fprintf_unlocked (FILE *, const char *, ...);
+-# endif
+-# endif
+-
+-#ifdef __cplusplus
+-}
+-#endif
+-
+-#endif
+-
+-/* ??? Glibc's fwrite/fread_unlocked macros cause
+- "warning: signed and unsigned type in conditional expression". */
+-#undef fread_unlocked
+-#undef fwrite_unlocked
+-
+ /* Include before "safe-ctype.h" to avoid GCC poisoning
+ the ctype macros through safe-ctype.h */
+
diff --git a/patches/gcc/11.3.0/libcpp-files.c.patch b/patches/gcc/11.3.0/libcpp-files.c.patch
new file mode 100644
index 0000000..ab2b1f1
--- /dev/null
+++ b/patches/gcc/11.3.0/libcpp-files.c.patch
@@ -0,0 +1,18 @@
+--- libcpp/files.c.bak 2022-04-26 16:05:45.106981389 +1000
++++ libcpp/files.c 2022-04-26 16:08:09.492877252 +1000
+@@ -742,11 +742,14 @@
+ cpp_error_at (pfile, CPP_DL_WARNING, loc,
+ "%s is shorter than expected", file->path);
+
++ off_t ot = (off_t) &file->st.st_size;
+ file->buffer = _cpp_convert_input (pfile,
+ CPP_OPTION (pfile, input_charset),
+ buf, size + 16, total,
+ &file->buffer_start,
+- &file->st.st_size);
++ &ot);
++
++ file->st.st_size = ot;
+ file->buffer_valid = true;
+
+ return true;
diff --git a/patches/gcc/11.3.0/libcpp-macro.c.patch b/patches/gcc/11.3.0/libcpp-macro.c.patch
new file mode 100644
index 0000000..18a8a9b
--- /dev/null
+++ b/patches/gcc/11.3.0/libcpp-macro.c.patch
@@ -0,0 +1,13 @@
+--- libcpp/macro.c.bak 2022-04-26 16:10:45.030907031 +1000
++++ libcpp/macro.c 2022-04-26 16:16:10.791129868 +1000
+@@ -509,6 +509,10 @@
+ struct stat *st = _cpp_get_file_stat (file);
+ if (st)
+ tb = localtime (&st->st_mtime);
++ if (st) {
++ const time_t mtime = (const time_t) st->st_mtime;
++ tb = localtime (&mtime);
++ }
+ if (tb)
+ {
+ char *str = asctime (tb);
diff --git a/patches/gcc/11.3.0/libstdc++-v3-config-os-bionic-ctype_base.h.patch b/patches/gcc/11.3.0/libstdc++-v3-config-os-bionic-ctype_base.h.patch
new file mode 100644
index 0000000..fb2a0db
--- /dev/null
+++ b/patches/gcc/11.3.0/libstdc++-v3-config-os-bionic-ctype_base.h.patch
@@ -0,0 +1,25 @@
+--- libstdc++-v3/config/os/bionic/ctype_base.h.bak 2022-04-27 12:37:53.088346124 +0000
++++ libstdc++-v3/config/os/bionic/ctype_base.h 2022-04-27 12:39:38.444403143 +0000
+@@ -28,6 +28,22 @@
+
+ // Information as gleaned from /usr/include/ctype.h
+
++#if defined (__ANDROID__)
++#if !defined(_U)
++#if !defined(_CTYPE_U)
++#error Bionic header ctype.h does not define either _U nor _CTYPE_U
++#endif
++#define _U _CTYPE_U
++#define _L _CTYPE_L
++#define _N _CTYPE_N
++#define _S _CTYPE_S
++#define _P _CTYPE_P
++#define _C _CTYPE_C
++#define _X _CTYPE_X
++#define _B _CTYPE_B
++#endif
++#endif /* __ANDROID__ */
++
+ namespace std _GLIBCXX_VISIBILITY(default)
+ {
+ _GLIBCXX_BEGIN_NAMESPACE_VERSION