Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 787322c5 authored by Jiyong Park's avatar Jiyong Park
Browse files

Build init with shared libraries

recovery partition now supports shared librarys. Therefore, init can now
be built as a dynamic executable both for normal and recovery modes.

To save save in the recovery mode, not all libs are dynamically linked.
Libs that are only used by init in the recovery mode are still
statically linked.

Note: init is still a static executable for legacy devices where
system-as-root is not on, because the dynamic linker and shared libs
which are in /system are not available when init starts.

Bug: 63673171
Test: `adb reboot recovery; adb devices` shows the device ID
Test: device boots to the UI in normal mode.
Test: do that for both walleye (system-as-root) and bullhead (legacy
ramdisk).
Change-Id: I30c84ae6a8e507e507ad0bb71acad281316d9e90
parent 011ee12b
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -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",
+20 −10
Original line number Diff line number Diff line
@@ -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 \