<div dir="ltr">Hi All,<div><br></div><div>Configuring a compiler to target or build libc++ is tricky. It often requires suppressing and rebuilding large parts of the CC1 compiler invocation. Doing this manually can be prohibitive, even for experienced users. Even doing it programmatically is hard and requires a lot of code because of the sheer number of configurations libc++ support.</div><div><br></div><div>These problems affects both libc++ and it's users. For libc++ CMake's statefulness makes it hard to generate the two different sets of flags needed to initially build the library and then to target it afterwards.</div><div><br></div><div>Therefore I'm proposing a utility called `libcxx-config.py` which, similar to llvm-config, when queried will output the flags required to compile and link libc++. The tool will have two main purposes:<br></div><div><br></div><div>(1) Generating the compile and link flags required to <b>use the just-built libc++ library</b>.</div><div>(2) Generating the compile and link flags required to <b>build the libc++ dylib.</b></div><div><b><br></b></div><div>The goals for `libcxx-config.py` are:</div><div><br></div><div>(1) Reduce duplicate configuration logic between the CMake and test-suite.</div><div>(2) Allow non-CMake users to correctly generate the flags required to build libc++. (Ex buildit)</div><div>(3) Make it easier for projects, including libc++, to correctly configure to target the just-built libc++.</div><div>(4) Allow the creation of a `test-libc++` tool which can compile and link test programs against libc++ (Often needed when debugging test suite failures).</div><div><br></div><div>Would anybody else have a need for this? Are there use cases anybody would like to see supported?</div><div><br></div><div>Some example usages I imagine for `libcxx-config.py` are:</div><div><br></div><div>  # Get the compile flags needed to build libc++.dylib</div><div>  $ libcxx-config.py --building-library --compile-flags --compiler=clang++ --cxx-abi-library=libcxxabi</div><div>  </div><div>  # output: -nostdinc++ -I <libcxx-headers> -D_LIBCPP_BUILDING_LIBRARY -DLIBCXX_BUILDING_LIBCXXABI -std=c++11 -fvisibility-inlines-hidden</div><div><br></div><div>  # Get the link flags needed to use libc++ with the specified compiler</div><div>  $ libcxx-config.py --link-flags --compiler=g++</div><div>  </div><div>  # Output: -nodefaultlibs -L <path> -Wl,-rpath <path> -lc++experimental -lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc</div><div><br></div><div>Any feedback is appreciated.</div><div><br></div><div>/Eric</div><div><br></div></div>