Skip to content

[compiler-rt][AArch64][Android] Use getauxval on Android. #102979

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

Merged
merged 3 commits into from
Aug 30, 2024

Conversation

DanielKristofKiss
Copy link
Member

__getauxval is a libgcc function that doesn't exist on Android.

__getauxval is a libgcc function that doesn't exist on Android.
@DanielKristofKiss
Copy link
Member Author

Calling getauxval on Android is fine since:
https://android-review.googlesource.com/c/platform/bionic/+/836525

The original motivation is broken as compiler-rt does call getauxval a lot from other places as of today.

static _Bool has_sme(void) {
return __getauxval(AT_HWCAP2) & HWCAP2_SME;
}
static _Bool has_sme(void) { return GETAUXVAL(AT_HWCAP2) & HWCAP2_SME; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that I would rather that we inline the use of __getauxval. getauxval is a GNU "standard" interface, but was introduced in glibc only in 2.16. I don't know if anyone is targeting an older glibc, but we can do something like:

Suggested change
static _Bool has_sme(void) { return GETAUXVAL(AT_HWCAP2) & HWCAP2_SME; }
static _Bool has_sme(void) {
#if defined(__GLIBC__) && !__GLIBC_PREREQ(2,16)
unsigned long int auxval = __getauxval(AT_HWCAP2);
#else
unsigned long int auxval = getauxval(AT_HWCAP2);
#endif
return auxval & HWCAP2_SME;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AArch64 support for getauxval just added in 2.17.
Compiler-rt uses getauxval with glibc in multiple places(SLE_Atomic, FMV, Sanitizers), so I don't see the point why use __getauxval only here.
I don't think we need to worry about such a platform that has SME while doesn't have getauxval

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It avoids the macros and allows us to have a single platform agnostic implementation. Over time, we would drop the use of the underscore variant of the function.

Copy link
Collaborator

@sdesmalen-arm sdesmalen-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, I didn't realise this PR was still waiting for review.

@DanielKristofKiss DanielKristofKiss merged commit cd634f5 into llvm:main Aug 30, 2024
7 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 30, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux running on sanitizer-buildbot1 while building compiler-rt at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/3256

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
[379/384] Generating MSAN_INST_GTEST.gtest-all.cc.x86_64.o
[380/384] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64-with-call.o
[381/384] Generating Msan-x86_64-with-call-Test
[382/384] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64.o
[383/384] Generating Msan-x86_64-Test
[383/384] Running compiler_rt regression tests
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 10229 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
TIMEOUT: SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c (10229 of 10229)
******************** TEST 'SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c' FAILED ********************
Exit Code: -9
Timeout: Reached timeout of 900 seconds

Command Output (stderr):
--
RUN: at line 1: /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing  -m64 -funwind-tables  -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp && env HWASAN_OPTIONS=die_after_fork=0  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing -m64 -funwind-tables -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
+ env HWASAN_OPTIONS=die_after_fork=0 /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp

=================================================================
==1809740==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 568 byte(s) in 3 object(s) allocated from:
    #0 0x5835988a93b4 in malloc (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xf93b4)
    #1 0x583598a022fe in operator new(unsigned long) llvm-link
    #2 0x58359889f9a4 in _start (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xef9a4)

Direct leak of 204 byte(s) in 1 object(s) allocated from:
    #0 0x5835988a8f39 in calloc (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xf8f39)
    #1 0x58359898a82b in llvm::safe_calloc(unsigned long, unsigned long) llvm-link
    #2 0x58359889f9a4 in _start (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xef9a4)

Indirect leak of 1320 byte(s) in 28 object(s) allocated from:
    #0 0x5835988a8985 in aligned_alloc (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xf8985)
    #1 0x583598998115 in llvm::allocate_buffer(unsigned long, unsigned long) llvm-link

Indirect leak of 780 byte(s) in 1 object(s) allocated from:
    #0 0x5835988a8f39 in calloc (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xf8f39)
    #1 0x58359898a82b in llvm::safe_calloc(unsigned long, unsigned long) llvm-link

Indirect leak of 160 byte(s) in 1 object(s) allocated from:
    #0 0x5835988a93b4 in malloc (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xf93b4)
    #1 0x583598a022fe in operator new(unsigned long) llvm-link
    #2 0x58359889f9a4 in _start (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xef9a4)

SUMMARY: HWAddressSanitizer: 3032 byte(s) leaked in 34 allocation(s).
HWAddressSanitizer:DEADLYSIGNAL
==1809867==ERROR: HWAddressSanitizer: SEGV on unknown address (pc 0x583598943c18 bp 0x000000010100 sp 0x7ffe85c6d3e8 T1809867)
Step 9 (test compiler-rt symbolizer) failure: test compiler-rt symbolizer (failure)
...
[379/384] Generating MSAN_INST_GTEST.gtest-all.cc.x86_64.o
[380/384] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64-with-call.o
[381/384] Generating Msan-x86_64-with-call-Test
[382/384] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64.o
[383/384] Generating Msan-x86_64-Test
[383/384] Running compiler_rt regression tests
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 10229 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
TIMEOUT: SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c (10229 of 10229)
******************** TEST 'SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c' FAILED ********************
Exit Code: -9
Timeout: Reached timeout of 900 seconds

Command Output (stderr):
--
RUN: at line 1: /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing  -m64 -funwind-tables  -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp && env HWASAN_OPTIONS=die_after_fork=0  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing -m64 -funwind-tables -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
+ env HWASAN_OPTIONS=die_after_fork=0 /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp

=================================================================
==1809740==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 568 byte(s) in 3 object(s) allocated from:
    #0 0x5835988a93b4 in malloc (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xf93b4)
    #1 0x583598a022fe in operator new(unsigned long) llvm-link
    #2 0x58359889f9a4 in _start (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xef9a4)

Direct leak of 204 byte(s) in 1 object(s) allocated from:
    #0 0x5835988a8f39 in calloc (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xf8f39)
    #1 0x58359898a82b in llvm::safe_calloc(unsigned long, unsigned long) llvm-link
    #2 0x58359889f9a4 in _start (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xef9a4)

Indirect leak of 1320 byte(s) in 28 object(s) allocated from:
    #0 0x5835988a8985 in aligned_alloc (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xf8985)
    #1 0x583598998115 in llvm::allocate_buffer(unsigned long, unsigned long) llvm-link

Indirect leak of 780 byte(s) in 1 object(s) allocated from:
    #0 0x5835988a8f39 in calloc (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xf8f39)
    #1 0x58359898a82b in llvm::safe_calloc(unsigned long, unsigned long) llvm-link

Indirect leak of 160 byte(s) in 1 object(s) allocated from:
    #0 0x5835988a93b4 in malloc (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xf93b4)
    #1 0x583598a022fe in operator new(unsigned long) llvm-link
    #2 0x58359889f9a4 in _start (/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xef9a4)

SUMMARY: HWAddressSanitizer: 3032 byte(s) leaked in 34 allocation(s).
HWAddressSanitizer:DEADLYSIGNAL
==1809867==ERROR: HWAddressSanitizer: SEGV on unknown address (pc 0x583598943c18 bp 0x000000010100 sp 0x7ffe85c6d3e8 T1809867)

lemenkov pushed a commit to lemenkov/libyuv that referenced this pull request Oct 15, 2024
This reverts commit 51e2e12.

Reason for revert: The llvm bug fix
llvm/llvm-project#102979 has been rolled into
Chrome in https://chromium-review.googlesource.com/5921462.

Original change's description:
> Do not enable libyuv_use_sme for is_android
>
> Revert the changes to libyuv.gni in commit dfa279f.
>
> The linker error "undefined symbol: __getauxval" referenced by
> sme-abi-init.c:26 on Android, previously reported in
> https://libyuv.g-issues.chromium.org/issues/359006069#comment2, has not
> been fixed yet. See
> https://chromium-review.googlesource.com/c/chromium/src/+/5918245?tab=checks.
>
> Change-Id: I94bd243e2863b9c316909f63f757fd95ec55dc18
> Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5917455
> Reviewed-by: Frank Barchard <[email protected]>

Bug: 359006069
Change-Id: Ic801c1bcb65894fdfe718ba6454669c8623a2e15
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5935026
Reviewed-by: Frank Barchard <[email protected]>
Bot-Commit: Rubber Stamper <[email protected]>
Reviewed-by: George Steed <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants