This is an archive of the discontinued LLVM Phabricator instance.

[DynamicLibrary] Fix build on musl libc
ClosedPublic

Authored by loladiro on Oct 25 2017, 9:53 AM.

Details

Summary

On musl libc, stdin/out/err are defined as FILE* const globals, and their address is not implicitly convertible to void *
(or at least gcc 6 doesn't allow it). Add an explicit cast to fix that problem.

Diff Detail

Event Timeline

loladiro created this revision.Oct 25 2017, 9:53 AM
krytarowski edited edge metadata.Oct 25 2017, 12:00 PM

What's the error message?

error: cannot initialize return object of type 'void *' with an rvalue of type 'FILE *const *' (aka '_IO_FILE *const *')
    EXPLICIT_SYMBOL(stderr);
    ^~~~~~~~~~~~~~~~~~~~~~~

This change looks fine. I'm unsure whether the proper style is to go for cast<void*>() or similar.

dim accepted this revision.Oct 26 2017, 3:40 AM

LGTM.

This revision is now accepted and ready to land.Oct 26 2017, 3:40 AM
This revision was automatically updated to reflect the committed changes.
elram reopened this revision.Feb 19 2018, 2:02 AM
elram added a subscriber: elram.

Has this been tested?
The modified EXPLICIT_SYMBOL is #undef at line 102 and does not apply to the EXPLICIT_SYMBOL(stdin/out/err) below.

This revision is now accepted and ready to land.Feb 19 2018, 2:02 AM
krytarowski resigned from this revision.Dec 23 2018, 12:14 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 7 2019, 5:20 AM
Herald added a subscriber: hiraditya. · View Herald Transcript