Skip to content

[android] Split demangling tests for Android 32/64 bits. #34554

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

Conversation

drodriguez
Copy link
Contributor

@drodriguez drodriguez commented Nov 3, 2020

size_t differs in 32 bit platforms like Android ARMv7 where it is
unsigned int instead of unsigned long. The mangling changes one of the
characters.

The original tests are disabled in Android, and they are replicated in
different files for Android, with both the 32 and the 64 bits versions
of the mangling and the function signatures.

The original tests are not modified in order to avoid complicated checks
to avoid platforms like iphonesimulator-i386, which is a 32 bit
platform, but still uses unsigned long as the underlying type for
size_t

Both tests started failing after #34057 landed in the Android 32 bits CI
machines.

@drodriguez
Copy link
Contributor Author

@swift-ci please test

@drodriguez
Copy link
Contributor Author

I checked myself in an ARMv7 build targeting Android, and a Linux x86-64 build. The tests seem to work in both cases. I am curious about other Darwin 32 bit platforms (ARMv7k, right?), because it seemed that it didn't fail the test, but all the references I can find seem to imply that size_t was 32 bits in 32 bits platforms, but maybe the new platforms use other rules and the change is not as easy.

@varungandhi-apple
Copy link
Contributor

I'm also surprised that this didn't fail for 32-bit Darwin, that's weird.

@swift-ci
Copy link
Contributor

swift-ci commented Nov 3, 2020

Build failed
Swift Test OS X Platform
Git Sha - 3a3b4c5470d4da6aeda7b5684de2ce770f681eac

@swift-ci
Copy link
Contributor

swift-ci commented Nov 3, 2020

Build failed
Swift Test Linux Platform
Git Sha - 3a3b4c5470d4da6aeda7b5684de2ce770f681eac

@drodriguez
Copy link
Contributor Author

So it seems that iphonesimulator-i386 (32 bits, right?) indeed uses unsigned long as its size_t type, and fails the modified test case.

Do we need to use size_t for the test? Can we use unsigned long long or short? That should be 64 bits wide in both pointer sizes (or 16 bits for short). What are we trying to exactly test with these tests?

@varungandhi-apple
Copy link
Contributor

There are certain types which are imported in Swift in a particular way, and then when you try to map that Swift type to a C type, you don't get a round-trip, you get something else. To preserve this information of the original C type, we have the additional cType: key in the @convention(c).

size_t is one of those few types (it is special-cased to be imported as Int, which gets re-mapped to a signed type), so using types like (unsigned) long long or (unsigned) short wouldn't work.

I think for this test case, it would be fine to disable it for 32-bit Android. You could add a separate test case for 32-bit Android (I think that would be easier to follow than having conditional compilation here, though I'm not 100% sure).

`size_t` differs in 32 bit platforms like Android ARMv7 where it is
`unsigned int` instead of `unsigned long`. The mangling changes one of the
characters.

The original tests are disabled in Android, and they are replicated in
different files for Android, with both the 32 and the 64 bits versions
of the mangling and the function signatures.

The original tests are not modified in order to avoid complicated checks
to avoid platforms like iphonesimulator-i386, which is a 32 bit
platform, but still uses `unsigned long` as the underlying type for
`size_t`

Both tests started failing after swiftlang#34057 landed in the Android 32 bits CI
machines.
@drodriguez drodriguez force-pushed the android-size-is-int-in-32-bits branch from 3a3b4c5 to 8962f5c Compare November 4, 2020 03:40
@drodriguez
Copy link
Contributor Author

@swift-ci please test

@drodriguez drodriguez changed the title [android] Split demangling tests for 32 and 64 bits. [android] Split demangling tests for Android 32/64 bits. Nov 4, 2020
@swift-ci
Copy link
Contributor

swift-ci commented Nov 4, 2020

Build failed
Swift Test OS X Platform
Git Sha - 8962f5c

@drodriguez
Copy link
Contributor Author

@swift-ci please test macOS platform

@swift-ci
Copy link
Contributor

swift-ci commented Nov 4, 2020

Build failed
Swift Test OS X Platform
Git Sha - 8962f5c

@drodriguez
Copy link
Contributor Author

@swift-ci please test macOS platform

@swift-ci
Copy link
Contributor

swift-ci commented Nov 4, 2020

Build failed
Swift Test OS X Platform
Git Sha - 8962f5c

@CodaFi
Copy link
Contributor

CodaFi commented Nov 4, 2020

Failure is still unrelated

@swift-ci smoke test macOS

@drodriguez drodriguez merged commit 526fe57 into swiftlang:main Nov 5, 2020
@drodriguez drodriguez deleted the android-size-is-int-in-32-bits branch November 5, 2020 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants