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

Conversation

fanc999-1
Copy link
Contributor

...when a Visual Studio-style compiler is being used.

The dumper program will fail to link with an obscure undefined symbol 'guard_check_icall$fo$' without an appropriate CRT cflag (i.e. /MD or /MDd for instance) specified, when the latest Windows SDK (10.0.26100.0 or later) is being used on Visual Studio 2019 at least.

This applies the appropriate CRT cflag according to the build options during introspection scanning so that this issue will be avoided.

@fanc999-1 fanc999-1 requested a review from jpakkane as a code owner July 8, 2024 09:21
@fanc999-1 fanc999-1 force-pushed the gir-windows-sdk-26100 branch 6 times, most recently from e75acec to c7f6c3c Compare July 15, 2024 02:23
...when a Visual Studio-style compiler is being used.

The scanner and dumper programs for gtkdoc and introspection will fail
to link with an obscure undefined symbol '_guard_check_icall_$fo$'
without an appropriate CRT cflag (i.e. /MD or /MDd for instance) specified,
when the latest Windows SDK (10.0.26100.0 or later) is being used on Visual
Studio 2019 at least.

This will update the private _get_langs_compilers_flags() if a Visual
Studio style compiler is being used, as indicated by the b_vscrt option.

This applies the appropriate CRT cflag according to the build options
so that this issue will be avoided.

for lang, compiler in langs_compilers:
if len(crt_cflags) == 0 and OptionKey('b_vscrt') in compiler.base_options:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if len(crt_cflags) == 0 and OptionKey('b_vscrt') in compiler.base_options:
if not crt_cflags and OptionKey('b_vscrt') in compiler.base_options:

# _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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the isinstance() check needed?

@@ -1157,6 +1166,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:
Copy link
Member

@dnicolodi dnicolodi Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if len(crt_cflags) > 0:
if crt_cflags:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, if crt_flags is a list, the check can be omitted.

@@ -1572,6 +1583,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, I think the check can be omitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants