1

I'm using Mac OS Catalina version 10.15.7. I'm trying to compile the image for AOSIP branch ten for OnePlus 7T and I am not able to complete the build using the command make api-stubs-docs-update-current-api

I had a few modules that were reported missing and following @TheHardGamer 's advice I went to AOSIP's Git page and downloaded branch ten for the following modules.

libsquashfs_util -> placed into systems/extras/squashfs_utils
fec & verity -> placed into systems/extras/verity
libtestUtil -> placed into test/vts-testcase/kernel/testUtil
simpleperf-inferno -> The systems/extras/simpleperf/scripts was not present so i copied the entire scripts folder from Git
libc++_darwin -> I did git clone https://android.googlesource.com/platform/prebuilts/clang/host/darwin-x86 -b android-10.0.0_r40 on the prebuilts/clang/host folder

Then I was faced with the following error:

internal error: Could not find a supported mac sdk: ["10.10" "10.11" "10.12" "10.13" "10.14"]
internal error: Could not find a supported mac sdk: ["10.10" "10.11" "10.12" "10.13" "10.14"]

So i followed the advice from Could not find a supported mac sdk: ["10.10" "10.11" "10.12" "10.13"]

edited the following file /Volumes/android/build/soong/cc/config/x86_darwin_host.go

added "11.1" into the following snippet in the file

darwinSupportedSdkVersions = []string{
    "10.10",
    "10.11",
    "10.12",
    "10.13",
    "10.14",
    "11.1",
}

Then the following error occured

error: system/extras/simpleperf/Android.bp:72:1: module "libsimpleperf_elf_read" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/read_apk.cpp" does not exist
error: system/extras/simpleperf/Android.bp:72:1: module "libsimpleperf_elf_read" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/read_elf.cpp" does not exist
error: system/extras/simpleperf/Android.bp:72:1: module "libsimpleperf_elf_read" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/utils.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/dso.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/event_attr.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/event_type.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/perf_regs.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/read_apk.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/read_elf.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/record.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/record_file_reader.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/report_sample.proto" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/thread_tree.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/tracing.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/utils.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/nonlinux_support/nonlinux_support.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/nonlinux_support/include" does not exist

Which I then copied the entire simpleperf folder from branch ten over my simpleperf folder.

I was then met with the following error

art/build/Android.common.mk:51: warning: unsupported HOST_ARCH=x86_64
[ 24% 116/481] including device_oneplus_hotdogb/overlay/packages/apps/overlays/NoCutoutOverlay/Android.mk ...
FAILED: 
build/make/core/base_rules.mk:324: error: device_oneplus_hotdogb/overlay/packages/apps/overlays/NoCutoutOverlay: MODULE.TARGET.APPS.NoCutoutOverlay already defined by device/oneplus/hotdogb/overlay/packages/apps/overlays/NoCutoutOverlay.
10:15:54 ckati failed with: exit status 1

I removed the device_oneplus_hotdogb folder.

After that I encountered this error.

FAILED: out/soong/.intermediates/system/core/base/libbase/darwin_x86_64_static/obj/system/core/base/cmsg.o
 prebuilts/clang/host/darwin-x86/clang-r353983c1/bin/clang++ -c -Isystem/core/base  -fPIC -funwind-tables -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.8 -DMACOSX_DEPLOYMENT_TARGET=10.8 -m64 -integrated-as -fstack-protector-strong -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -no-canonical-prefixes -DNDEBUG -UDEBUG -fno-exceptions -Wno-multichar -O2 -g -fno-strict-aliasing -D__compiler_offsetof=__builtin_offsetof -faddrsig -Wimplicit-fallthrough -Werror=int-conversion -Wno-reserved-id-macro -Wno-format-pedantic -Wno-unused-command-line-argument -fcolor-diagnostics -Wno-zero-as-null-pointer-constant -Wno-sign-compare -Wno-defaulted-function-deleted -Wno-inconsistent-missing-override   -Isystem/core/base/include -Iexternal/libcxx/include -Iexternal/libcxxabi/include -Isystem/core/liblog/include -Isystem/core/include -Isystem/media/audio/include -Ihardware/libhardware/include -Ihardware/libhardware_legacy/include -Ihardware/ril/include -Iframeworks/native/include -Iframeworks/native/opengl/include -Iframeworks/av/include  -Ilibnativehelper/include_jni -Wall -Werror -Wextra -D_FILE_OFFSET_BITS=64 -target x86_64-apple-darwin -B/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin -DANDROID_STRICT -fPIC -D_USING_LIBCXX -std=gnu++17 -Wsign-promo -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -Wno-thread-safety-negative -Wno-gnu-include-next  -Wexit-time-destructors  -D_LIBCPP_DISABLE_AVAILABILITY -nostdinc++ -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=address-of-temporary -Werror=return-type -Wno-tautological-constant-compare -Wno-tautological-type-limit-compare -Wno-tautological-unsigned-enum-zero-compare -Wno-tautological-unsigned-zero-compare -Wno-c++98-compat-extra-semi -Wno-return-std-move-in-c++11 -MD -MF out/soong/.intermediates/system/core/base/libbase/darwin_x86_64_static/obj/system/core/base/cmsg.o.d -o out/soong/.intermediates/system/core/base/libbase/darwin_x86_64_static/obj/system/core/base/cmsg.o system/core/base/cmsg.cpp
system/core/base/cmsg.cpp:36:21: error: use of undeclared identifier 'PAGE_SIZE'
  if (cmsg_space >= PAGE_SIZE) {
                    ^
system/core/base/cmsg.cpp:78:21: error: use of undeclared identifier 'PAGE_SIZE'
  if (cmsg_space >= PAGE_SIZE) {
                    ^

Should I attempt to define the page_size? if yes, how do i decide on the size? or am i missing a header file somewhere?

Thank you.

3 Answers3

3

I'm attempting to compile AOSP on an M1 Mac, and I've ran into this issue before. The way I solved it was by adding

#ifndef PAGE_SIZE
#define PAGE_SIZE (size_t)(sysconf(_SC_PAGESIZE))
#endif

in /system/core/base/cmsg.cpp

UPDATE: Just in case someone else is trying to compile Android on M1 Macs, it's entirely possible, and not too difficult to achieve. The next issue you will run into is similar to this:

external/python/cpython2/Modules/getpath.c:414:50: error: incompatible pointer types passing 'unsigned long *' to parameter of type 'uint32_t *' (aka 'unsigned int *') [-Werror,-Wincompatible-pointer-types]
     else if(0 == _NSGetExecutablePath(progpath, &nsexeclength) && progpath[0] == SEP)
                                                 ^~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach-o/dyld.h:98:54: note: passing argument to parameter 'bufsize' here
extern int _NSGetExecutablePath(char* buf, uint32_t* bufsize)                 __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0);
                                                     ^
1 error generated.
16:29:38 ninja failed with: exit status 1

You can solve this in external/python/cpython2/Modules/getpath.c by finding

#ifdef __APPLE__
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
    uint32_t nsexeclength = MAXPATHLEN;
#else
    unsigned long nsexeclength = MAXPATHLEN;
#endif
#endif

and changing it to

#ifdef __APPLE__
    uint32_t nsexeclength = MAXPATHLEN;
#endif

Next you might run into an issue about sed. The solution is to install gsed from homebrew as detailed here How do I fix "sed: illegal option -- r" in macOS Sierra Android build? .

These are not proper solutions that can be contributed to the AOSP, but they will work for local compilation. I have managed to compile 2 variations of AOSP using these changes. Hope this helps :)

0

The list of supported Mac sdk versions is there for a reason. Yes, you can add yours to the list and hope for the best, but you're likely to hit issues like you did.

Since Google develops Android on Linux, your best bet is to just install some Linux distribution on virtual machine and just compile there. Don't get me wrong, I'm not saying it's impossible to build on Mac. It's just asking for trouble (and that's fine if you're an expert).

twasilczyk
  • 186
  • 4
0

UPDATE THIS ANSWER:

Replace external/python/cpython2/Modules/getpath.c

#ifdef __APPLE__
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
    uint32_t nsexeclength = MAXPATHLEN;
#else
    unsigned long nsexeclength = MAXPATHLEN;
#endif
#endif

with

#ifdef __APPLE__
    uint32_t nsexeclength = MAXPATHLEN;
#endif

Do the same in external/python/cpython3/Modules/getpath.c:

#ifdef __APPLE__
    char execpath[MAXPATHLEN + 1];
    uint32_t nsexeclength = Py_ARRAY_LENGTH(execpath) - 1;
#endif
i_82
  • 335
  • 5
  • 7