diff --git a/Makefile b/Makefile index 6254138..94f1d8f 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,11 @@ OBJECTS := $(SOURCES:.c=.o) ifeq ($(CONFIG_CXX_ALLOCATOR),true) # make sure LTO is compatible in case CC and CXX don't match (such as clang and g++) CXX := $(CC) - LDLIBS += -lstdc++ + ifeq ($(CONFIG_USE_LIBCXX),true) + LDLIBS += -lc++ + else + LDLIBS += -lstdc++ + endif SOURCES += new.cc OBJECTS += new.o @@ -85,6 +89,7 @@ ifeq (,$(filter $(CONFIG_STATS),true false)) endif CPPFLAGS += \ + -DCONFIG_USE_LIBCXX=$(CONFIG_USE_LIBCXX) \ -DCONFIG_SEAL_METADATA=$(CONFIG_SEAL_METADATA) \ -DZERO_ON_FREE=$(CONFIG_ZERO_ON_FREE) \ -DWRITE_AFTER_FREE_CHECK=$(CONFIG_WRITE_AFTER_FREE_CHECK) \ diff --git a/config/default.mk b/config/default.mk index 67a267b..eb239bb 100644 --- a/config/default.mk +++ b/config/default.mk @@ -1,6 +1,7 @@ CONFIG_WERROR := true CONFIG_NATIVE := true CONFIG_CXX_ALLOCATOR := true +CONFIG_USE_LIBCXX := false CONFIG_UBSAN := false CONFIG_SEAL_METADATA := false CONFIG_ZERO_ON_FREE := true diff --git a/config/light.mk b/config/light.mk index 397f85e..7f998d4 100644 --- a/config/light.mk +++ b/config/light.mk @@ -1,6 +1,7 @@ CONFIG_WERROR := true CONFIG_NATIVE := true CONFIG_CXX_ALLOCATOR := true +CONFIG_USE_LIBCXX := false CONFIG_UBSAN := false CONFIG_SEAL_METADATA := false CONFIG_ZERO_ON_FREE := true diff --git a/new.cc b/new.cc index e46e302..152b2df 100644 --- a/new.cc +++ b/new.cc @@ -1,4 +1,6 @@ +#if !defined(__clang__) || !CONFIG_USE_LIBCXX #include +#endif #include #include "h_malloc.h"