Skip to content

[libc++abi] Fix test on Android #74753

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
Dec 13, 2023
Merged

Conversation

maksfb
Copy link
Contributor

@maksfb maksfb commented Dec 7, 2023

Follow up to #72727. The added test could not be executed on Android.

Follow up to llvm#72727. The added test could not be executed on Android.
@maksfb maksfb added the libc++abi libc++abi C++ Runtime Library. Not libc++. label Dec 7, 2023
@maksfb maksfb requested review from MaskRay and ldionne December 7, 2023 19:42
@maksfb maksfb requested a review from a team as a code owner December 7, 2023 19:42
@llvmbot
Copy link
Member

llvmbot commented Dec 7, 2023

@llvm/pr-subscribers-libcxxabi

Author: Maksim Panchenko (maksfb)

Changes

Follow up to #72727. The added test could not be executed on Android.


Full diff: https://github.com/llvm/llvm-project/pull/74753.diff

1 Files Affected:

  • (modified) libcxxabi/test/native/x86_64/lpstart-zero.pass.sh.s (+1-1)
diff --git a/libcxxabi/test/native/x86_64/lpstart-zero.pass.sh.s b/libcxxabi/test/native/x86_64/lpstart-zero.pass.sh.s
index ea9dd0104c086..249d243d921ea 100644
--- a/libcxxabi/test/native/x86_64/lpstart-zero.pass.sh.s
+++ b/libcxxabi/test/native/x86_64/lpstart-zero.pass.sh.s
@@ -2,7 +2,7 @@
 # RUN: %t.exe
 
 # REQUIRES: linux && target={{x86_64-.+}}
-# UNSUPPORTED: no-exceptions
+# UNSUPPORTED: no-exceptions || android
 
 ## Check that libc++abi works correctly when LPStart address is explicitly set
 ## to zero.

@maksfb
Copy link
Contributor Author

maksfb commented Dec 7, 2023

Unrelated ibm-libc++-shared.cfg.in test failed on AIX.

@maksfb
Copy link
Contributor Author

maksfb commented Dec 11, 2023

Checked that all test failures are unrelated.

@ldionne
Copy link
Member

ldionne commented Dec 11, 2023

@rprichard Can you take a look? I suspect the right thing to do here is not to mark the test as UNSUPPORTED, since that would simply reduce your test coverage.

@rprichard
Copy link
Contributor

I think the UNSUPPORTED is correct here.

The RUN: %t.exe line should be RUN: %{exec} %t.exe, but after fixing that, the test will still fail on Android because of the -no-pie compile option in RUN: %{cxx} %{flags} %s %{link_flags} -no-pie -o %t.exe. The Android dynamic loader rejects non-PIE executables:

"./t.tmp.exe": error: Android 5.0 and later only support position-independent executables (-fPIE).

I can't make the executable work as a PIE because the address of the landing pad would require a dynamic relocation, which can't be applied because .gcc_except_table is read-only. Making the section writable instead is rejected by the assembler:

/llvm/libcxxabi/test/native/x86_64/lpstart-zero.pass.sh.s:76:2: error: changed section flags for .gcc_except_table, expected: 0x2
        .section        .gcc_except_table,"aw",@progbits
        ^

Also:

.Lexception0:
	.byte	3                               # @LPStart Encoding = udata4
  .long 0
	.byte	155                             # @TType Encoding = indirect pcrel sdata4
	.uleb128 .Lttbase0-.Lttbaseref0
.Lttbaseref0:
	.byte	11                              # Call site Encoding = udata4

DW_EH_PE_udata4 is 3 but DW_EH_PE_sdata4 is 11. I think the comment on the call side encoding is wrong -- it should be sdata4 instead of udata4.

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

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

Thanks for the analysis @rprichard!

@maksfb Can you please address those comments?

@@ -2,7 +2,7 @@
# RUN: %t.exe

# REQUIRES: linux && target={{x86_64-.+}}
# UNSUPPORTED: no-exceptions
# UNSUPPORTED: no-exceptions || android
Copy link
Member

Choose a reason for hiding this comment

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

@rprichard What would be the right target-based annotation here?

// UNSUPPORTED: target={{.+}}-android{{.+}}

?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would change the suffix to use {{.*}} to also match a triple without the version number suffix, just for completeness:

// UNSUPPORTED: target={{.+}}-android{{.*}}

The two unversioned Android annotations I currently see in libc++ also use a {{.*}} suffix:

// XFAIL: LIBCXX-ANDROID-FIXME && target={{i686|x86_64}}-{{.+}}-android{{.*}}
// UNSUPPORTED: target=i686-{{.+}}-android{{.*}}

@maksfb
Copy link
Contributor Author

maksfb commented Dec 12, 2023

Fixed the execution command and the comment. The test is supposed to be non-PIE, which excludes it from testing on Android.

@ldionne ldionne merged commit 2c5fe14 into llvm:main Dec 13, 2023
@maksfb maksfb deleted the gh-fix-android-build branch January 30, 2024 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++abi libc++abi C++ Runtime Library. Not libc++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants