Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modules/gnome.py: Fix generating .gir with latest Windows SDK #13392

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions mesonbuild/modules/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,12 +896,21 @@ def _get_gir_targets_inc_dirs(girtargets: T.Sequence[build.BuildTarget]) -> Orde

@staticmethod
def _get_langs_compilers_flags(state: 'ModuleState', langs_compilers: T.List[T.Tuple[str, 'Compiler']]
) -> T.Tuple[T.List[str], T.List[str], T.List[str]]:
) -> T.Tuple[T.List[str], T.List[str], T.List[str], T.List[str]]:
cflags: T.List[str] = []
internal_ldflags: T.List[str] = []
external_ldflags: T.List[str] = []
crt_cflags: T.List[str] = []

for lang, compiler in langs_compilers:
if len(crt_cflags) == 0 and OptionKey('b_vscrt') in compiler.base_options:
# For the latest Windows SDK 10.0.26100.0+, we must specify a CRT cflag (/MD or /MDd for instance),
# otherwise the scanner program will fail to link with an obscure undefined symbol
# _guard_check_icall_$fo$
crt_val = state.environment.coredata.get_option(OptionKey('b_vscrt'))
buildtype = state.environment.coredata.get_option(OptionKey('buildtype'))
if isinstance(crt_val, str) and isinstance(buildtype, str):
crt_cflags = compiler.get_crt_compile_args(crt_val, buildtype)
if state.global_args.get(lang):
cflags += state.global_args[lang]
if state.project_args.get(lang):
Expand All @@ -921,7 +930,7 @@ def _get_langs_compilers_flags(state: 'ModuleState', langs_compilers: T.List[T.T
# does not understand -f LDFLAGS. https://bugzilla.gnome.org/show_bug.cgi?id=783892
# ldflags += compiler.sanitizer_link_args(sanitize)

return cflags, internal_ldflags, external_ldflags
return cflags, internal_ldflags, external_ldflags, crt_cflags

@staticmethod
def _make_gir_filelist(state: 'ModuleState', srcdir: str, ns: str,
Expand Down Expand Up @@ -1143,7 +1152,7 @@ def generate_gir(self, state: 'ModuleState', args: T.Tuple[T.List[T.Union[Execut
depends.extend(girtargets)

langs_compilers = self._get_girtargets_langs_compilers(girtargets)
cflags, internal_ldflags, external_ldflags = self._get_langs_compilers_flags(state, langs_compilers)
cflags, internal_ldflags, external_ldflags, crt_cflags = self._get_langs_compilers_flags(state, langs_compilers)
deps = self._get_gir_targets_deps(girtargets)
deps += kwargs['dependencies']
deps += [gir_dep]
Expand All @@ -1154,6 +1163,8 @@ def generate_gir(self, state: 'ModuleState', args: T.Tuple[T.List[T.Union[Execut
dep_cflags, dep_internal_ldflags, dep_external_ldflags, gi_includes, depends = \
self._get_dependencies_flags(deps, state, depends, use_gir_args=True)
scan_cflags = []
if len(crt_cflags) > 0:
scan_cflags += list(crt_cflags)
scan_cflags += list(self._get_scanner_cflags(cflags))
scan_cflags += list(self._get_scanner_cflags(dep_cflags))
scan_cflags += list(self._get_scanner_cflags(self._get_external_args_for_langs(state, [lc[0] for lc in langs_compilers])))
Expand Down Expand Up @@ -1566,6 +1577,8 @@ def _get_build_args(self, c_args: T.List[str], inc_dirs: T.List[T.Union[str, bui
compiler = state.environment.coredata.compilers[MachineChoice.HOST]['c']

compiler_flags = self._get_langs_compilers_flags(state, [('c', compiler)])
if len(compiler_flags[3]) > 0:
cflags.extend(compiler_flags[3]) # Apply CRT cflag first if necessary
cflags.extend(compiler_flags[0])
ldflags.extend(compiler_flags[1])
ldflags.extend(compiler_flags[2])
Expand Down
Loading