Skip to content

Don't redefine asprintf when building for Android #4610

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

Closed
wants to merge 1 commit into from

Conversation

etcwilde
Copy link
Member

Bionic includes a definition and implementation of asprintf. We should
not include our own on Android.

See 'include/stdio.h' and 'libc/stdio/stdio.cpp'

https://android.googlesource.com/platform/bionic/+/refs/heads/master/libc/include/stdio.h#288
https://android.googlesource.com/platform/bionic/+/refs/heads/master/libc/stdio/stdio.cpp#736

Bionic includes a definition and implementation of asprintf. We should
not include our own on Android.

See 'include/stdio.h' and 'libc/stdio/stdio.cpp'
@etcwilde
Copy link
Member Author

@swift-ci please test

@drodriguez
Copy link
Contributor

/cc @buttaface FYI

Copy link
Member

@finagolfin finagolfin left a comment

Choose a reason for hiding this comment

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

LGTM, but maybe the similar #3021 should be merged instead?

@etcwilde
Copy link
Member Author

That works for me too.

@etcwilde
Copy link
Member Author

I should say that it works for me with caveats.
Digging through the macros. It's already defined if you have __USE_GNU enabled, or STDC_WANT_LIB_EXT2 set, so we shouldn't re-declare it in that case. @compnerd will likely have more comments.

@compnerd
Copy link
Member

__STDC_WANT_LIB_EXT2__ is meant to be controlled by the user. However, __USE_GNU also triggers the extensions. Given that the GNU extensions enabled asprintf backdating before Swift, I think that @buttaface's suggestion is the right thing to do - we should simply remove the TARGET_OS_LINUX conditional. However, we should ensure that _GNU_SOURCE is defined (which I believe we do set) before we include stdio.h (or the appropriate header).

@etcwilde etcwilde closed this Jul 8, 2022
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