From f9a46ad22a544bdc9c1c0d87ea69d43e215c630c Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Mon, 27 Sep 2021 07:24:16 -0700 Subject: [PATCH] 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 Part-of: --- meson.build | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/meson.build b/meson.build index d1606a7824a2d..fa37127612c35 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',