Mesa (main): meson: Allow mismatching RTTI for MSVC

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Nov 19 16:09:18 UTC 2021


Module: Mesa
Branch: main
Commit: f9a46ad22a544bdc9c1c0d87ea69d43e215c630c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f9a46ad22a544bdc9c1c0d87ea69d43e215c630c

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Mon Sep 27 07:24:16 2021 -0700

meson: Allow mismatching RTTI for MSVC

This might be safe to relax to all Windows compilers, but I didn't
test Clang or MinGW, so scoping to MSVC for now. For MSVC, this is
safe to mismatch, because the vftables are emitted into all objects
with "pick largest," and the definition with RTTI is larger than the
one without. This is different than the Itanium ABI, which only emits
one copy of the typeinfo in the object which defines the key method.

Acked-by: Eric Engestrom <eric at engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13064>

---

 meson.build | 41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/meson.build b/meson.build
index d1606a7824a..fa37127612c 100644
--- a/meson.build
+++ b/meson.build
@@ -1734,28 +1734,29 @@ if with_llvm
     error('SWR requires LLVM draw support.')
   endif
 
-  # LLVM can be built without rtti, turning off rtti changes the ABI of C++
-  # programs, so we need to build all C++ code in mesa without rtti as well to
-  # ensure that linking works.
-  #
-  # In meson 0.51.0 we can use cmake to find LLVM in addittion to meson's
-  # builtin llvm-config based finder. A new generic variable getter method
-  # has also been added, so we'll use that if we can, to cover the cmake case.
-  if dep_llvm.type_name() == 'internal'
-    _llvm_rtti = subproject('llvm').get_variable('has_rtti', true)
-  else
-    # The CMake finder will return 'ON', the llvm-config will return 'YES'
-    _llvm_rtti = ['ON', 'YES'].contains(dep_llvm.get_variable(cmake : 'LLVM_ENABLE_RTTI', configtool: 'has-rtti'))
-  endif
-  if _rtti != _llvm_rtti
-    if _llvm_rtti
-      error('LLVM was built with RTTI, cannot build Mesa with RTTI disabled. Remove cpp_rtti disable switch or use LLVM built without LLVM_ENABLE_RTTI.')
+  if cc.get_id() != 'msvc'
+    # LLVM can be built without rtti, turning off rtti changes the ABI of C++
+    # programs, so we need to build all C++ code in mesa without rtti as well to
+    # ensure that linking works. Note that MSVC does handle mismatching RTTI
+    # without issues, so only apply this for other compilers.
+    #
+    # In meson 0.51.0 we can use cmake to find LLVM in addittion to meson's
+    # builtin llvm-config based finder. A new generic variable getter method
+    # has also been added, so we'll use that if we can, to cover the cmake case.
+    if dep_llvm.type_name() == 'internal'
+      _llvm_rtti = subproject('llvm').get_variable('has_rtti', true)
     else
-      error('LLVM was built without RTTI, so Mesa must also disable RTTI. Use an LLVM built with LLVM_ENABLE_RTTI or add cpp_rtti=false.')
+      # The CMake finder will return 'ON', the llvm-config will return 'YES'
+      _llvm_rtti = ['ON', 'YES'].contains(dep_llvm.get_variable(cmake : 'LLVM_ENABLE_RTTI', configtool: 'has-rtti'))
     endif
-  endif
-
-  if cc.get_id() == 'msvc'
+    if _rtti != _llvm_rtti
+      if _llvm_rtti
+        error('LLVM was built with RTTI, cannot build Mesa with RTTI disabled. Remove cpp_rtti disable switch or use LLVM built without LLVM_ENABLE_RTTI.')
+      else
+        error('LLVM was built without RTTI, so Mesa must also disable RTTI. Use an LLVM built with LLVM_ENABLE_RTTI or add cpp_rtti=false.')
+      endif
+    endif
+  else
     # Suppress "/DELAYLOAD:ole32.dll/shell32.dll ignored" warnings that LLVM adds
     add_project_link_arguments(
       '/ignore:4199',



More information about the mesa-commit mailing list