Merge "Allow flashing a squashfs system image"
diff --git a/core/cxx_stl_setup.mk b/core/cxx_stl_setup.mk
index 0f574d2..265d8cb 100644
--- a/core/cxx_stl_setup.mk
+++ b/core/cxx_stl_setup.mk
@@ -10,6 +10,11 @@
# Platform code. Select the appropriate STL.
ifndef USE_MINGW
my_cxx_stl := libc++
+ ifdef LOCAL_IS_HOST_MODULE
+ ifneq (,$(BUILD_HOST_static))
+ my_cxx_stl := libc++_static
+ endif
+ endif
else
# libc++ is not supported on mingw.
my_cxx_stl := libstdc++
@@ -21,6 +26,26 @@
my_cxx_stl := $(strip $(LOCAL_CXX_STL))
endif
+# Yes, this is actually what the clang driver does.
+HOST_linux_dynamic_gcclibs := -lgcc_s -lgcc -lc -lgcc_s -lgcc
+HOST_linux_static_gcclibs := -Wl,--start-group -lgcc -lgcc_eh -lc -Wl,--end-group
+HOST_darwin_dynamic_gcclibs := -lc -lSystem
+HOST_darwin_static_gcclibs := NO_STATIC_HOST_BINARIES_ON_DARWIN
+
+my_link_type := dynamic
+ifdef LOCAL_IS_HOST_MODULE
+ ifneq (,$(BUILD_HOST_static))
+ my_link_type := static
+ endif
+ ifeq (-static,$(filter -static,$(my_ldflags)))
+ my_link_type := static
+ endif
+else
+ ifeq (true,$(LOCAL_FORCE_STATIC_EXECUTABLE))
+ my_link_type := static
+ endif
+endif
+
ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),)
my_cflags += -D_USING_LIBCXX
my_c_includes += external/libcxx/include
@@ -33,7 +58,8 @@
ifdef LOCAL_IS_HOST_MODULE
my_cppflags += -nostdinc++
my_ldflags += -nodefaultlibs
- my_ldlibs += -lc -lm -lpthread
+ my_ldlibs += -lpthread -lm
+ my_ldlibs += $($(my_prefix)$(HOST_OS)_$(my_link_type)_gcclibs)
endif
else ifneq ($(filter $(my_cxx_stl),stlport stlport_static),)
ifndef LOCAL_IS_HOST_MODULE
@@ -61,7 +87,8 @@
else ifeq ($(my_cxx_stl),none)
ifdef LOCAL_IS_HOST_MODULE
my_cppflags += -nostdinc++
- my_ldflags += -nodefaultlibs -lc -lm
+ my_ldflags += -nodefaultlibs
+ my_ldlibs += $($(my_prefix)$(HOST_OS)_$(my_link_type)_gcclibs)
endif
else
$(error $(my_cxx_stl) is not a supported STL.)