From 19f0e47f9dc10087a67f3db2db84f0e4cab8bd50 Mon Sep 17 00:00:00 2001
From: Axel Naumann <Axel.Naumann@cern.ch>
Date: Tue, 10 Apr 2018 15:32:28 +0200
Subject: [PATCH] Relax stdlib ABI check; fix libc++ ABI check.

---
 .../cling/lib/Interpreter/IncrementalParser.cpp    | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/interpreter/cling/lib/Interpreter/IncrementalParser.cpp b/interpreter/cling/lib/Interpreter/IncrementalParser.cpp
index 5a1683eff40..5c051b7db71 100644
--- a/interpreter/cling/lib/Interpreter/IncrementalParser.cpp
+++ b/interpreter/cling/lib/Interpreter/IncrementalParser.cpp
@@ -62,12 +62,15 @@ namespace {
 #if defined(__GLIBCXX__)
     #define CLING_CXXABI_VERS       std::to_string(__GLIBCXX__)
     const char* CLING_CXXABI_NAME = "__GLIBCXX__";
+    static constexpr bool CLING_CXXABI_BACKWARDCOMP = true;
 #elif defined(_LIBCPP_VERSION)
-    #define CLING_CXXABI_VERS       std::to_string(_LIBCPP_VERSION)
-    const char* CLING_CXXABI_NAME = "_LIBCPP_VERSION";
+    #define CLING_CXXABI_VERS       std::to_string(_LIBCPP_ABI_VERSION)
+    const char* CLING_CXXABI_NAME = "_LIBCPP_ABI_VERSION";
+    static constexpr bool CLING_CXXABI_BACKWARDCOMP = false;
 #elif defined(_CRT_MSVCP_CURRENT)
     #define CLING_CXXABI_VERS        _CRT_MSVCP_CURRENT
     const char* CLING_CXXABI_NAME = "_CRT_MSVCP_CURRENT";
+    static constexpr bool CLING_CXXABI_BACKWARDCOMP = false;
 #else
     #error "Unknown platform for ABI check";
 #endif
@@ -75,10 +78,15 @@ namespace {
     const std::string CurABI = Interp.getMacroValue(CLING_CXXABI_NAME);
     if (CurABI == CLING_CXXABI_VERS)
       return true;
+    if (CLING_CXXABI_BACKWARDCOMP && CurABI < CLING_CXXABI_VERS) {
+       // Backward compatible ABIs allow us to interpret old headers
+       // against a newer stdlib.so.
+       return true;
+    }
 
     cling::errs() <<
       "Warning in cling::IncrementalParser::CheckABICompatibility():\n"
-      "  Possible C++ standard library mismatch, compiled with "
+      "  Possible C++ standard library ABI mismatch, compiled with "
       << CLING_CXXABI_NAME << " '" << CLING_CXXABI_VERS << "'\n"
       "  Extraction of runtime standard library version was: '"
       << CurABI << "'\n";
-- 
GitLab