aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoaLitiuM <goalitium@kapsi.fi>2018-09-12 12:17:11 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2018-09-13 22:07:19 +0300
commit8fa7c29661db94b5cafac2aab53f738df2cdaf99 (patch)
tree204ca47e59338c53a98e3022b75e21ae6af1eda4
parente0d02e2111a39270ba225e130e8a1b2e12fc62fd (diff)
downloadmeson-8fa7c29661db94b5cafac2aab53f738df2cdaf99.zip
meson-8fa7c29661db94b5cafac2aab53f738df2cdaf99.tar.gz
meson-8fa7c29661db94b5cafac2aab53f738df2cdaf99.tar.bz2
D: Fix linker detection when static linker is missing
Fallback to using D compilers as static linkers when no suitable static linker were found.
-rw-r--r--mesonbuild/environment.py14
-rw-r--r--mesonbuild/linkers.py17
2 files changed, 21 insertions, 10 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 9e9b5fc..3a1e1e6 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -15,7 +15,7 @@
import configparser, os, platform, re, shlex, shutil, subprocess
from . import coredata
-from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, LDCLinker
+from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker
from . import mesonlib
from .mesonlib import EnvironmentException, Popen_safe
from . import mlog
@@ -341,7 +341,6 @@ class Environment:
self.vs_static_linker = ['lib']
self.gcc_static_linker = ['gcc-ar']
self.clang_static_linker = ['llvm-ar']
- self.ldc2_static_linker = ['ldc2']
# Various prefixes and suffixes for import libraries, shared libraries,
# static libraries, and executables.
@@ -885,10 +884,11 @@ This is probably wrong, it should always point to the native compiler.''' % evar
# Use llvm-ar if available; needed for LTO
linkers = [self.clang_static_linker, self.default_static_linker]
elif isinstance(compiler, compilers.DCompiler):
+ # Prefer static linkers over linkers used by D compilers
if mesonlib.is_windows():
- linkers = [self.vs_static_linker, self.ldc2_static_linker]
+ linkers = [self.vs_static_linker, compiler.get_linker_exelist()]
else:
- linkers = [self.default_static_linker, self.ldc2_static_linker]
+ linkers = [self.default_static_linker, compiler.get_linker_exelist()]
else:
linkers = [self.default_static_linker]
popen_exceptions = {}
@@ -906,8 +906,12 @@ This is probably wrong, it should always point to the native compiler.''' % evar
return VisualStudioLinker(linker)
if p.returncode == 0 and ('armar' in linker or 'armar.exe' in linker):
return ArmarLinker(linker)
+ if 'DMD32 D Compiler' in out or 'DMD64 D Compiler' in out:
+ return DLinker(linker, compiler.is_64, compiler.is_msvc)
if 'LDC - the LLVM D compiler' in out:
- return LDCLinker(linker)
+ return DLinker(linker, compiler.is_64, compiler.is_msvc)
+ if 'GDC' in out and ' based on D ' in out:
+ return DLinker(linker, compiler.is_64, compiler.is_msvc)
if p.returncode == 0:
return ArLinker(linker)
if p.returncode == 1 and err.startswith('usage'): # OSX
diff --git a/mesonbuild/linkers.py b/mesonbuild/linkers.py
index 93106b3..30ca5d8 100644
--- a/mesonbuild/linkers.py
+++ b/mesonbuild/linkers.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from .mesonlib import Popen_safe
+from .mesonlib import Popen_safe, is_windows
from . import mesonlib
class StaticLinker:
@@ -138,11 +138,12 @@ class ArmarLinker(ArLinker):
# armar cann't accept arguments using the @rsp syntax
return False
-class LDCLinker(StaticLinker):
-
- def __init__(self, exelist):
+class DLinker(StaticLinker):
+ def __init__(self, exelist, is_64, is_msvc):
self.exelist = exelist
- self.id = 'ldc2'
+ self.id = exelist[0]
+ self.is_64 = is_64
+ self.is_msvc = is_msvc
def can_linker_accept_rsp(self):
return mesonlib.is_windows()
@@ -163,6 +164,12 @@ class LDCLinker(StaticLinker):
return []
def get_linker_always_args(self):
+ if is_windows():
+ if self.is_64:
+ return ['-m64']
+ elif self.is_msvc and self.id == 'dmd':
+ return ['-m32mscoff']
+ return ['-m32']
return []
def get_coverage_link_args(self):