Accepting request 773990 from home:dimstar:Factory

- Add meson-6614.patch: cmake: Fix crash when no C++ compiler is
  not installed (gh#mesonbuild/meson#6559).

OBS-URL: https://build.opensuse.org/request/show/773990
OBS-URL: https://build.opensuse.org/package/show/devel:tools:building/meson?expand=0&rev=157
This commit is contained in:
Dominique Leuenberger 2020-02-12 19:35:07 +00:00 committed by Git OBS Bridge
parent e35b209d51
commit 982598ce45
3 changed files with 149 additions and 0 deletions

140
meson-6614.patch Normal file
View File

@ -0,0 +1,140 @@
From c6684f3eee34888759171dd790f332cc57f00f60 Mon Sep 17 00:00:00 2001
From: Daniel Mensinger <daniel@mensinger-ka.de>
Date: Wed, 12 Feb 2020 19:23:25 +0100
Subject: [PATCH] cmake: Fix crash when no C++ compiler is not installed (fixes
#6559)
---
mesonbuild/cmake/executor.py | 96 +++++++++++++++++++-----------------
1 file changed, 50 insertions(+), 46 deletions(-)
diff --git a/mesonbuild/cmake/executor.py b/mesonbuild/cmake/executor.py
index c3303ebd6c..7b9edf7b0c 100644
--- a/mesonbuild/cmake/executor.py
+++ b/mesonbuild/cmake/executor.py
@@ -23,6 +23,7 @@
import os
import shutil
import ctypes
+import textwrap
from .. import mlog, mesonlib
from ..mesonlib import PerMachine, Popen_safe, version_compare, MachineChoice
@@ -264,9 +265,12 @@ def choose_compiler(lang: str) -> T.Tuple[str, str]:
if lang in compilers:
exe_list = compilers[lang].get_exelist()
else:
- comp_obj = self.environment.compiler_from_language(lang, MachineChoice.BUILD)
- if comp_obj is not None:
- exe_list = comp_obj.get_exelist()
+ try:
+ comp_obj = self.environment.compiler_from_language(lang, MachineChoice.BUILD)
+ if comp_obj is not None:
+ exe_list = comp_obj.get_exelist()
+ except Exception:
+ pass
if len(exe_list) == 1:
return make_abs(exe_list[0], lang), ''
@@ -278,10 +282,7 @@ def choose_compiler(lang: str) -> T.Tuple[str, str]:
c_comp, c_launcher = choose_compiler('c')
cxx_comp, cxx_launcher = choose_compiler('cpp')
- try:
- fortran_comp, fortran_launcher = choose_compiler('fortran')
- except Exception:
- fortran_comp = fortran_launcher = ''
+ fortran_comp, fortran_launcher = choose_compiler('fortran')
# on Windows, choose_compiler returns path with \ as separator - replace by / before writing to CMAKE file
c_comp = c_comp.replace('\\', '/')
@@ -302,47 +303,50 @@ def choose_compiler(lang: str) -> T.Tuple[str, str]:
cxx_comp_file = comp_dir / 'CMakeCXXCompiler.cmake'
fortran_comp_file = comp_dir / 'CMakeFortranCompiler.cmake'
- if not c_comp_file.is_file():
- c_comp_file.write_text('''# Fake CMake file to skip the boring and slow stuff
-set(CMAKE_C_COMPILER "{}") # Should be a valid compiler for try_compile, etc.
-set(CMAKE_C_COMPILER_LAUNCHER "{}") # The compiler launcher (if presentt)
-set(CMAKE_C_COMPILER_ID "GNU") # Pretend we have found GCC
-set(CMAKE_COMPILER_IS_GNUCC 1)
-set(CMAKE_C_COMPILER_LOADED 1)
-set(CMAKE_C_COMPILER_WORKS TRUE)
-set(CMAKE_C_ABI_COMPILED TRUE)
-set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
-set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
-set(CMAKE_SIZEOF_VOID_P "{}")
-'''.format(c_comp, c_launcher, ctypes.sizeof(ctypes.c_voidp)))
-
- if not cxx_comp_file.is_file():
- cxx_comp_file.write_text('''# Fake CMake file to skip the boring and slow stuff
-set(CMAKE_CXX_COMPILER "{}") # Should be a valid compiler for try_compile, etc.
-set(CMAKE_CXX_COMPILER_LAUNCHER "{}") # The compiler launcher (if presentt)
-set(CMAKE_CXX_COMPILER_ID "GNU") # Pretend we have found GCC
-set(CMAKE_COMPILER_IS_GNUCXX 1)
-set(CMAKE_CXX_COMPILER_LOADED 1)
-set(CMAKE_CXX_COMPILER_WORKS TRUE)
-set(CMAKE_CXX_ABI_COMPILED TRUE)
-set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
-set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP)
-set(CMAKE_SIZEOF_VOID_P "{}")
-'''.format(cxx_comp, cxx_launcher, ctypes.sizeof(ctypes.c_voidp)))
+ if c_comp and not c_comp_file.is_file():
+ c_comp_file.write_text(textwrap.dedent('''\
+ # Fake CMake file to skip the boring and slow stuff
+ set(CMAKE_C_COMPILER "{}") # Should be a valid compiler for try_compile, etc.
+ set(CMAKE_C_COMPILER_LAUNCHER "{}") # The compiler launcher (if presentt)
+ set(CMAKE_C_COMPILER_ID "GNU") # Pretend we have found GCC
+ set(CMAKE_COMPILER_IS_GNUCC 1)
+ set(CMAKE_C_COMPILER_LOADED 1)
+ set(CMAKE_C_COMPILER_WORKS TRUE)
+ set(CMAKE_C_ABI_COMPILED TRUE)
+ set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
+ set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
+ set(CMAKE_SIZEOF_VOID_P "{}")
+ '''.format(c_comp, c_launcher, ctypes.sizeof(ctypes.c_voidp))))
+
+ if cxx_comp and not cxx_comp_file.is_file():
+ cxx_comp_file.write_text(textwrap.dedent('''\
+ # Fake CMake file to skip the boring and slow stuff
+ set(CMAKE_CXX_COMPILER "{}") # Should be a valid compiler for try_compile, etc.
+ set(CMAKE_CXX_COMPILER_LAUNCHER "{}") # The compiler launcher (if presentt)
+ set(CMAKE_CXX_COMPILER_ID "GNU") # Pretend we have found GCC
+ set(CMAKE_COMPILER_IS_GNUCXX 1)
+ set(CMAKE_CXX_COMPILER_LOADED 1)
+ set(CMAKE_CXX_COMPILER_WORKS TRUE)
+ set(CMAKE_CXX_ABI_COMPILED TRUE)
+ set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
+ set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP)
+ set(CMAKE_SIZEOF_VOID_P "{}")
+ '''.format(cxx_comp, cxx_launcher, ctypes.sizeof(ctypes.c_voidp))))
if fortran_comp and not fortran_comp_file.is_file():
- fortran_comp_file.write_text('''# Fake CMake file to skip the boring and slow stuff
-set(CMAKE_Fortran_COMPILER "{}") # Should be a valid compiler for try_compile, etc.
-set(CMAKE_Fortran_COMPILER_LAUNCHER "{}") # The compiler launcher (if presentt)
-set(CMAKE_Fortran_COMPILER_ID "GNU") # Pretend we have found GCC
-set(CMAKE_COMPILER_IS_GNUG77 1)
-set(CMAKE_Fortran_COMPILER_LOADED 1)
-set(CMAKE_Fortran_COMPILER_WORKS TRUE)
-set(CMAKE_Fortran_ABI_COMPILED TRUE)
-set(CMAKE_Fortran_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
-set(CMAKE_Fortran_SOURCE_FILE_EXTENSIONS f;F;fpp;FPP;f77;F77;f90;F90;for;For;FOR;f95;F95)
-set(CMAKE_SIZEOF_VOID_P "{}")
-'''.format(fortran_comp, fortran_launcher, ctypes.sizeof(ctypes.c_voidp)))
+ fortran_comp_file.write_text(textwrap.dedent('''\
+ # Fake CMake file to skip the boring and slow stuff
+ set(CMAKE_Fortran_COMPILER "{}") # Should be a valid compiler for try_compile, etc.
+ set(CMAKE_Fortran_COMPILER_LAUNCHER "{}") # The compiler launcher (if presentt)
+ set(CMAKE_Fortran_COMPILER_ID "GNU") # Pretend we have found GCC
+ set(CMAKE_COMPILER_IS_GNUG77 1)
+ set(CMAKE_Fortran_COMPILER_LOADED 1)
+ set(CMAKE_Fortran_COMPILER_WORKS TRUE)
+ set(CMAKE_Fortran_ABI_COMPILED TRUE)
+ set(CMAKE_Fortran_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
+ set(CMAKE_Fortran_SOURCE_FILE_EXTENSIONS f;F;fpp;FPP;f77;F77;f90;F90;for;For;FOR;f95;F95)
+ set(CMAKE_SIZEOF_VOID_P "{}")
+ '''.format(fortran_comp, fortran_launcher, ctypes.sizeof(ctypes.c_voidp))))
return self.call(args, build_dir, env)

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Feb 12 19:08:54 UTC 2020 - Dominique Leuenberger <dimstar@opensuse.org>
- Add meson-6614.patch: cmake: Fix crash when no C++ compiler is
not installed (gh#mesonbuild/meson#6559).
-------------------------------------------------------------------
Tue Feb 11 08:50:47 UTC 2020 - Frederic Crozat <fcrozat@suse.com>

View File

@ -51,6 +51,8 @@ Patch4: meson-fix-gcc48.patch
Patch5: meson-distutils.patch
# PATCH-FIX-UPSREAM meson-testsuite-boost.patch dimstar@opensuse.org -- https://github.com/mesonbuild/meson/issues/4788
Patch6: meson-testsuite-boost.patch
# PATCH-FIX-UPSTREAM meson-6614.patch dimstar@opensuse.org -- cmake: Fix crash when no C++ compiler is not installed
Patch7: meson-6614.patch
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildRequires: python3-base
@ -174,6 +176,7 @@ This package provides support for meson.build files in Vim.
(cd "test cases/frameworks/1 boost"
%patch6 -p0
)
%patch7 -p1
# Remove static boost tests from "test cases/frameworks/1 boost/".
sed -i "/static/d" test\ cases/frameworks/1\ boost/meson.build