[cfe-commits] Hacks and kluges for libc++ on OS X 10.6
Howard Hinnant
hhinnant at apple.com
Thu Dec 20 15:15:34 PST 2012
On Dec 20, 2012, at 5:54 PM, Alex Rosenberg <alexr at leftfield.org> wrote:
> On Dec 20, 2012, at 2:42 PM, Howard Hinnant wrote:
>
>> On Dec 20, 2012, at 5:39 PM, Charles Davis <cdavis5x at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> By request, this is a collection of patches I have to make libc++ work on 10.6. They're all hacks and kluges to make libc++ work better on 10.6, except the change the libc++'s makefile (to not chown(8) the just-installed headers to root:wheel). I made that one so I can install the headers for use in Clang's tests as part of a self-host build.
>>>
>>> I don't expect Howard to OK these. I'm posting them here for the benefit of users stuck on 10.6 who want to build libc++. Do with them what you will, and use at your own risk.
>>>
>>> Chip
>>
>> Talk about a walk down memory lane... Yeah, those were a pita. :-) Putting these on the command line with -D is another option available to users.
>
> Could you elaborate on why 10.6 patches wouldn't be accepted? I'm using it partially because I need a box that can still run PPC. Bootstrapping Clang and thus lld is my goal for it.
Even with this minor macro patching, libc++ isn't supported on 10.6. Since libc++ wasn't finished at the dawn of time, some time, some OS, had to be the first to support it. And 10.7 is that OS.
Let's look at one of the patches:
> ===================================================================
> --- include/cinttypes (revision 170761)
> +++ include/cinttypes (working copy)
> @@ -235,6 +235,10 @@
> } // std
> */
>
> +#define __STDC_CONSTANT_MACROS
> +#define __STDC_LIMIT_MACROS
> +#define __STDC_FORMAT_MACROS
> +
> #include <__config>
> #include <cstdint>
> #include <inttypes.h>
The apparent need for these macros stem from footnotes in C99. For example:
> 7.8.1 Macros for format specifiers
>
> 1 Each of the following object-like macros(182) expands to a character string literal containing a conversion specifier, ...
>
> 182) C++ implementations should define these macros only when _ _STDC_FORMAT_MACROS is defined
> before <inttypes.h> is included.
However the C++ committee had already decided that this was not a good API for C++ with respect to the similar __STDC_LIMIT_MACROS macros. So I concluded that the right place to fix this problem was in C++11, not in libc++, so I filed this lwg issue:
http://cplusplus.github.com/LWG/lwg-defects.html#984
And I filed internal bug reports against Apple's <inttypes.h> to conform.
And today, I still believe the correct place to deal with this issue is in <inttypes.h> and in the standards documents.
If we were to apply the above patch, it would only work /some/ of the time, not all of the time. Imagine this translation unit sequence:
#include <inttypes.h>
...
#include <cinttypes>
The #define __STDC_FORMAT_MACROS in <cinttypes> would have no impact because the include guards of <inttypes.h> would prevent it from being re-included. (*)
A patch that pretends to support something that is not supported, and that doesn't reliably solve the problem, is not something I want to encourage in libc++. Nevertheless, I would like to thank Charles for making this information accessible. More info is always better.
Howard
(*) Disclaimer: I don't actually have 10.6 handy at the moment. I seem to remember that the macros in question were protected by an include guard. I could be mistaken about that. But still, I believe the issue has been addressed in the correct fashion.
More information about the cfe-commits
mailing list