Author: ericwf Date: Fri Oct 28 01:06:50 2016 New Revision: 285382 URL: http://llvm.org/viewvc/llvm-project?rev=285382&view=rev Log: Add __libcpp_version file and __libcpp_library_version function.
This patch does two seperate things. First it adds a file called "__libcpp_version" which only contains the current libc++ version (currently 4000). This file is not intended for use as a header. This file is used by Clang in order to easily determine the installed libc++ version. This allows Clang to enable/disable certain language features only when the library supports them. The second change is the addition of _LIBCPP_LIBRARY_VERSION macro, which returns the version of the installed dylib since it may be different than the headers. Added: libcxx/trunk/include/__libcpp_version libcxx/trunk/src/libcpp_version.cpp libcxx/trunk/test/libcxx/version.pass.cpp Modified: libcxx/trunk/include/__config libcxx/trunk/lib/abi/CHANGELOG.TXT libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=285382&r1=285381&r2=285382&view=diff ============================================================================== --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Fri Oct 28 01:06:50 2016 @@ -908,6 +908,13 @@ extern "C" void __sanitizer_annotate_con #define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF #endif +_LIBCPP_BEGIN_NAMESPACE_STD +_LIBCPP_FUNC_VIS _LIBCPP_WEAK int __libcpp_library_version(); +_LIBCPP_END_NAMESPACE_STD + +#define _LIBCPP_LIBRARY_VERSION \ + (_VSTD::__libcpp_library_version ? _VSTD::__libcpp_library_version() : -1) + #endif // __cplusplus #endif // _LIBCPP_CONFIG Added: libcxx/trunk/include/__libcpp_version URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__libcpp_version?rev=285382&view=auto ============================================================================== --- libcxx/trunk/include/__libcpp_version (added) +++ libcxx/trunk/include/__libcpp_version Fri Oct 28 01:06:50 2016 @@ -0,0 +1 @@ +4000 \ No newline at end of file Modified: libcxx/trunk/lib/abi/CHANGELOG.TXT URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CHANGELOG.TXT?rev=285382&r1=285381&r2=285382&view=diff ============================================================================== --- libcxx/trunk/lib/abi/CHANGELOG.TXT (original) +++ libcxx/trunk/lib/abi/CHANGELOG.TXT Fri Oct 28 01:06:50 2016 @@ -16,6 +16,11 @@ New entries should be added directly bel Version 4.0 ----------- +* rTBD - Add __libcpp_library_version + + all platforms + ------------- + Symbol added: _ZNSt3__124__libcpp_library_versionEv * r285101 - Add -fvisibility-inlines-hidden when building libc++. Modified: libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist?rev=285382&r1=285381&r2=285382&view=diff ============================================================================== --- libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist (original) +++ libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist Fri Oct 28 01:06:50 2016 @@ -1141,6 +1141,7 @@ {'type': 'FUNC', 'name': '_ZNSt3__121recursive_timed_mutexD1Ev'} {'type': 'FUNC', 'name': '_ZNSt3__121recursive_timed_mutexD2Ev'} {'type': 'FUNC', 'name': '_ZNSt3__121undeclare_no_pointersEPcm'} +{'type': 'FUNC', 'name': '_ZNSt3__124__libcpp_library_versionEv'} {'type': 'FUNC', 'name': '_ZNSt3__125__num_get_signed_integralIlEET_PKcS3_Rji'} {'type': 'FUNC', 'name': '_ZNSt3__125__num_get_signed_integralIxEET_PKcS3_Rji'} {'type': 'FUNC', 'name': '_ZNSt3__125notify_all_at_thread_exitERNS_18condition_variableENS_11unique_lockINS_5mutexEEE'} Added: libcxx/trunk/src/libcpp_version.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/libcpp_version.cpp?rev=285382&view=auto ============================================================================== --- libcxx/trunk/src/libcpp_version.cpp (added) +++ libcxx/trunk/src/libcpp_version.cpp Fri Oct 28 01:06:50 2016 @@ -0,0 +1,14 @@ +#include "__config" + +_LIBCPP_BEGIN_NAMESPACE_STD + +// Test that _LIBCPP_VERSION and __libcpp_version are in sync. +// The __libcpp_version file stores only a number representing the libc++ +// version so it can be easily parsed by clang. +static_assert(_LIBCPP_VERSION == +#include "__libcpp_version" + , "version file does not match"); + +int __libcpp_library_version() { return _LIBCPP_VERSION; } + +_LIBCPP_END_NAMESPACE_STD Added: libcxx/trunk/test/libcxx/version.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/version.pass.cpp?rev=285382&view=auto ============================================================================== --- libcxx/trunk/test/libcxx/version.pass.cpp (added) +++ libcxx/trunk/test/libcxx/version.pass.cpp Fri Oct 28 01:06:50 2016 @@ -0,0 +1,29 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Test the _LIBCPP_VERSION and _LIBCPP_LIBRARY_VERSION macros + +#include <__config> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION must be defined +#endif + +#ifndef _LIBCPP_LIBRARY_VERSION +#error _LIBCPP_LIBRARY_VERSION must be defined +#endif + +#include <cassert> + +int main() { + assert(_LIBCPP_VERSION == _LIBCPP_LIBRARY_VERSION); + assert(std::__libcpp_library_version); + assert(_LIBCPP_LIBRARY_VERSION == std::__libcpp_library_version()); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits