From 3af59dfed1f0e6203cea3a6e5cdaa3bac7d72d31 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 28 Jun 2019 20:58:41 +0200 Subject: [PATCH] AK: We can't use std::initializer_list in LibC builds. The LibC build is a bit complicated, since the toolchain depends on it. During the toolchain bootstrap, after we've built parts of GCC, we have to stop and build Serenity's LibC, so that the rest of GCC can use it. This means that during that specific LibC build, we don't yet have access to things like std::initializer_list. For now we solve this by defining SERENITY_LIBC_BUILD during the LibC build and excluding the Vector/initializer_list support inside LibC. --- AK/Vector.h | 8 ++++++++ LibC/Makefile | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/AK/Vector.h b/AK/Vector.h index 2ed2dc7bfc..1ae11d6cab 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -3,7 +3,13 @@ #include #include #include + +// NOTE: We can't include during the toolchain bootstrap, +// since it's part of libstdc++, and libstdc++ depends on LibC. +// For this reason, we don't support Vector(initializer_list) in LibC. +#ifndef SERENITY_LIBC_BUILD #include +#endif #ifndef __serenity__ #include @@ -65,12 +71,14 @@ public: clear(); } +#ifndef SERENITY_LIBC_BUILD Vector(std::initializer_list list) { ensure_capacity(list.size()); for (auto& item : list) unchecked_append(item); } +#endif Vector(Vector&& other) : m_size(other.m_size) diff --git a/LibC/Makefile b/LibC/Makefile index 8892be807f..83b9e1944d 100644 --- a/LibC/Makefile +++ b/LibC/Makefile @@ -58,7 +58,7 @@ ASM_OBJS = setjmp.ao crti.ao crtn.ao CPP_OBJS = $(AK_OBJS) $(WIDGETS_OBJS) $(LIBC_OBJS) LIBRARY = libc.a -DEFINES += -DUSERLAND +DEFINES += -DUSERLAND -DSERENITY_LIBC_BUILD all: $(LIBRARY) startfiles