Add -lm to the default libs for Linux & Darwin

libm is a default library for device builds, so default it for host
builds as well.

Also removes duplicate additions of -ldl, -lpthread, -lm and -lrt.

Test: m host
Change-Id: I6a07e12053090eb6997b79d4091c28ac9a9022de
This commit is contained in:
Dan Willemsen 2017-09-26 20:26:11 -07:00
parent b182ea7bcb
commit a3a06feeed
5 changed files with 2 additions and 12 deletions

View file

@ -291,10 +291,10 @@ my_ldlib_flags :=
my_shared_libraries += $(patsubst -l%,lib%,$(filter-out $(my_allowed_ldlibs),$(my_ldlibs))) my_shared_libraries += $(patsubst -l%,lib%,$(filter-out $(my_allowed_ldlibs),$(my_ldlibs)))
my_ldlibs := $(filter $(my_allowed_ldlibs),$(my_ldlibs)) my_ldlibs := $(filter $(my_allowed_ldlibs),$(my_ldlibs))
else # LOCAL_IS_HOST_MODULE else # LOCAL_IS_HOST_MODULE
# Add -ldl, -lpthread and -lrt to host builds to match the default behavior of # Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of
# device builds # device builds
ifneq ($($(my_prefix)OS),windows) ifneq ($($(my_prefix)OS),windows)
my_ldlibs += -ldl -lpthread my_ldlibs += -ldl -lpthread -lm
ifneq ($(HOST_OS),darwin) ifneq ($(HOST_OS),darwin)
my_ldlibs += -lrt my_ldlibs += -lrt
endif endif

View file

@ -217,7 +217,6 @@ ifneq ($(my_sanitize),)
ifdef LOCAL_IS_HOST_MODULE ifdef LOCAL_IS_HOST_MODULE
my_cflags += -fno-sanitize-recover=all my_cflags += -fno-sanitize-recover=all
my_ldflags += -fsanitize=$(fsanitize_arg) my_ldflags += -fsanitize=$(fsanitize_arg)
my_ldlibs += -lrt -ldl
else else
my_cflags += -fsanitize-trap=all my_cflags += -fsanitize-trap=all
my_cflags += -ftrap-function=abort my_cflags += -ftrap-function=abort
@ -249,7 +248,6 @@ ifneq ($(filter address,$(my_global_sanitize) $(my_sanitize)),)
ifdef LOCAL_IS_HOST_MODULE ifdef LOCAL_IS_HOST_MODULE
# -nodefaultlibs (provided with libc++) prevents the driver from linking # -nodefaultlibs (provided with libc++) prevents the driver from linking
# libraries needed with -fsanitize=address. http://b/18650275 (WAI) # libraries needed with -fsanitize=address. http://b/18650275 (WAI)
my_ldlibs += -lm -lpthread
my_ldflags += -Wl,--no-as-needed my_ldflags += -Wl,--no-as-needed
else else
# Add asan libraries unless LOCAL_MODULE is the asan library. # Add asan libraries unless LOCAL_MODULE is the asan library.

View file

@ -89,7 +89,6 @@ ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),)
ifdef LOCAL_IS_HOST_MODULE ifdef LOCAL_IS_HOST_MODULE
my_cppflags += -nostdinc++ my_cppflags += -nostdinc++
my_ldflags += -nodefaultlibs my_ldflags += -nodefaultlibs
my_ldlibs += -lpthread -lm
my_cxx_ldlibs += $($($(my_prefix)OS)_$(my_link_type)_gcclibs) my_cxx_ldlibs += $($($(my_prefix)OS)_$(my_link_type)_gcclibs)
else else
ifeq (arm,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) ifeq (arm,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))

View file

@ -5,9 +5,7 @@
ifeq ($(LOCAL_GTEST),true) ifeq ($(LOCAL_GTEST),true)
LOCAL_CFLAGS_windows += -DGTEST_OS_WINDOWS LOCAL_CFLAGS_windows += -DGTEST_OS_WINDOWS
LOCAL_CFLAGS_linux += -DGTEST_OS_LINUX LOCAL_CFLAGS_linux += -DGTEST_OS_LINUX
LOCAL_LDLIBS_linux += -lpthread
LOCAL_CFLAGS_darwin += -DGTEST_OS_MAC LOCAL_CFLAGS_darwin += -DGTEST_OS_MAC
LOCAL_LDLIBS_darwin += -lpthread
LOCAL_CFLAGS += -DGTEST_HAS_STD_STRING -O0 -g LOCAL_CFLAGS += -DGTEST_HAS_STD_STRING -O0 -g

View file

@ -18,9 +18,4 @@ cc_binary_host {
"makeparallel.cpp", "makeparallel.cpp",
], ],
cflags: ["-Wall", "-Werror"], cflags: ["-Wall", "-Werror"],
target: {
linux: {
host_ldlibs: ["-lrt", "-lpthread"],
},
},
} }