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

[BUG] Invalid enum value in sysroot/usr/include/android/hardware_buffer.h for 32-bit architectures #2082

Closed
klzgrad opened this issue Oct 6, 2024 · 2 comments
Labels

Comments

@klzgrad
Copy link

klzgrad commented Oct 6, 2024

Description

When building Chromium for 32-bit platforms (including x86 and armv7) using Clang 20 (llvmorg-20-init-1009-g7088a5ed-10), Clang reports errors in the hardware_buffer.h header provided by NDK:

../../third_party/llvm-build/Release+Asserts/bin/clang++ ... --target=i686-linux-android24 -m32 -mfpmath=sse -msse3 -std=c++20 --sysroot=../../third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot -c ../../base/android/scoped_hardware_buffer_handle.cc
In file included from ../../base/android/scoped_hardware_buffer_handle.cc:7:
In file included from ../../base/android/android_hardware_buffer_compat.h:8:
../../third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:322:42: error: expression is not an integral constant expression
  322 |     AHARDWAREBUFFER_USAGE_FRONT_BUFFER = 1UL << 32,
      |                                          ^~~~~~~~~
../../third_party/android_toolchain/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/hardware_buffer.h:322:46: note: shift count 32 >= width of type 'unsigned long' (32 bits)
  322 |     AHARDWAREBUFFER_USAGE_FRONT_BUFFER = 1UL << 32,
      |                                              ^
1 error generated.

Clang 19 did not report this error, but as it stands the code 1UL << 32 is indeed invalid for 32-bit architectures.

Clang no longer reports errors once I patched it to 1ULL << 32.

Affected versions

r27

Canary version

No response

Host OS

Linux

Host OS version

Debian trixie/sid

Affected ABIs

armeabi-v7a, x86

Build system

Other (specify below)

Other build system

No response

minSdkVersion

24

Device API level

No response

@klzgrad klzgrad added the bug label Oct 6, 2024
@enh-google
Copy link
Collaborator

(see also the UINT*_C() and INT*_C() macros in <stdint.h> [https://pubs.opengroup.org/onlinepubs/009696899/basedefs/stdint.h.html] if you want simple advice for the API reviewers and/or want to stick with UL for LP64 and only change ILP32 to ULL in this case.)

@DanAlbert
Copy link
Member

This has already been fixed in Android, just not in r27, because r27 doesn't have a clang that new. Updating the sysroot after release is a pretty risky thing, and because of #2081 we know it would break things, so we can't do that.

This is only a problem for projects that are using a ToT clang without also using a ToT Android sysroot. If you need to do that, you should also be using an up-to-date sysroot. You can get one of those from ci.android.com. The "ndk" target of the "aosp-main" branch has an artifact named "ndk_platform.tar.bz2". You need to use that instead of the NDK if you're not using the NDK's Clang.

@DanAlbert DanAlbert closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants