-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
meson: Fix builds targetting Android
Linking is broken with Meson 0.52 mesonbuild/meson#6057 CLang detection for macOS Catalina's version is broken with Meson 0.49 We keep 0.52 except when targetting Android that we build for 0.49
- Loading branch information
Showing
8 changed files
with
539 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
recipes/build-tools/meson/0001-Fix-msys-1.0-gcc-python-linking.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
From cb19ecebfdce80e4f9475612efef19eb7c1dae94 Mon Sep 17 00:00:00 2001 | ||
From: Cerbero <nacho.garglez@gmail.com> | ||
Date: Mon, 28 Jan 2019 17:39:05 +0100 | ||
Subject: [PATCH 1/1] Fix msys 1-mingw linker compatibility with python | ||
|
||
Old mingw doesn't link correctly with pythonXX.lib in | ||
all cases. | ||
This patch forces to link against pyhthonXX.dll in | ||
case a gcc compiler is being used, even in | ||
Windows platforms. | ||
Note that msys 1.0 platform is detected as windows | ||
instead of 'mingw' | ||
|
||
Please enter the commit message for your changes. Lines starting | ||
--- | ||
mesonbuild/dependencies/misc.py | 11 +++++++---- | ||
mesonbuild/modules/python.py | 10 +++++++--- | ||
2 files changed, 14 insertions(+), 7 deletions(-) | ||
|
||
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py | ||
index 9e0a65a..e88ae98 100644 | ||
--- a/mesonbuild/dependencies/misc.py | ||
+++ b/mesonbuild/dependencies/misc.py | ||
@@ -280,7 +280,6 @@ class ThreadDependency(ExternalDependency): | ||
class Python3Dependency(ExternalDependency): | ||
def __init__(self, environment, kwargs): | ||
super().__init__('python3', environment, None, kwargs) | ||
- | ||
if self.want_cross: | ||
return | ||
|
||
@@ -337,10 +336,14 @@ class Python3Dependency(ExternalDependency): | ||
if pyplat.startswith('win'): | ||
vernum = sysconfig.get_config_var('py_version_nodot') | ||
if self.static: | ||
- libname = 'libpython{}.a'.format(vernum) | ||
+ libpath = Path('libs') / 'libpython{}.a'.format(vernum) | ||
else: | ||
- libname = 'python{}.lib'.format(vernum) | ||
- lib = Path(sysconfig.get_config_var('base')) / 'libs' / libname | ||
+ comp =self.get_compiler() | ||
+ if comp.id is "gcc": | ||
+ libpath = 'python{}.dll'.format(vernum) | ||
+ else: | ||
+ libpath = Path('libs') / 'python{}.lib'.format(vernum) | ||
+ lib = Path(sysconfig.get_config_var('base')) / libpath | ||
elif pyplat == 'mingw': | ||
if self.static: | ||
libname = sysconfig.get_config_var('LIBRARY') | ||
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py | ||
index 9cfbd6f..84d71a6 100644 | ||
--- a/mesonbuild/modules/python.py | ||
+++ b/mesonbuild/modules/python.py | ||
@@ -183,10 +183,14 @@ class PythonDependency(ExternalDependency): | ||
if self.platform.startswith('win'): | ||
vernum = self.variables.get('py_version_nodot') | ||
if self.static: | ||
- libname = 'libpython{}.a'.format(vernum) | ||
+ libpath = Path('libs') / 'libpython{}.a'.format(vernum) | ||
else: | ||
- libname = 'python{}.lib'.format(vernum) | ||
- lib = Path(self.variables.get('base')) / 'libs' / libname | ||
+ comp =self.get_compiler() | ||
+ if comp.id is "gcc": | ||
+ libpath = 'python{}.dll'.format(vernum) | ||
+ else: | ||
+ libpath = Path('libs') / 'python{}.lib'.format(vernum) | ||
+ lib = Path(self.variables.get('base')) / libpath | ||
elif self.platform == 'mingw': | ||
if self.static: | ||
libname = self.variables.get('LIBRARY') | ||
-- | ||
2.16.1.windows.1 | ||
|
37 changes: 37 additions & 0 deletions
37
recipes/build-tools/meson/0001-compilers-Fix-bitcode-and-other-options-for-objc-cod.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
From b7b651c8db5063b7ed6de08595a3c456573610b0 Mon Sep 17 00:00:00 2001 | ||
From: Nirbheek Chauhan <nirbheek@centricular.com> | ||
Date: Tue, 18 Jun 2019 12:10:55 +0530 | ||
Subject: [PATCH] compilers: Fix bitcode and other options for objc code | ||
|
||
We were setting the base options for the Objective-C compiler | ||
manually, due to which options such as b_bitcode and b_ndebug were not | ||
getting set at all. | ||
|
||
The base options here are the same as for C code with the Clang | ||
compiler, so just use the same inherited list. | ||
--- | ||
mesonbuild/compilers/objc.py | 1 - | ||
mesonbuild/compilers/objcpp.py | 1 - | ||
2 files changed, 2 deletions(-) | ||
|
||
diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py | ||
index 5b2b517f..7f3431c9 100644 | ||
--- a/mesonbuild/compilers/objc.py | ||
+++ b/mesonbuild/compilers/objc.py | ||
@@ -68,4 +68,3 @@ class ClangObjCCompiler(ClangCompiler, ObjCCompiler): | ||
self.warn_args = {'1': default_warn_args, | ||
'2': default_warn_args + ['-Wextra'], | ||
'3': default_warn_args + ['-Wextra', '-Wpedantic']} | ||
- self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage'] | ||
diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py | ||
index e1b7a7dc..4a8aa51d 100644 | ||
--- a/mesonbuild/compilers/objcpp.py | ||
+++ b/mesonbuild/compilers/objcpp.py | ||
@@ -69,4 +69,3 @@ class ClangObjCPPCompiler(ClangCompiler, ObjCPPCompiler): | ||
self.warn_args = {'1': default_warn_args, | ||
'2': default_warn_args + ['-Wextra'], | ||
'3': default_warn_args + ['-Wextra', '-Wpedantic']} | ||
- self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage'] | ||
-- | ||
2.21.0 | ||
|
159 changes: 159 additions & 0 deletions
159
recipes/build-tools/meson/0001-find_library-Check-arch-of-libraries-on-Darwin.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
From a4e29ebfc4911fd3139cc76e51dbd44456085886 Mon Sep 17 00:00:00 2001 | ||
From: Nirbheek Chauhan <nirbheek@centricular.com> | ||
Date: Tue, 29 Jan 2019 16:12:35 +0530 | ||
Subject: [PATCH 1/2] find_library: Check arch of libraries on Darwin | ||
|
||
macOS provides the tool `lipo` to check the archs supported by an | ||
object (executable, static library, dylib, etc). This is especially | ||
useful for fat archives, but it also helps with thin archives. | ||
|
||
Without this, the linker will fail to link to the library we mistakenly | ||
'found' like so: | ||
|
||
ld: warning: ignoring file /path/to/libfoo.a, missing required architecture armv7 in file /path/to/libfoo.a | ||
--- | ||
mesonbuild/backend/ninjabackend.py | 5 +-- | ||
mesonbuild/compilers/c.py | 27 ++++++++--- | ||
mesonbuild/mesonlib.py | 18 ++++++++ | ||
run_tests.py | 1 + | ||
run_unittests.py | 72 +++++++++++++++++------------- | ||
5 files changed, 84 insertions(+), 39 deletions(-) | ||
|
||
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py | ||
index 493fc0dd..9b215b2f 100644 | ||
--- a/mesonbuild/backend/ninjabackend.py | ||
+++ b/mesonbuild/backend/ninjabackend.py | ||
@@ -2347,15 +2347,14 @@ rule FORTRAN_DEP_HACK%s | ||
target_args = self.build_target_link_arguments(linker, target.link_whole_targets) | ||
return linker.get_link_whole_for(target_args) if len(target_args) else [] | ||
|
||
- @staticmethod | ||
@lru_cache(maxsize=None) | ||
- def guess_library_absolute_path(linker, libname, search_dirs, patterns): | ||
+ def guess_library_absolute_path(self, linker, libname, search_dirs, patterns): | ||
for d in search_dirs: | ||
for p in patterns: | ||
trial = CCompiler._get_trials_from_pattern(p, d, libname) | ||
if not trial: | ||
continue | ||
- trial = CCompiler._get_file_from_list(trial) | ||
+ trial = CCompiler._get_file_from_list(self.environment, trial) | ||
if not trial: | ||
continue | ||
# Return the first result | ||
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py | ||
index c0cd0bcd..376de2b1 100644 | ||
--- a/mesonbuild/compilers/c.py | ||
+++ b/mesonbuild/compilers/c.py | ||
@@ -27,6 +27,7 @@ from . import compilers | ||
from ..mesonlib import ( | ||
EnvironmentException, MesonException, version_compare, Popen_safe, listify, | ||
for_windows, for_darwin, for_cygwin, for_haiku, for_openbsd, | ||
+ darwin_get_object_archs | ||
) | ||
from .c_function_attributes import C_FUNC_ATTRIBUTES | ||
|
||
@@ -979,10 +980,27 @@ class CCompiler(Compiler): | ||
return [f.as_posix()] | ||
|
||
@staticmethod | ||
- def _get_file_from_list(files): | ||
+ def _get_file_from_list(env, files): | ||
+ ''' | ||
+ We just check whether the library exists. We can't do a link check | ||
+ because the library might have unresolved symbols that require other | ||
+ libraries. On macOS we check if the library matches our target | ||
+ architecture. | ||
+ ''' | ||
+ if not env.machines.host.is_darwin(): | ||
+ for f in files: | ||
+ if os.path.isfile(f): | ||
+ return f | ||
+ # Run `lipo` and check if the library supports the arch we want | ||
for f in files: | ||
- if os.path.isfile(f): | ||
+ if not os.path.isfile(f): | ||
+ continue | ||
+ archs = darwin_get_object_archs(f) | ||
+ if archs and env.machines.host.cpu_family in archs: | ||
return f | ||
+ else: | ||
+ mlog.debug('Rejected {}, supports {} but need {}' | ||
+ .format(f, archs, env.machines.host.cpu_family)) | ||
return None | ||
|
||
@functools.lru_cache() | ||
@@ -1023,10 +1041,7 @@ class CCompiler(Compiler): | ||
trial = self._get_trials_from_pattern(p, d, libname) | ||
if not trial: | ||
continue | ||
- # We just check whether the library exists. We can't do a link | ||
- # check because the library might have unresolved symbols that | ||
- # require other libraries. | ||
- trial = self._get_file_from_list(trial) | ||
+ trial = self._get_file_from_list(env, trial) | ||
if not trial: | ||
continue | ||
return [trial] | ||
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py | ||
index 8454d79d..7155a112 100644 | ||
--- a/mesonbuild/mesonlib.py | ||
+++ b/mesonbuild/mesonlib.py | ||
@@ -461,6 +461,24 @@ def exe_exists(arglist): | ||
pass | ||
return False | ||
|
||
+lru_cache(maxsize=None) | ||
+def darwin_get_object_archs(objpath): | ||
+ ''' | ||
+ For a specific object (executable, static library, dylib, etc), run `lipo` | ||
+ to fetch the list of archs supported by it. Supports both thin objects and | ||
+ 'fat' objects. | ||
+ ''' | ||
+ _, stdo, stderr = Popen_safe(['lipo', '-archs', objpath]) | ||
+ if not stdo: | ||
+ mlog.debug('lipo {}: {}'.format(objpath, stderr)) | ||
+ return None | ||
+ # Convert from lipo-style archs to meson-style CPUs | ||
+ stdo = stdo.replace('i386', 'x86') | ||
+ # Add generic name for armv7 and armv7s | ||
+ if 'armv7' in stdo: | ||
+ stdo += ' arm' | ||
+ return stdo.split() | ||
+ | ||
def detect_vcs(source_dir): | ||
vcs_systems = [ | ||
dict(name = 'git', cmd = 'git', repo_dir = '.git', get_rev = 'git describe --dirty=+', rev_regex = '(.*)', dep = '.git/logs/HEAD'), | ||
-- | ||
2.17.2 (Apple Git-113) | ||
|
||
|
||
From 71a0ce7a1f9219dbf9d50d2008f679cd7c18f2a7 Mon Sep 17 00:00:00 2001 | ||
From: Nirbheek Chauhan <nirbheek@centricular.com> | ||
Date: Wed, 30 Jan 2019 15:30:36 +0530 | ||
Subject: [PATCH 2/2] macos: lipo from older xcode does not support -archs | ||
|
||
--- | ||
mesonbuild/mesonlib.py | 3 ++- | ||
1 file changed, 2 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py | ||
index 7155a112..2fca187c 100644 | ||
--- a/mesonbuild/mesonlib.py | ||
+++ b/mesonbuild/mesonlib.py | ||
@@ -468,10 +468,11 @@ def darwin_get_object_archs(objpath): | ||
to fetch the list of archs supported by it. Supports both thin objects and | ||
'fat' objects. | ||
''' | ||
- _, stdo, stderr = Popen_safe(['lipo', '-archs', objpath]) | ||
+ _, stdo, stderr = Popen_safe(['lipo', '-info', objpath]) | ||
if not stdo: | ||
mlog.debug('lipo {}: {}'.format(objpath, stderr)) | ||
return None | ||
+ stdo = stdo.rsplit(': ', 1)[1] | ||
# Convert from lipo-style archs to meson-style CPUs | ||
stdo = stdo.replace('i386', 'x86') | ||
# Add generic name for armv7 and armv7s | ||
-- | ||
2.17.2 (Apple Git-113) | ||
|
25 changes: 25 additions & 0 deletions
25
recipes/build-tools/meson/0001-macos-lipo-outputs-aarch64-as-arm64-fix-it.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
From 2963c8775e91ee0cea9fd21dbcb92ac0476dc887 Mon Sep 17 00:00:00 2001 | ||
From: Nirbheek Chauhan <nirbheek@centricular.com> | ||
Date: Fri, 1 Feb 2019 13:29:37 +0530 | ||
Subject: [PATCH] macos: lipo outputs aarch64 as arm64, fix it | ||
|
||
Or we'll reject arm64 objects as invalid when building for aarch64 | ||
--- | ||
mesonbuild/mesonlib.py | 1 + | ||
1 file changed, 1 insertion(+) | ||
|
||
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py | ||
index 939b4cb1..540fcdca 100644 | ||
--- a/mesonbuild/mesonlib.py | ||
+++ b/mesonbuild/mesonlib.py | ||
@@ -475,6 +475,7 @@ def darwin_get_object_archs(objpath): | ||
stdo = stdo.rsplit(': ', 1)[1] | ||
# Convert from lipo-style archs to meson-style CPUs | ||
stdo = stdo.replace('i386', 'x86') | ||
+ stdo = stdo.replace('arm64', 'aarch64') | ||
# Add generic name for armv7 and armv7s | ||
if 'armv7' in stdo: | ||
stdo += ' arm' | ||
-- | ||
2.20.1 | ||
|
27 changes: 27 additions & 0 deletions
27
recipes/build-tools/meson/0001-meson-Add-a-quick-hack-to-support-VS2019.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
From db6157bd3d21b1e807fe918e5a352b216660d548 Mon Sep 17 00:00:00 2001 | ||
From: Nirbheek Chauhan <nirbheek@centricular.com> | ||
Date: Wed, 17 Apr 2019 18:54:26 +0530 | ||
Subject: [PATCH] meson: Add a quick-hack to support VS2019 | ||
|
||
Proper support is already upstream in 0.50.1, but it's too close to | ||
the 1.16 release to bump to that. | ||
--- | ||
mesonbuild/compilers/c.py | 2 ++ | ||
1 file changed, 2 insertions(+) | ||
|
||
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py | ||
index 655dfb3..d47694e 100644 | ||
--- a/mesonbuild/compilers/c.py | ||
+++ b/mesonbuild/compilers/c.py | ||
@@ -1563,6 +1563,8 @@ class VisualStudioCCompiler(CCompiler): | ||
return '14.0' # (Visual Studio 2015) | ||
elif version < 1920: | ||
return '14.1' # (Visual Studio 2017) | ||
+ elif version < 1930: | ||
+ return '14.2' # (Visual Studio 2017) | ||
return None | ||
|
||
def get_default_include_dirs(self): | ||
-- | ||
2.20.1.windows.1 | ||
|
31 changes: 31 additions & 0 deletions
31
recipes/build-tools/meson/0001-ninja-backend-Quote-args-to-compiler-rules.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
From e61d4cbbc9c67416af83e812606b6ef7bcb79eab Mon Sep 17 00:00:00 2001 | ||
From: Nirbheek Chauhan <nirbheek@centricular.com> | ||
Date: Tue, 25 Jun 2019 10:24:43 +0530 | ||
Subject: [PATCH] ninja backend: Quote args to compiler rules | ||
|
||
These must be quoted in the same way as args in each compile line. | ||
This is not needed in 0.50 anymore because we don't add compiler args | ||
directly to the compiler rule there. | ||
|
||
This is needed to correctly quote arguments added through c_args in | ||
the cross file. | ||
--- | ||
mesonbuild/backend/ninjabackend.py | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py | ||
index f49649be..de178b38 100644 | ||
--- a/mesonbuild/backend/ninjabackend.py | ||
+++ b/mesonbuild/backend/ninjabackend.py | ||
@@ -1599,7 +1599,7 @@ rule FORTRAN_DEP_HACK%s | ||
command_template = ' command = {executable} $ARGS {cross_args} {dep_args} {output_args} {compile_only_args} $in\n' | ||
command = command_template.format( | ||
executable=' '.join([ninja_quote(i) for i in compiler.get_exelist()]), | ||
- cross_args=' '.join(cross_args), | ||
+ cross_args=' '.join([quote_func(i) for i in cross_args]), | ||
dep_args=' '.join(quoted_depargs), | ||
output_args=' '.join(compiler.get_output_args('$out')), | ||
compile_only_args=' '.join(compiler.get_compile_only_args()) | ||
-- | ||
2.21.0 | ||
|
Oops, something went wrong.