This is an archive of the discontinued LLVM Phabricator instance.

[openmp] fix a compile error on musl-libc

Authored by zlei on Sep 29 2016, 11:29 PM.



Function strerror_r() has different signatures in different implementations of libc: glibc's version returns a char*, while BSDs and musl return a int. libomp unconditionally assumes glibc on Linux and thus fails to compile against musl-libc. This patch addresses this issue.

Diff Detail


Event Timeline

zlei updated this revision to Diff 72983.Sep 29 2016, 11:29 PM
zlei retitled this revision from to [openmp] fix a compile error on musl-libc.
zlei updated this object.
zlei added a reviewer: jcownie.
zlei added a subscriber: cfe-commits.
Hahnfeld edited subscribers, added: openmp-commits; removed: cfe-commits.Sep 29 2016, 11:31 PM
mgorny added a subscriber: mgorny.
mgorny added inline comments.
812 ↗(On Diff #72983)

Hmm, wouldn't it be reasonable to just check for GLIBC? I think non-Linux (Hurd?) glibc would have the same signature, wouldn't it?

zlei added inline comments.Oct 7 2016, 6:52 AM
812 ↗(On Diff #72983)

Agree. Although I don't know if anyone is really building libomp on those niche platforms.

jlpeyton edited edge metadata.Oct 7 2016, 9:19 AM

_GNU_SOURCE has to be defined for the char* version to be used (which we do by sending in -D_GNU_SOURCE during compilation). So have the #if be

#if defined(__GLIBC__) && defined(_GNU_SOURCE)
zlei updated this revision to Diff 74008.Oct 7 2016, 6:46 PM
zlei edited edge metadata.
This revision is now accepted and ready to land.Oct 11 2016, 11:52 PM
jlpeyton accepted this revision.Oct 18 2016, 9:31 AM
jlpeyton edited edge metadata.

LGTM too.

@zlei, I presume you still don't have commit access, so I'll commit it for you, and backport it on Gentoo end. Thanks for working on this.

This revision was automatically updated to reflect the committed changes.