[cfe-dev] [libcxx] Handling multi-platform configuration.

Michael Spencer bigcheesegs at gmail.com
Fri Dec 10 17:33:09 PST 2010


I recently started porting libc++ over to MinGW and have discovered
just how complicated configuration is going to be. Even ignoring
locale, there are huge differences in support and style between MinGW,
the Microsoft C Runtime, POSIX.1-2008 (IEEE Std 1003.1™-2008 (The Open
Group Technical Standard Base Specifications, Issue 7)), and all the
other platforms out there. For example, the version of cerrno I came
up with (attached) that is standard compliant is about 800 lines long
just to properly deal with all the errno.h macros that aren't in the C
standard and various platforms don't define, but C++0x requires. This
is simple compared to some of the other configuration issues we have
to deal with, like locale.

The most common solution to this problem is pre-build configuration
based on the host platform and compiler; however this does not work
well for the standard library because it should be usable with any
supported compiler without rebuilding or specifying extra parameters.
It should always Just Work.

libc++ currently solves a subset of this problem, compiler
differences, with the __config header. This is a manually maintained
header that defines various macros for features that are not
supported. This works currently, but I feel that when we add more
compilers and platforms (and versions thereof) this will become
unmaintainable. Complex configurations like this are why autoconf and
the like were created. However, as stated above, we can't configure at
libc++ build time. It has to be at include time, which means using the
preprocessor.

I propose that instead of trying to write a program in C Preprocessor,
we write it in a real language which generates C Preprocessor for us.
The key difference between this and autoconf is that the generated
__config header file is platform independent. Similar to how no matter
what platform you run tblgen on, you get the same output.

I don't currently have a proposal for what language to actually use
other than something declarative like tablegen. The important part is
that the total effort of maintaining the generator + config is less
than maintaining a C Preprocessor version of the config.

- Michael Spencer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cerrno-pp.patch
Type: application/octet-stream
Size: 19027 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101210/e8fbbcf8/attachment.obj>


More information about the cfe-dev mailing list