[libc++] Move the toolchain's macros undefinition to Make.defs
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
8bc4a5b08a
commit
b827565396
@ -23,6 +23,24 @@ include $(TOPDIR)/tools/Config.mk
|
||||
|
||||
HOSTOS = ${shell uname -o 2>/dev/null || uname -s 2>/dev/null || echo "Other"}
|
||||
|
||||
# NuttX is sometimes built as a native target.
|
||||
# In that case, the __NuttX__ macro is predefined by the compiler.
|
||||
# https://github.com/NuttX/buildroot
|
||||
#
|
||||
# In other cases, __NuttX__ is an ordinary user-definded macro.
|
||||
# It's especially the case for NuttX sim, which is a target to run
|
||||
# the entire NuttX as a program on the host OS, which can be Linux,
|
||||
# macOS, Windows, etc.
|
||||
# https://cwiki.apache.org/confluence/display/NUTTX/NuttX+Simulation
|
||||
# In that case, the host OS compiler is used to build NuttX.
|
||||
# Thus, eg. NuttX sim on macOS is built with __APPLE__.
|
||||
# We #undef predefined macros for those possible host OSes here
|
||||
# because the OS APIs this library should use are of NuttX,
|
||||
# not the host OS.
|
||||
|
||||
ARCHDEFINES += -U_AIX -U_WIN32 -U__APPLE__ -U__FreeBSD__
|
||||
ARCHDEFINES += -U__NetBSD__ -U__linux__ -U__sun__ -U__unix__
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
ARCHOPTIMIZATION = -g
|
||||
endif
|
||||
@ -146,4 +164,4 @@ ifeq ($(CONFIG_SIM_M32),y)
|
||||
endif
|
||||
|
||||
HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
|
||||
$(ARCHCPUFLAGS) $(HOSTINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
|
||||
$(ARCHCPUFLAGS) $(HOSTINCLUDES) $(EXTRAFLAGS) -pipe
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 10891b1c9eda0c87e33b0c0ba87f17a83930093c Mon Sep 17 00:00:00 2001
|
||||
From 6b12d8b5c30a84aa5767b1b18ecf5ba5e99a1654 Mon Sep 17 00:00:00 2001
|
||||
From: Xiang Xiao <xiaoxiang@xiaomi.com>
|
||||
Date: Fri, 2 Oct 2020 13:25:43 +0800
|
||||
Subject: [PATCH] [libcxx] Port to NuttX(https://nuttx.apache.org/) RTOS
|
||||
@ -9,54 +9,19 @@ Co-authored-by: YAMAMOTO Takashi <yamamoto@midokura.com>
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D88718
|
||||
---
|
||||
include/__config | 31 +++++++++++++++++++++++++-
|
||||
include/__config | 3 ++-
|
||||
include/__locale | 2 ++
|
||||
include/support/nuttx/xlocale.h | 18 +++++++++++++++
|
||||
include/support/nuttx/xlocale.h | 18 ++++++++++++++++++
|
||||
src/include/config_elast.h | 4 ++++
|
||||
src/locale.cpp | 2 +-
|
||||
5 files changed, 55 insertions(+), 2 deletions(-)
|
||||
5 files changed, 27 insertions(+), 2 deletions(-)
|
||||
create mode 100644 include/support/nuttx/xlocale.h
|
||||
|
||||
diff --git a/include/__config libcxx/include/__config
|
||||
index 575147cead4..32036094017 100644
|
||||
index eeef9c53a9f..9ace3b46028 100644
|
||||
--- a/include/__config
|
||||
+++ libcxx/include/__config
|
||||
@@ -10,6 +10,34 @@
|
||||
#ifndef _LIBCPP_CONFIG
|
||||
#define _LIBCPP_CONFIG
|
||||
|
||||
+// NuttX is sometimes built as a native target.
|
||||
+// In that case, the __NuttX__ macro is predefined by the compiler.
|
||||
+// https://github.com/NuttX/buildroot
|
||||
+//
|
||||
+// In other cases, __NuttX__ is an ordinary user-definded macro.
|
||||
+// It's especially the case for NuttX sim, which is a target to run
|
||||
+// the entire NuttX as a program on the host OS, which can be Linux,
|
||||
+// macOS, Windows, etc.
|
||||
+// https://cwiki.apache.org/confluence/display/NUTTX/NuttX+Simulation
|
||||
+// In that case, the host OS compiler is used to build NuttX.
|
||||
+// Thus, eg. NuttX sim on macOS is built with __APPLE__.
|
||||
+// We #undef predefined macros for those possible host OSes here
|
||||
+// because the OS APIs this library should use are of NuttX,
|
||||
+// not the host OS.
|
||||
+#if defined(__NuttX__)
|
||||
+#undef __linux__
|
||||
+#undef __APPLE__
|
||||
+#undef __FreeBSD__
|
||||
+#undef __NetBSD__
|
||||
+#undef _WIN32
|
||||
+#undef __sun__
|
||||
+#undef _AIX
|
||||
+// For the current use of the __unix__ macro in this library,
|
||||
+// NuttX is not __unix__.
|
||||
+// This might need to be revisited in future.
|
||||
+#undef __unix__
|
||||
+#endif
|
||||
+
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
@@ -1125,6 +1153,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
@@ -1117,6 +1117,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
# if defined(__FreeBSD__) || \
|
||||
defined(__wasi__) || \
|
||||
defined(__NetBSD__) || \
|
||||
@ -64,7 +29,7 @@ index 575147cead4..32036094017 100644
|
||||
defined(__linux__) || \
|
||||
defined(__GNU__) || \
|
||||
defined(__APPLE__) || \
|
||||
@@ -1227,7 +1256,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
@@ -1219,7 +1220,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -74,10 +39,10 @@ index 575147cead4..32036094017 100644
|
||||
#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
|
||||
#endif
|
||||
diff --git a/include/__locale libcxx/include/__locale
|
||||
index 6d10fa4d3d6..fb391861f23 100644
|
||||
index 125adcf68c8..ebededf066b 100644
|
||||
--- a/include/__locale
|
||||
+++ libcxx/include/__locale
|
||||
@@ -21,6 +21,8 @@
|
||||
@@ -22,6 +22,8 @@
|
||||
#if defined(_LIBCPP_MSVCRT_LIKE)
|
||||
# include <cstring>
|
||||
# include <support/win32/locale_win32.h>
|
||||
@ -130,7 +95,7 @@ index 501cbc4ffeb..3113f9fb5cd 100644
|
||||
// No _LIBCPP_ELAST needed on Fuchsia
|
||||
#elif defined(__wasi__)
|
||||
diff --git a/src/locale.cpp libcxx/src/locale.cpp
|
||||
index b9180880e49..25699f29ec9 100644
|
||||
index 5fdc14992f8..ed93727b544 100644
|
||||
--- a/src/locale.cpp
|
||||
+++ libcxx/src/locale.cpp
|
||||
@@ -30,7 +30,7 @@
|
||||
|
Loading…
x
Reference in New Issue
Block a user