Skip to content

Commit

Permalink
Fix compile.links for vala (alternative)
Browse files Browse the repository at this point in the history
Fixes issue #12959
compiler.links command for vala crashes
Add a new enumerated typei (FORCELINK) to CompileCheckMode.
  • Loading branch information
bcorby committed Apr 22, 2024
1 parent e166524 commit 2d09edd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
1 change: 1 addition & 0 deletions mesonbuild/compilers/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class CompileCheckMode(enum.Enum):
PREPROCESS = 'preprocess'
COMPILE = 'compile'
LINK = 'link'
FORCELINK = 'forcelink'


gnu_winlibs = ['-lkernel32', '-luser32', '-lgdi32', '-lwinspool', '-lshell32',
Expand Down
18 changes: 6 additions & 12 deletions mesonbuild/compilers/vala.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoic
super().__init__([], exelist, version, for_machine, info, is_cross=is_cross)
self.version = version
self.base_options = {OptionKey('b_colorout')}
self.force_link = False

def needs_static_linker(self) -> bool:
return False # Because compiles into C.
Expand All @@ -48,15 +47,13 @@ def get_compile_only_args(self) -> T.List[str]:

def get_compiler_args_for_mode(self, mode: CompileCheckMode) -> T.List[str]:
args: T.List[str] = []
if mode is CompileCheckMode.LINK and self.force_link:
if mode is CompileCheckMode.FORCELINK:
return args
args += self.get_always_args()
if mode is CompileCheckMode.COMPILE:
args += self.get_compile_only_args()
elif mode is CompileCheckMode.PREPROCESS:
args += self.get_preprocess_only_args()
else:
assert mode is CompileCheckMode.LINK
return args

def get_preprocess_only_args(self) -> T.List[str]:
Expand Down Expand Up @@ -153,11 +150,8 @@ def links(self, code: 'mesonlib.FileOrString', env: 'Environment', *,
if compiler:
with compiler._build_wrapper(code, env, dependencies=dependencies, want_output=True) as r:
objfile = mesonlib.File.from_absolute_file(r.output_name)
result = self.compiles(objfile, env, extra_args=extra_args,
dependencies=dependencies, mode=CompileCheckMode.LINK, disable_cache=True)
self.force_link = False
return result
result = self.compiles(code, env, extra_args=extra_args,
dependencies=dependencies, mode=CompileCheckMode.LINK, disable_cache=disable_cache)
self.force_link = False
return result
return self.compiles(objfile, env, extra_args=extra_args,
dependencies=dependencies, mode=CompileCheckMode.FORCELINK, disable_cache=True)
return self.compiles(code, env, extra_args=extra_args,
dependencies=dependencies, mode=CompileCheckMode.FORCELINK, disable_cache=disable_cache)

0 comments on commit 2d09edd

Please sign in to comment.