Make win_subsystem a linker property

pull/8096/head
Laurin-Luis Lehning 4 years ago committed by Dylan Baker
parent 9f1ba40252
commit 2fb4d1f751
  1. 9
      mesonbuild/compilers/compilers.py
  2. 6
      mesonbuild/compilers/mixins/clang.py
  3. 14
      mesonbuild/compilers/mixins/gnu.py
  4. 3
      mesonbuild/compilers/mixins/visualstudio.py
  5. 31
      mesonbuild/linkers.py

@ -874,11 +874,10 @@ class Compiler(metaclass=abc.ABCMeta):
return []
def get_win_subsystem_args(self, value: str) -> T.List[str]:
# This returns an empty array rather than throws to simplify the code.
# Otherwise we would have to check whenever calling this function whether
# the target is for Windows. There are also many cases where this is
# a meaningless choice, such as with Jave or C#.
return []
# By default the dynamic linker is going to return an empty
# array in case it either doesn't support Windows subsystems
# or does not target Windows
return self.linker.get_win_subsystem_args(value)
def has_func_attribute(self, name: str, env: 'Environment') -> T.Tuple[bool, bool]:
raise EnvironmentException(

@ -109,12 +109,6 @@ class ClangCompiler(GnuLikeCompiler):
# Shouldn't work, but it'll be checked explicitly in the OpenMP dependency.
return []
def get_win_subsystem_args(self, value: str) -> T.List[str]:
if self.info.is_windows() and not self.info.is_cygwin() and isinstance(self.linker, ClangClDynamicLinker):
return [f'-Wl,/subsystem:{value}']
return super().get_win_subsystem_args(value)
@classmethod
def use_linker_args(cls, linker: str) -> T.List[str]:
# Clang additionally can use a linker specified as a path, which GCC

@ -219,20 +219,6 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta):
return ['-mwindows' if value else '-mconsole']
return []
def get_win_subsystem_args(self, value: str) -> T.List[str]:
args = []
if self.info.is_windows() or self.info.is_cygwin():
if 'windows' in value:
args = ['-Wl,--subsystem,windows']
elif 'console' in value:
args = ['-Wl,--subsystem,console']
else:
raise mesonlib.MesonException('Only "windows" and "console" are supported for win_subsystem with MinGW, not "{}".'.format(value))
if ',' in value:
args[-1] = args[-1] + ':' + value.split(',')[1]
return args
def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str], build_dir: str) -> T.List[str]:
for idx, i in enumerate(parameter_list):
if i[:2] == '-I' or i[:2] == '-L':

@ -205,9 +205,6 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
else:
return ['/SUBSYSTEM:CONSOLE']
def get_win_subsystem_args(self, value: str) -> T.List[str]:
return ['/SUBSYSTEM:' + value.upper()]
def get_pic_args(self) -> T.List[str]:
return [] # PIC is handled by the loader on Windows

@ -477,6 +477,11 @@ class DynamicLinker(LinkerEnvVarsMixin, metaclass=abc.ABCMeta):
# Only used by the Apple linker
return []
def get_win_subsystem_args(self, value: str) -> T.List[str]:
# Only used if supported by the dynamic linker and
# only when targeting Windows
return []
def bitcode_args(self) -> T.List[str]:
raise mesonlib.MesonException('This linker does not support bitcode bundles')
@ -743,6 +748,22 @@ class GnuDynamicLinker(GnuLikeDynamicLinkerMixin, PosixDynamicLinkerMixin, Dynam
"""Representation of GNU ld.bfd and ld.gold."""
def get_win_subsystem_args(self, value: str) -> T.List[str]:
m = env.machines[self.for_machine]
args = []
if m.is_windows() or m.is_cygwin():
if 'windows' in value:
args = ['--subsystem,windows']
elif 'console' in value:
args = ['--subsystem,console']
else:
raise mesonlib.MesonException(f'Only "windows" and "console" are supported for win_subsystem with MinGW, not "{value}".')
if ',' in value:
args[-1] = args[-1] + ':' + value.split(',')[1]
return self._apply_prefix(args)
def get_accepts_rsp(self) -> bool:
return True
@ -781,6 +802,13 @@ class LLVMDynamicLinker(GnuLikeDynamicLinkerMixin, PosixDynamicLinkerMixin, Dyna
return self._apply_prefix('--allow-shlib-undefined')
return []
def get_win_subsystem_args(self, value: str) -> T.List[str]:
m = env.machines[self.for_machine]
if not m.is_windows() or m.is_cygwin():
return []
return self._apply_prefix([f'-subsystem:{value}'])
class WASMDynamicLinker(GnuLikeDynamicLinkerMixin, PosixDynamicLinkerMixin, DynamicLinker):
@ -1122,6 +1150,9 @@ class VisualStudioLikeLinkerMixin:
def get_allow_undefined_args(self) -> T.List[str]:
return []
def get_win_subsystem_args(self, value: str) -> T.List[str]:
return self._apply_prefix([f'/SUBSYSTEM:{value.upper()}'])
def get_soname_args(self, env: 'Environment', prefix: str, shlib_name: str,
suffix: str, soversion: str, darwin_versions: T.Tuple[str, str],
is_shared_module: bool) -> T.List[str]:

Loading…
Cancel
Save