diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-12-09 12:53:10 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-12-13 09:37:47 +0530 |
commit | 82a77609e81a513e04fd08a43f0921743a4b1617 (patch) | |
tree | 88f59ebe9c39c46d5dcba4a835b81d03feb32f80 /mesonbuild/backend/backends.py | |
parent | 0fc4ad2a0bc8f60f0c9336a39cf71746d1dab9b9 (diff) | |
download | meson-82a77609e81a513e04fd08a43f0921743a4b1617.zip meson-82a77609e81a513e04fd08a43f0921743a4b1617.tar.gz meson-82a77609e81a513e04fd08a43f0921743a4b1617.tar.bz2 |
Query the target itself for the dynamic linker
This greatly improves the logic for determining the linker. Previously,
we would completely break if a target contained only extracted objects
and we were using more than one compiler in our project.
This also fixes determination of the linker if our target only contains
generated objc++ sources, and other funky combinations.
Diffstat (limited to 'mesonbuild/backend/backends.py')
-rw-r--r-- | mesonbuild/backend/backends.py | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 91c5b0f..48dfb11 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -235,39 +235,21 @@ class Backend(): self.write_benchmark_file(datafile) return (test_data, benchmark_data) - def determine_linker(self, target, src): + def determine_linker(self, target): + ''' + If we're building a static library, there is only one static linker. + Otherwise, we query the target for the dynamic linker. + ''' if isinstance(target, build.StaticLibrary): if target.is_cross: return self.build.static_cross_linker else: return self.build.static_linker - if target.is_cross: - compilers = self.build.cross_compilers - else: - compilers = self.build.compilers - if len(compilers) == 1: - return compilers[0] - # Currently a bit naive. C++ must - # be linked with a C++ compiler, but - # otherwise we don't care. This will - # become trickier if and when Fortran - # and the like become supported. - cpp = None - for c in compilers: - if c.get_language() == 'cpp': - cpp = c - break - if cpp is not None: - for s in src: - if c.can_compile(s): - return cpp - for c in compilers: - if c.get_language() == 'vala': - continue - for s in src: - if c.can_compile(s): - return c - raise AssertionError("BUG: Couldn't determine linker for sources {!r}".format(src)) + l = target.get_clike_dynamic_linker() + if not l: + m = "Couldn't determine linker for target {!r}" + raise MesonException(m.format(target.name)) + return l def object_filename_from_source(self, target, source): if isinstance(source, mesonlib.File): |