Add basic musl support to make
There are still devices that set BUILD_BROKEN_USES_BUILD_HOST_* and build host modules in Make. Add basic support for building against libc_musl in Make when USE_HOST_MUSL is set. Bug: 258535366 Test: build a host tool defined in Android.mk file in internal branch Change-Id: I9150be749bbeaac2ac5a33b2cf915004aa3033df
This commit is contained in:
parent
2e62ca1a68
commit
af7ac3986e
5 changed files with 41 additions and 11 deletions
|
@ -19,7 +19,11 @@ include $(BUILD_SYSTEM)/use_lld_setup.mk
|
|||
# supply that, for example, when building libc itself.
|
||||
ifdef LOCAL_IS_HOST_MODULE
|
||||
ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
|
||||
ifdef USE_HOST_MUSL
|
||||
my_system_shared_libraries := libc_musl
|
||||
else
|
||||
my_system_shared_libraries :=
|
||||
endif
|
||||
else
|
||||
my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
|
||||
endif
|
||||
|
@ -348,9 +352,11 @@ my_ldlibs := $(filter $(my_allowed_ldlibs),$(my_ldlibs))
|
|||
else # LOCAL_IS_HOST_MODULE
|
||||
# Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of
|
||||
# device builds
|
||||
my_ldlibs += -ldl -lpthread -lm
|
||||
ifneq ($(HOST_OS),darwin)
|
||||
my_ldlibs += -lrt
|
||||
ifndef USE_HOST_MUSL
|
||||
my_ldlibs += -ldl -lpthread -lm
|
||||
ifneq ($(HOST_OS),darwin)
|
||||
my_ldlibs += -lrt
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
|
|
@ -1049,14 +1049,6 @@ endif # PRODUCT_USE_DYNAMIC_PARTITIONS
|
|||
BOARD_PREBUILT_HIDDENAPI_DIR ?=
|
||||
.KATI_READONLY := BOARD_PREBUILT_HIDDENAPI_DIR
|
||||
|
||||
ifdef USE_HOST_MUSL
|
||||
ifneq (,$(or $(BUILD_BROKEN_USES_BUILD_HOST_EXECUTABLE),\
|
||||
$(BUILD_BROKEN_USES_BUILD_HOST_SHARED_LIBRARY),\
|
||||
$(BUILD_BROKEN_USES_BUILD_HOST_STATIC_LIBRARY)))
|
||||
$(error USE_HOST_MUSL can't be set when native host builds are enabled in Make with BUILD_BROKEN_USES_BUILD_HOST_*)
|
||||
endif
|
||||
endif
|
||||
|
||||
# ###############################################################
|
||||
# Set up final options.
|
||||
# ###############################################################
|
||||
|
|
|
@ -2121,6 +2121,7 @@ $(hide) $(PRIVATE_CXX_LINK) \
|
|||
$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
|
||||
) \
|
||||
$(PRIVATE_LDFLAGS) \
|
||||
$(PRIVATE_CRTBEGIN) \
|
||||
$(PRIVATE_ALL_OBJECTS) \
|
||||
-Wl,--whole-archive \
|
||||
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
||||
|
@ -2129,8 +2130,10 @@ $(hide) $(PRIVATE_CXX_LINK) \
|
|||
$(PRIVATE_ALL_STATIC_LIBRARIES) \
|
||||
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
|
||||
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
|
||||
$(PRIVATE_LIBCRT_BUILTINS) \
|
||||
$(PRIVATE_ALL_SHARED_LIBRARIES) \
|
||||
-o $@ \
|
||||
$(PRIVATE_CRTEND) \
|
||||
$(PRIVATE_LDLIBS)
|
||||
endef
|
||||
endif
|
||||
|
@ -2264,6 +2267,7 @@ endef
|
|||
ifneq ($(HOST_CUSTOM_LD_COMMAND),true)
|
||||
define transform-host-o-to-executable-inner
|
||||
$(hide) $(PRIVATE_CXX_LINK) \
|
||||
$(PRIVATE_CRTBEGIN) \
|
||||
$(PRIVATE_ALL_OBJECTS) \
|
||||
-Wl,--whole-archive \
|
||||
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
|
||||
|
@ -2272,6 +2276,7 @@ $(hide) $(PRIVATE_CXX_LINK) \
|
|||
$(PRIVATE_ALL_STATIC_LIBRARIES) \
|
||||
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
|
||||
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
|
||||
$(PRIVATE_LIBCRT_BUILTINS) \
|
||||
$(PRIVATE_ALL_SHARED_LIBRARIES) \
|
||||
$(foreach path,$(PRIVATE_RPATHS), \
|
||||
-Wl,-rpath,\$$ORIGIN/$(path)) \
|
||||
|
@ -2280,6 +2285,7 @@ $(hide) $(PRIVATE_CXX_LINK) \
|
|||
) \
|
||||
$(PRIVATE_LDFLAGS) \
|
||||
-o $@ \
|
||||
$(PRIVATE_CRTEND) \
|
||||
$(PRIVATE_LDLIBS)
|
||||
endef
|
||||
endif
|
||||
|
|
|
@ -39,6 +39,21 @@ $(LOCAL_BUILT_MODULE): PRIVATE_RPATHS := ../$(my_libdir) $(my_libdir)
|
|||
endif
|
||||
my_libdir :=
|
||||
|
||||
my_crtbegin :=
|
||||
my_crtend :=
|
||||
my_libcrt_builtins :=
|
||||
ifdef USE_HOST_MUSL
|
||||
my_crtbegin := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_OBJECT_libc_musl_crtbegin_dynamic)
|
||||
my_crtend := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_OBJECT_libc_musl_crtend)
|
||||
my_libcrt_builtins := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBCRT_BUILTINS)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_LDFLAGS += -Wl,--no-dynamic-linker
|
||||
endif
|
||||
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_CRTBEGIN := $(my_crtbegin)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_CRTEND := $(my_crtend)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_LIBCRT_BUILTINS := $(my_libcrt_builtins)
|
||||
$(LOCAL_BUILT_MODULE): $(my_crtbegin) $(my_crtend) $(my_libcrt_builtins)
|
||||
|
||||
$(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries) $(CLANG_CXX)
|
||||
$(transform-host-o-to-executable)
|
||||
|
||||
|
|
|
@ -36,6 +36,17 @@ include $(BUILD_SYSTEM)/binary.mk
|
|||
my_host_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_HOST_LIBPROFILE_RT := $(my_host_libprofile_rt)
|
||||
|
||||
ifdef USE_HOST_MUSL
|
||||
my_crtbegin := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_OBJECT_libc_musl_crtbegin_so)
|
||||
my_crtend := $(SOONG_$(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_OBJECT_libc_musl_crtend_so)
|
||||
my_libcrt_builtins := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBCRT_BUILTINS)
|
||||
endif
|
||||
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_CRTBEGIN := $(my_crtbegin)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_CRTEND := $(my_crtend)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_LIBCRT_BUILTINS := $(my_libcrt_builtins)
|
||||
$(LOCAL_BUILT_MODULE): $(my_crtbegin) $(my_crtend) $(my_libcrt_builtins)
|
||||
|
||||
$(LOCAL_BUILT_MODULE): \
|
||||
$(all_objects) \
|
||||
$(all_libraries) \
|
||||
|
|
Loading…
Reference in a new issue