Skip to content

[Rust] sanity check has hardcoded filename, that doesn't include .exe for Windows cross compilation #14374

Open
@kasper93

Description

@kasper93

Describe the bug
rust sanity check has hardcoded filename, that doesn't include .exe for Windows cross compilation

Produced binary is correct and works fine, but is not runnable, because Meson runs wine rusttest instead of wine rusttest.exe. (wine is exe_wrapper in this case)

The binary name is hardcoded here:

output_name = os.path.join(work_dir, 'rusttest')

It should be using exiting code to generate proper temp file... like this from base class.

def _get_compile_output(self, dirname: str, mode: CompileCheckMode) -> str:
assert mode != CompileCheckMode.PREPROCESS, 'In pre-processor mode, the output is sent to stdout and discarded'
# Extension only matters if running results; '.exe' is
# guaranteed to be executable on every platform.
if mode == CompileCheckMode.LINK:
suffix = 'exe'
else:
suffix = 'obj'
return os.path.join(dirname, 'output.' + suffix)

and even probably use this https://github.com/mesonbuild/meson/blob/d17df82efa5dd0b60b9b2a25f8a5e2f34477af6a/mesonbuild/compilers/compilers.py#L824C8-L824C10 instead of NIHing the process in rust.py.

You can use https://github.com/kasper93/meson-rust for example, there are github actions with both skip_sanity_check enabled and disabled.

To Reproduce
Try to cross compile Rust for --target x86_64-pc-windows-gnu.

Expected behavior
Sanity check passes when binaries are correct.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions