This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Convert Solaris support library to C++ to fix -std=c++11 build
ClosedPublic

Authored by mgorny on Oct 10 2016, 5:56 AM.

Details

Summary

Convert the Solaris xlocale.c compatibility library from plain C to C++,
and fix the prototype for declared functions in order to fix the build
failures caused by the addition of -std=c++11 to LIBCXX_COMPILE_FLAGS.
The additional flag got propagated to the C file, resulting in error
with strict compilers.

Diff Detail

Repository
rL LLVM

Event Timeline

mgorny updated this revision to Diff 74119.Oct 10 2016, 5:56 AM
mgorny retitled this revision from to [libcxx] [CMake] Build Solaris compat as separate C lib, to avoid -std= issues.
mgorny updated this object.
mgorny added reviewers: EricWF, theraven.
mgorny added a subscriber: cfe-commits.
theraven edited edge metadata.Oct 10 2016, 6:06 AM

It sounds as if the bug here is either that the .c files are being treated as c++, or that we're sticking -std=c++{whatever} in CFLAGS as well as CXXFLAGS. This is probably the bug that should be fixed.

It sounds as if the bug here is either that the .c files are being treated as c++, or that we're sticking -std=c++{whatever} in CFLAGS as well as CXXFLAGS. This is probably the bug that should be fixed.

We're sticking them into LIBCXX_COMPILE_FLAGS, to be more precise. And this is the only C file in the whole libcxx, so I'm not sure if anyone even remember about that ;-).

EricWF edited edge metadata.Oct 14 2016, 4:15 AM

Why not just compile the sources files as C++ by changing their extensions? This change seems all kinds of wrong because we're throwing away *all* of our flags, including things like -m32 or -target <cross-compile-target>.

Why not just compile the sources files as C++ by changing their extensions? This change seems all kinds of wrong because we're throwing away *all* of our flags, including things like -m32 or -target <cross-compile-target>.

That's another option. Having a lot of other problems on Solaris at the time, using a separate library was simpler to test. I will try this alternative today.

mgorny updated this revision to Diff 74666.Oct 14 2016, 6:03 AM
mgorny retitled this revision from [libcxx] [CMake] Build Solaris compat as separate C lib, to avoid -std= issues to [libcxx] Convert Solaris support library to C++ to fix -std=c++11 build .
mgorny updated this object.
mgorny edited edge metadata.

Ok, here's an updated patch that changes the code to C++. Since C++ is more strict than C, I also had to remove some conflicting declarations -- and while at it, I updated the header to avoid any collisions and redundancy on SunOS 5.11 (OpenIndiana). I don't have access to any older system, and considering that the support for SunOS in clang is still incomplete, I don't think it important to support older systems.

mgorny planned changes to this revision.Oct 17 2016, 12:19 PM

Damn it, it seems that SunOS isn't actually exposing some functions. I need to work on this further, and figure out WTF.

mgorny updated this revision to Diff 74996.Oct 18 2016, 7:07 AM
mgorny updated this object.

Ok, here's a minimal change necessary to fix the build. I'm not touching anything else not to break it ;-).

Looks like a much better change to me.

joerg accepted this revision.Oct 18 2016, 9:12 AM
joerg added a reviewer: joerg.
joerg added a subscriber: joerg.

Commit the prototype fix separately, please.

This revision is now accepted and ready to land.Oct 18 2016, 9:12 AM
This revision was automatically updated to reflect the committed changes.

Thanks for the review. Committed the prototype fix first, and followed it by the C++ conversion.