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

Meson env fixes for icc-cl and msvc #14175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
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)
Copy link
Member

Choose a reason for hiding this comment

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

This looks like it belongs in a distinct commit. We should also find out why it triggers at all, e.g. what is the backtrace it's asking for?

Copy link
Author

Choose a reason for hiding this comment

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

was hoping @jpakkane could tell me why this was added in the first place. 181c349#diff-7ada83df1272b6eaaff2fea8bbbb14ff9cd6baaf7de40c532fe95acf9bf73fbcR546 . It looks like a hack to me but I don't know this code base very well.

Copy link
Author

Choose a reason for hiding this comment

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

Without this change I get

The Meson build system
Version: 1.6.1
Source dir: /build/Source-Tree/libs/fontconfig
Build dir: /build/Source-Tree/build/objects/x86_64-Windows-10/intel_msvc-2024.2/optimize/fontconfig/1.1.1.R/static
Build type: cross build
Project name: fontconfig
Project version: 2.15.0
Traceback (most recent call last):
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/mesonmain.py", line 193, in run
    return options.run_func(options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/msetup.py", line 365, in run
    app.generate()
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/msetup.py", line 188, in generate
    return self._generate(env, capture, vslite_ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/msetup.py", line 210, in _generate
    intr = interpreter.Interpreter(b, user_defined_options=user_defined_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/interpreter/interpreter.py", line 322, in __init__
    self.parse_project()
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/interpreterbase/interpreterbase.py", line 129, in parse_project
    self.evaluate_codeblock(self.ast, end=1)
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/interpreterbase/interpreterbase.py", line 195, in evaluate_codeblock
    raise e
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/interpreterbase/interpreterbase.py", line 187, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/interpreterbase/interpreterbase.py", line 201, in evaluate_statement
    return self.function_call(cur)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/interpreterbase/interpreterbase.py", line 528, in function_call
    res = func(node, func_args, kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/interpreterbase/decorators.py", line 237, in wrapper
    return f(*nargs, **wrapped_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/interpreterbase/decorators.py", line 556, in wrapper
    return f(*wrapped_args, **wrapped_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/interpreter/interpreter.py", line 1321, in func_project
    self.add_languages(proj_langs, True, MachineChoice.HOST)
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/interpreter/interpreter.py", line 1490, in add_languages
    success = self.add_languages_for(args, required, for_machine)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/interpreter/interpreter.py", line 1533, in add_languages_for
    comp = compilers.detect_compiler_for(self.environment, lang, for_machine, skip_sanity_check, self.subproject)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/compilers/detect.py", line 109, in detect_compiler_for
    env.coredata.process_compiler_options(lang, comp, env, subproject)
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/coredata.py", line 755, in process_compiler_options
    self.add_compiler_options(comp.get_options(), lang, comp.for_machine, env, subproject)
                              ^^^^^^^^^^^^^^^^^^
  File "/site/toolchain/buildtools/by-build/x86_64-CentOS-6/meson/1.6.1/bin/mesonbuild/compilers/c.py", line 555, in get_options
    raise RuntimeError('This is a transitory issue that should not happen. Please report with full backtrace.')
RuntimeError: This is a transitory issue that should not happen. Please report with full backtrace.

../../../../../../../../libs/fontconfig/meson.build:1:0: ERROR: Unhandled python exception

    This is a Meson bug and should be reported!```

Copy link
Member

Choose a reason for hiding this comment

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

The reason it was added is because the type of the thing will change when the option refactor branch lands (should happen immediately after 1.7 release). Things used to be stored in separate places so the thing could be a dictionary or a "proxy object" that pretends to be a dictionary. Those all will go away and options are stored wholly inside the OptionStore object.

IIRC I did not fix it "properly" at the time because it would have taken a lot of effort and the entire code path would get deleted fairly soon anyway.

Copy link
Author

Choose a reason for hiding this comment

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

so what would you suggest I do for now then?

Copy link
Author

Choose a reason for hiding this comment

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

@dcbaker should I drop this and retry against some other branch then?

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):
Copy link
Author

Choose a reason for hiding this comment

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

idk what to name this or how to pipe it through ini files

Copy link
Author

Choose a reason for hiding this comment

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

@eli-schwartz any input/suggestions on this?

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 = env.lookup_binary_entry(for_machine, 'c_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 = env.lookup_binary_entry(for_machine, 'c_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
3 changes: 2 additions & 1 deletion mesonbuild/linkers/linkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,8 @@ 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_win_subsystem_args(self, value: str) -> T.List[str]:
return self._apply_prefix([f'/SUBSYSTEM:{value.upper()}'])
Expand Down
Loading