mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-30 22:03:54 -06:00
rust: build: move rustc_args.py invocation to qemu-api crate
Only qemu-api needs access to the symbols in config-host.h. Remove the temptation to use them elsewhere by limiting the --cfg arguments to the qemu-api crate. Per-crate invocation of the script will also be needed to add --check-cfg options for each crate's features (when more complex, build-time configurable devices are added in the future). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
cb7ada5409
commit
f3a6e9bc47
2 changed files with 29 additions and 32 deletions
56
meson.build
56
meson.build
|
@ -120,7 +120,30 @@ if have_rust
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if have_rust
|
if have_rust
|
||||||
|
rustc_args = find_program('scripts/rust/rustc_args.py')
|
||||||
rustfmt = find_program('rustfmt', required: false)
|
rustfmt = find_program('rustfmt', required: false)
|
||||||
|
|
||||||
|
# Prohibit code that is forbidden in Rust 2024
|
||||||
|
rustc_lint_args = ['-D', 'unsafe_op_in_unsafe_fn']
|
||||||
|
|
||||||
|
# Occasionally, we may need to silence warnings and clippy lints that
|
||||||
|
# were only introduced in newer Rust compiler versions. Do not croak
|
||||||
|
# in that case; a CI job with rust_strict_lints == true ensures that
|
||||||
|
# we do not have misspelled allow() attributes.
|
||||||
|
if not get_option('strict_rust_lints')
|
||||||
|
rustc_lint_args += ['-A', 'unknown_lints']
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Apart from procedural macros, our Rust executables will often link
|
||||||
|
# with C code, so include all the libraries that C code needs. This
|
||||||
|
# is safe; https://github.com/rust-lang/rust/pull/54675 says that
|
||||||
|
# passing -nodefaultlibs to the linker "was more ideological to
|
||||||
|
# start with than anything".
|
||||||
|
add_project_arguments(rustc_lint_args +
|
||||||
|
['--cfg', 'MESON', '-C', 'default-linker-libraries'],
|
||||||
|
native: false, language: 'rust')
|
||||||
|
add_project_arguments(rustc_lint_args + ['--cfg', 'MESON'],
|
||||||
|
native: true, language: 'rust')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
dtrace = not_found
|
dtrace = not_found
|
||||||
|
@ -3399,37 +3422,8 @@ endif
|
||||||
# Generated sources #
|
# Generated sources #
|
||||||
#####################
|
#####################
|
||||||
|
|
||||||
genh += configure_file(output: 'config-host.h', configuration: config_host_data)
|
config_host_h = configure_file(output: 'config-host.h', configuration: config_host_data)
|
||||||
|
genh += config_host_h
|
||||||
if have_rust
|
|
||||||
rustc_args = run_command(
|
|
||||||
find_program('scripts/rust/rustc_args.py'),
|
|
||||||
'--config-headers', meson.project_build_root() / 'config-host.h',
|
|
||||||
capture : true,
|
|
||||||
check: true).stdout().strip().split()
|
|
||||||
|
|
||||||
# Prohibit code that is forbidden in Rust 2024
|
|
||||||
rustc_args += ['-D', 'unsafe_op_in_unsafe_fn']
|
|
||||||
|
|
||||||
# Occasionally, we may need to silence warnings and clippy lints that
|
|
||||||
# were only introduced in newer Rust compiler versions. Do not croak
|
|
||||||
# in that case; a CI job with rust_strict_lints == true ensures that
|
|
||||||
# we do not have misspelled allow() attributes.
|
|
||||||
if not get_option('strict_rust_lints')
|
|
||||||
rustc_args += ['-A', 'unknown_lints']
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Apart from procedural macros, our Rust executables will often link
|
|
||||||
# with C code, so include all the libraries that C code needs. This
|
|
||||||
# is safe; https://github.com/rust-lang/rust/pull/54675 says that
|
|
||||||
# passing -nodefaultlibs to the linker "was more ideological to
|
|
||||||
# start with than anything".
|
|
||||||
add_project_arguments(rustc_args +
|
|
||||||
['--cfg', 'MESON', '-C', 'default-linker-libraries'],
|
|
||||||
native: false, language: 'rust')
|
|
||||||
add_project_arguments(rustc_args + ['--cfg', 'MESON'],
|
|
||||||
native: true, language: 'rust')
|
|
||||||
endif
|
|
||||||
|
|
||||||
hxtool = find_program('scripts/hxtool')
|
hxtool = find_program('scripts/hxtool')
|
||||||
shaderinclude = find_program('scripts/shaderinclude.py')
|
shaderinclude = find_program('scripts/shaderinclude.py')
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
_qemu_api_cfg = []
|
_qemu_api_cfg = run_command(rustc_args,
|
||||||
|
'--config-headers', config_host_h,
|
||||||
|
capture: true, check: true).stdout().strip().split()
|
||||||
|
|
||||||
# _qemu_api_cfg += ['--cfg', 'feature="allocator"']
|
# _qemu_api_cfg += ['--cfg', 'feature="allocator"']
|
||||||
if rustc.version().version_compare('>=1.77.0')
|
if rustc.version().version_compare('>=1.77.0')
|
||||||
_qemu_api_cfg += ['--cfg', 'has_offset_of']
|
_qemu_api_cfg += ['--cfg', 'has_offset_of']
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue