1*58b9f456SAndroid Build Coastguard Worker======================================================= 2*58b9f456SAndroid Build Coastguard WorkerCapturing configuration information during installation 3*58b9f456SAndroid Build Coastguard Worker======================================================= 4*58b9f456SAndroid Build Coastguard Worker 5*58b9f456SAndroid Build Coastguard Worker.. contents:: 6*58b9f456SAndroid Build Coastguard Worker :local: 7*58b9f456SAndroid Build Coastguard Worker 8*58b9f456SAndroid Build Coastguard WorkerThe Problem 9*58b9f456SAndroid Build Coastguard Worker=========== 10*58b9f456SAndroid Build Coastguard Worker 11*58b9f456SAndroid Build Coastguard WorkerCurrently the libc++ supports building the library with a number of different 12*58b9f456SAndroid Build Coastguard Workerconfiguration options. Unfortunately all of that configuration information is 13*58b9f456SAndroid Build Coastguard Workerlost when libc++ is installed. In order to support "persistent" 14*58b9f456SAndroid Build Coastguard Workerconfigurations libc++ needs a mechanism to capture the configuration options 15*58b9f456SAndroid Build Coastguard Workerin the INSTALLED headers. 16*58b9f456SAndroid Build Coastguard Worker 17*58b9f456SAndroid Build Coastguard Worker 18*58b9f456SAndroid Build Coastguard WorkerDesign Goals 19*58b9f456SAndroid Build Coastguard Worker============ 20*58b9f456SAndroid Build Coastguard Worker 21*58b9f456SAndroid Build Coastguard Worker* The solution should not INSTALL any additional headers. We don't want an extra 22*58b9f456SAndroid Build Coastguard Worker #include slowing everybody down. 23*58b9f456SAndroid Build Coastguard Worker 24*58b9f456SAndroid Build Coastguard Worker* The solution should not unduly affect libc++ developers. The problem is limited 25*58b9f456SAndroid Build Coastguard Worker to installed versions of libc++ and the solution should be as well. 26*58b9f456SAndroid Build Coastguard Worker 27*58b9f456SAndroid Build Coastguard Worker* The solution should not modify any existing headers EXCEPT during installation. 28*58b9f456SAndroid Build Coastguard Worker It makes developers lives harder if they have to regenerate the libc++ headers 29*58b9f456SAndroid Build Coastguard Worker every time they are modified. 30*58b9f456SAndroid Build Coastguard Worker 31*58b9f456SAndroid Build Coastguard Worker* The solution should not make any of the libc++ headers dependent on 32*58b9f456SAndroid Build Coastguard Worker files generated by the build system. The headers should be able to compile 33*58b9f456SAndroid Build Coastguard Worker out of the box without any modification. 34*58b9f456SAndroid Build Coastguard Worker 35*58b9f456SAndroid Build Coastguard Worker* The solution should not have ANY effect on users who don't need special 36*58b9f456SAndroid Build Coastguard Worker configuration options. The vast majority of users will never need this so it 37*58b9f456SAndroid Build Coastguard Worker shouldn't cost them. 38*58b9f456SAndroid Build Coastguard Worker 39*58b9f456SAndroid Build Coastguard Worker 40*58b9f456SAndroid Build Coastguard WorkerThe Solution 41*58b9f456SAndroid Build Coastguard Worker============ 42*58b9f456SAndroid Build Coastguard Worker 43*58b9f456SAndroid Build Coastguard WorkerWhen you first configure libc++ using CMake we check to see if we need to 44*58b9f456SAndroid Build Coastguard Workercapture any options. If we haven't been given any "persistent" options then 45*58b9f456SAndroid Build Coastguard Workerwe do NOTHING. 46*58b9f456SAndroid Build Coastguard Worker 47*58b9f456SAndroid Build Coastguard WorkerOtherwise we create a custom installation rule that modifies the installed __config 48*58b9f456SAndroid Build Coastguard Workerheader. The rule first generates a dummy "__config_site" header containing the required 49*58b9f456SAndroid Build Coastguard Worker#defines. The contents of the dummy header are then prepended to the installed 50*58b9f456SAndroid Build Coastguard Worker__config header. By manually prepending the files we avoid the cost of an 51*58b9f456SAndroid Build Coastguard Workerextra #include and we allow the __config header to be ignorant of the extra 52*58b9f456SAndroid Build Coastguard Workerconfiguration all together. An example "__config" header generated when 53*58b9f456SAndroid Build Coastguard Worker-DLIBCXX_ENABLE_THREADS=OFF is given to CMake would look something like: 54*58b9f456SAndroid Build Coastguard Worker 55*58b9f456SAndroid Build Coastguard Worker.. code-block:: cpp 56*58b9f456SAndroid Build Coastguard Worker 57*58b9f456SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 58*58b9f456SAndroid Build Coastguard Worker // 59*58b9f456SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 60*58b9f456SAndroid Build Coastguard Worker // 61*58b9f456SAndroid Build Coastguard Worker // This file is dual licensed under the MIT and the University of Illinois Open 62*58b9f456SAndroid Build Coastguard Worker // Source Licenses. See LICENSE.TXT for details. 63*58b9f456SAndroid Build Coastguard Worker // 64*58b9f456SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 65*58b9f456SAndroid Build Coastguard Worker 66*58b9f456SAndroid Build Coastguard Worker #ifndef _LIBCPP_CONFIG_SITE 67*58b9f456SAndroid Build Coastguard Worker #define _LIBCPP_CONFIG_SITE 68*58b9f456SAndroid Build Coastguard Worker 69*58b9f456SAndroid Build Coastguard Worker /* #undef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE */ 70*58b9f456SAndroid Build Coastguard Worker /* #undef _LIBCPP_HAS_NO_STDIN */ 71*58b9f456SAndroid Build Coastguard Worker /* #undef _LIBCPP_HAS_NO_STDOUT */ 72*58b9f456SAndroid Build Coastguard Worker #define _LIBCPP_HAS_NO_THREADS 73*58b9f456SAndroid Build Coastguard Worker /* #undef _LIBCPP_HAS_NO_MONOTONIC_CLOCK */ 74*58b9f456SAndroid Build Coastguard Worker /* #undef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS */ 75*58b9f456SAndroid Build Coastguard Worker 76*58b9f456SAndroid Build Coastguard Worker #endif 77*58b9f456SAndroid Build Coastguard Worker // -*- C++ -*- 78*58b9f456SAndroid Build Coastguard Worker //===--------------------------- __config ---------------------------------===// 79*58b9f456SAndroid Build Coastguard Worker // 80*58b9f456SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 81*58b9f456SAndroid Build Coastguard Worker // 82*58b9f456SAndroid Build Coastguard Worker // This file is dual licensed under the MIT and the University of Illinois Open 83*58b9f456SAndroid Build Coastguard Worker // Source Licenses. See LICENSE.TXT for details. 84*58b9f456SAndroid Build Coastguard Worker // 85*58b9f456SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 86*58b9f456SAndroid Build Coastguard Worker 87*58b9f456SAndroid Build Coastguard Worker #ifndef _LIBCPP_CONFIG 88*58b9f456SAndroid Build Coastguard Worker #define _LIBCPP_CONFIG 89