Skip to content

Commit

Permalink
fix for when lib.exe is not in meson's hardcoded list of names. fix s…
Browse files Browse the repository at this point in the history
…o intel cl reads linker exe from env instead of relying on hardcoded string
  • Loading branch information
gfudies committed Jan 22, 2025
1 parent 0b9baf5 commit 82887a5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
5 changes: 1 addition & 4 deletions mesonbuild/compilers/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,7 @@ def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoic
def get_options(self) -> 'MutableKeyedOptionDictType':
opts = super().get_options()
key = self.form_compileropt_key('std')
# To shut up mypy.
if isinstance(opts, dict):
raise RuntimeError('This is a transitory issue that should not happen. Please report with full backtrace.')
std_opt = opts.get_value_object(key)
std_opt = opts.get(key)
assert isinstance(std_opt, options.UserStdOption), 'for mypy'
std_opt.set_versions(['c89', 'c99', 'c11'])
return opts
Expand Down
10 changes: 7 additions & 3 deletions mesonbuild/compilers/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def detect_static_linker(env: 'Environment', compiler: Compiler) -> StaticLinker
for linker in trials:
linker_name = os.path.basename(linker[0])

if any(os.path.basename(x) in {'lib', 'lib.exe', 'llvm-lib', 'llvm-lib.exe', 'xilib', 'xilib.exe'} for x in linker):
if os.getenv('FORCE_MSVC_ARFLAGS') or any(os.path.basename(x) in {'lib', 'lib.exe', 'llvm-lib', 'llvm-lib.exe', 'xilib', 'xilib.exe'} for x in linker):
arg = '/?'
elif linker_name in {'ar2000', 'ar2000.exe', 'ar430', 'ar430.exe', 'armar', 'armar.exe', 'ar6x', 'ar6x.exe'}:
arg = '?'
Expand Down Expand Up @@ -483,7 +483,9 @@ def sanitize(p: T.Optional[str]) -> T.Optional[str]:
target = 'x86' if 'IA-32' in err else 'x86_64'
cls = c.IntelClCCompiler if lang == 'c' else cpp.IntelClCPPCompiler
env.coredata.add_lang_args(cls.language, cls, for_machine, env)
linker = linkers.XilinkDynamicLinker(for_machine, [], version=version)
linker_exe = os.getenv('CC_LD')
linker_exelist = [linker_exe] if linker_exe else None
linker = linkers.XilinkDynamicLinker(for_machine, [], version=version, exelist=linker_exelist)
return cls(
compiler, version, for_machine, is_cross, info, target,
linker=linker)
Expand All @@ -492,7 +494,9 @@ def sanitize(p: T.Optional[str]) -> T.Optional[str]:
target = 'x86' if 'IA-32' in err else 'x86_64'
cls = c.IntelLLVMClCCompiler if lang == 'c' else cpp.IntelLLVMClCPPCompiler
env.coredata.add_lang_args(cls.language, cls, for_machine, env)
linker = linkers.XilinkDynamicLinker(for_machine, [], version=version)
linker_exe = os.getenv('CC_LD')
linker_exelist = [linker_exe] if linker_exe else None
linker = linkers.XilinkDynamicLinker(for_machine, [], version=version, exelist=linker_exelist)
return cls(
compiler, version, for_machine, is_cross, info, target,
linker=linker)
Expand Down
7 changes: 5 additions & 2 deletions mesonbuild/linkers/linkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,6 @@ def get_thinlto_cache_args(self, path: str) -> T.List[str]:
def fatal_warnings(self) -> T.List[str]:
return ['-WX']


class XilinkDynamicLinker(VisualStudioLikeLinkerMixin, DynamicLinker):

"""Intel's Xilink.exe."""
Expand All @@ -1433,7 +1432,11 @@ def __init__(self, for_machine: mesonlib.MachineChoice, always_args: T.List[str]
prefix: T.Union[str, T.List[str]] = '',
machine: str = 'x86', version: str = 'unknown version',
direct: bool = True):
super().__init__(['xilink.exe'], for_machine, '', always_args, version=version)
super().__init__(exelist or ['xilink.exe'], for_machine,
prefix, always_args, machine=machine, version=version, direct=direct)

def get_gui_app_args(self, value: bool) -> T.List[str]:
return self.get_win_subsystem_args("windows" if value else "console")

def get_win_subsystem_args(self, value: str) -> T.List[str]:
return self._apply_prefix([f'/SUBSYSTEM:{value.upper()}'])
Expand Down

0 comments on commit 82887a5

Please sign in to comment.