Skip to content

Commit 5e96e72

Browse files
cuiziweizwxiaoxiang781216
authored andcommitted
X86_64: Add libcxx availability macros.
Signed-off-by: cuiziwei <[email protected]>
1 parent 1373957 commit 5e96e72

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

arch/x86_64/src/common/Toolchain.defs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@
1818
#
1919
############################################################################
2020

21+
# NuttX is sometimes built as a native target.
22+
# In that case, the __NuttX__ macro is predefined by the compiler.
23+
# https://github.com/NuttX/buildroot
24+
#
25+
# In other cases, __NuttX__ is an ordinary user-definded macro.
26+
# It's especially the case for NuttX sim, which is a target to run
27+
# the entire NuttX as a program on the host OS, which can be Linux,
28+
# macOS, Windows, etc.
29+
# https://cwiki.apache.org/confluence/display/NUTTX/NuttX+Simulation
30+
# In that case, the host OS compiler is used to build NuttX.
31+
# Thus, eg. NuttX sim on macOS is built with __APPLE__.
32+
# We #undef predefined macros for those possible host OSes here
33+
# because the OS APIs this library should use are of NuttX,
34+
# not the host OS.
35+
36+
ARCHDEFINES += -U_AIX -U_WIN32 -U__APPLE__ -U__FreeBSD__
37+
ARCHDEFINES += -U__NetBSD__ -U__linux__ -U__sun__ -U__unix__
38+
ARCHDEFINES += -U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
39+
2140
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
2241
ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
2342
endif
@@ -58,6 +77,23 @@ ifeq ($(CONFIG_DEBUG_LINK_WHOLE_ARCHIVE),y)
5877
LDFLAGS += --whole-archive
5978
endif
6079

80+
ifeq ($(CONFIG_LIBCXX),y)
81+
# Linux C++ ABI seems vary.
82+
# Probably __GLIBCXX__ is the best bet.
83+
# XXX what to do for windows?
84+
85+
CXXFLAGS += -D__GLIBCXX__
86+
87+
# Disable availability macros.
88+
# The availability on Host OS is not likely appropriate for NuttX.
89+
#
90+
# Note: When compiling NuttX apps, we undefine __APPLE__.
91+
# It makes libcxx __availability header unhappy.
92+
# https://github.com/llvm/llvm-project/blob/2e2999cd44f6ec9a5e396fa0113497ea82582f69/libcxx/include/__availability#L258
93+
94+
CXXFLAGS += -D_LIBCPP_DISABLE_AVAILABILITY
95+
endif
96+
6197
CC = $(CROSSDEV)gcc
6298
CPP = $(CROSSDEV)gcc -E -x c
6399
LD = $(CROSSDEV)ld

0 commit comments

Comments
 (0)