Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[deps/zlib] Android arm64 build fails due to missing cpufeatures library #46749

Closed
nappy opened this issue Feb 20, 2023 · 10 comments
Closed

[deps/zlib] Android arm64 build fails due to missing cpufeatures library #46749

nappy opened this issue Feb 20, 2023 · 10 comments
Labels
android Issues and PRs related to the android platform. build Issues and PRs related to build files or the CI.

Comments

@nappy
Copy link
Contributor

nappy commented Feb 20, 2023

Version

18.14.1

Platform

debian bullseye (host) / android arm64 (target)

Subsystem

deps

What steps will reproduce the bug?

Cross compile node for android / arm64.

How often does it reproduce? Is there a required condition?

Consistently

What is the expected behavior?

The build succeeding

What do you see instead?

/home/nappy/ndks/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android23-clang -o /home/nappy/node/out/Release/obj.target/zlib/deps/zlib/crc32.o ../deps/zlib/crc32.c '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-DNODE_OPENSSL_CONF_NAME=nodejs_conf' '-DICU_NO_USER_DATA_OVERRIDE' '-D__STDC_FORMAT_MACROS' '-DHAVE_HIDDEN' '-DUSE_FILE32API' '-D__ARM_NEON__' '-DDEFLATE_SLIDE_HASH_NEON' '-DINFLATE_CHUNK_READ_64LE' '-DINFLATE_CHUNK_SIMD_NEON' '-DADLER32_SIMD_NEON' '-DCRC32_ARMV8_CRC32' '-DARMV8_OS_ANDROID' '-D_GLIBCXX_USE_C99_MATH' -I../deps/zlib  -msign-return-address=all -Wall -Wextra -Wno-unused-parameter -Wno-implicit-fallthrough -O3 -fno-omit-frame-pointer -fPIC  -MMD -MF /home/nappy/node/out/Release/.deps//home/nappy/node/out/Release/obj.target/zlib/deps/zlib/crc32.o.d.raw -I/home/nappy/openssl/include -fPIE -fPIC -c
../deps/zlib/cpu_features.c:42:10: fatal error: 'cpu-features.h' file not found
#include <cpu-features.h>
         ^~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [deps/zlib/zlib.target.mk:119: /home/nappy/node/out/Release/obj.target/zlib/deps/zlib/cpu_features.o] Error 1
make[1]: *** Waiting for unfinished jobs....

Additional information

18.12.1 was building without issues in the same environment

References: @lpinca #45589
References: @richardlau #45589

@nappy nappy changed the title Android arm64 build fails due to missing cpufeatures library [deps/zlib] Android arm64 build fails due to missing cpufeatures library Feb 20, 2023
@nappy
Copy link
Contributor Author

nappy commented Feb 20, 2023

I think this part of BUILD.gn is missing in the corresponding gyp file:

if (is_android) {
    import("//build/config/android/config.gni")
    if (defined(android_ndk_root) && android_ndk_root != "") {
      deps += [ "//third_party/android_ndk:cpu_features" ]
    } else {
      assert(false, "CPU detection requires the Android NDK")
    }
  }

@bnoordhuis
Copy link
Member

V8 basically slurps in this file: https://chromium.googlesource.com/android_ndk/+/refs/heads/main/sources/android/cpufeatures/cpu-features.c

I don't really have a suggestion on how to fix that except by vendoring it and the other files except Android.mk in that directory. PR or better solution welcome, I'd say.

@bnoordhuis bnoordhuis added build Issues and PRs related to build files or the CI. android Issues and PRs related to the android platform. labels Feb 20, 2023
@nappy
Copy link
Contributor Author

nappy commented Feb 21, 2023

@bnoordhuis My proposal would be to source it locally from $ANDROID_NDK_ROOT/sources/android/cpufeatures. I am not aware how to acces ENV variables in the gyp file though.

@bnoordhuis
Copy link
Member

You can't access them directly but you can from configure.py, which then writes config.gypi.

However, that adds one more moving part to the build and moving parts have a tendency to break down, hence my suggestion of vendoring.

That file seems to change only very infrequently; last two changes were 2 and 5 years ago, respectively.

@richardlau
Copy link
Member

FWIW android_configure.py already knows the path to the Android NDK:

if not os.path.exists(sys.argv[1]) or not os.listdir(sys.argv[1]):
print("\033[91mError: \033[0m" + "Invalid path to the Android NDK")
sys.exit(1)
if int(sys.argv[2]) < 24:
print("\033[91mError: \033[0m" + "Android SDK version must be at least 24 (Android 7.0)")
sys.exit(1)
android_ndk_path = sys.argv[1]

@nappy
Copy link
Contributor Author

nappy commented Feb 21, 2023

@bnoordhuis If it does not cause legal issues I think vendoring would be the most stable option indeed. The library itself seems deprecated anyways so I would not expect updates either. For me it is not quite clear how v8 sources it though, because it is not committed there either. Is the build system downloading it or how does it work with v8 deps?

@bnoordhuis
Copy link
Member

Yes, chromium's fetch tool downloads it when you clone the v8 repo.

@bnoordhuis
Copy link
Member

@nappy do you want to send a pull request or can I close this?

@bnoordhuis bnoordhuis closed this as not planned Won't fix, can't repro, duplicate, stale Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Issues and PRs related to the android platform. build Issues and PRs related to build files or the CI.
Projects
None yet
Development

No branches or pull requests

4 participants
@nappy @bnoordhuis @richardlau and others