diff --git a/init/Android.bp b/init/Android.bp index 25877c083..7d863c884 100644 --- a/init/Android.bp +++ b/init/Android.bp @@ -67,24 +67,26 @@ cc_defaults { "libsquashfs_utils", "liblogwrap", "libext4_utils", - "libcutils", - "libbase", - "libc", "libseccomp_policy", - "libselinux", - "liblog", "libcrypto_utils", - "libcrypto", - "libc++_static", - "libdl", "libsparse", - "libz", "libprocessgroup", "libavb", "libkeyutils", "libprotobuf-cpp-lite", "libpropertyinfoserializer", "libpropertyinfoparser", + "libselinux", + ], + shared_libs: [ + "libcutils", + "libbase", + "libc", + "liblog", + "libcrypto", + "libc++", + "libdl", + "libz", ], } @@ -166,7 +168,6 @@ cc_binary { cc_test { name: "init_tests", defaults: ["init_defaults"], - static_executable: true, srcs: [ "devices_test.cpp", "init_test.cpp", @@ -187,7 +188,6 @@ cc_test { cc_benchmark { name: "init_benchmarks", - static_executable: true, defaults: ["init_defaults"], srcs: [ "subcontext_benchmark.cpp", diff --git a/init/Android.mk b/init/Android.mk index c4a6a50e5..da27a73f4 100644 --- a/init/Android.mk +++ b/init/Android.mk @@ -45,7 +45,6 @@ LOCAL_SRC_FILES := main.cpp LOCAL_MODULE:= init -LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED) @@ -59,18 +58,10 @@ LOCAL_STATIC_LIBRARIES := \ libsquashfs_utils \ liblogwrap \ libext4_utils \ - libcutils \ - libbase \ - libc \ libseccomp_policy \ - libselinux \ - liblog \ libcrypto_utils \ - libcrypto \ - libc++_static \ - libdl \ libsparse \ - libz \ + libselinux \ libprocessgroup \ libavb \ libkeyutils \ @@ -78,6 +69,25 @@ LOCAL_STATIC_LIBRARIES := \ libpropertyinfoserializer \ libpropertyinfoparser \ +shared_libs := \ + libcutils \ + libbase \ + liblog \ + libcrypto \ + libdl \ + libz \ + +ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) +# init is static executable for non-system-as-root devices, because the dynamic linker +# and shared libs are not available before /system is mounted, but init has to run +# before the partition is mounted. +LOCAL_STATIC_LIBRARIES += $(shared_libs) libc++_static +LOCAL_FORCE_STATIC_EXECUTABLE := true +else +LOCAL_SHARED_LIBRARIES := $(shared_libs) libc++ +endif +shared_libs := + LOCAL_REQUIRED_MODULES := \ e2fsdroid \ mke2fs \