You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/01/14 05:49:57 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2063: Fix libcxx for sim/macOS

xiaoxiang781216 commented on a change in pull request #2063:
URL: https://github.com/apache/incubator-nuttx/pull/2063#discussion_r557057930



##########
File path: boards/sim/sim/sim/scripts/Make.defs
##########
@@ -93,14 +93,28 @@ NM = $(CROSSDEV)nm
 OBJCOPY = $(CROSSDEV)objcopy
 OBJDUMP = $(CROSSDEV)objdump
 
+# Note: -fshort-wchar for the case where NuttX and the host OS have
+# differnt wchar_t. On Nuttx, it's uint16_t. On macOS, it's 32-bit.
 CFLAGS := $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
-   $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
+   $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe \
+   -fshort-wchar
 CXXFLAGS := $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \
-   $(ARCHCPUFLAGSXX) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
-CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
+   $(ARCHCPUFLAGSXX) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe \
+   -fshort-wchar
+CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) \
+   -fshort-wchar
 AFLAGS := $(CFLAGS) -D__ASSEMBLY__
 
 ifeq ($(CONFIG_LIBCXX),y)
+  # Why c++14?
+  #  * libcxx seems to require c++11.
+  #  * The compiler defaults varies:
+  #      clang/macOS (from xcode): 199711L
+  #      gcc/ubuntu:               201402L
+  #  * There is a precedent to use c++14.
+  #    (boards/arm/stm32l4/nucleo-l476rg/scripts/Make.defs)
+  CXXFLAGS += -std=c++14 -D_LIBCPP_STD_VER=14

Review comment:
       Don't need _LIBCPP_STD_VER=14, libcxx will detect the right version automatically:
   https://github.com/llvm/llvm-project/blob/master/libcxx/include/__config#L45-L57




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org