Message ID | cdba13875d38feb836468a73509d24a88c8332ca.1721648163.git.manos.pitsidianakis@linaro.org |
---|---|
State | New |
Headers | show |
Series | Add Rust support, implement ARM PL011 | expand |
Hi Manos, On Mon, Jul 22, 2024 at 02:43:31PM +0300, Manos Pitsidianakis wrote: > Date: Mon, 22 Jul 2024 14:43:31 +0300 > From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> > Subject: [RFC PATCH v5 1/8] build-sys: Add rust feature option > X-Mailer: git-send-email 2.44.0 > > Add rust feature in meson.build, configure, to prepare for adding Rust > code in the followup commits. > > Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> > --- > MAINTAINERS | 5 +++++ > configure | 12 ++++++++++++ > meson.build | 17 ++++++++++++++++- > Kconfig | 1 + > Kconfig.host | 3 +++ > meson_options.txt | 5 +++++ > rust/Kconfig | 0 > scripts/meson-buildoptions.sh | 3 +++ > 8 files changed, 45 insertions(+), 1 deletion(-) > create mode 100644 rust/Kconfig > [snip] > diff --git a/meson.build b/meson.build > index a1e51277b0..a3f346ab3c 100644 > --- a/meson.build > +++ b/meson.build > @@ -70,6 +70,14 @@ if host_os == 'darwin' and \ > all_languages += ['objc'] > objc = meson.get_compiler('objc') > endif > +if get_option('have_rust') and meson.version().version_compare('<1.0.0') > + error('Rust support requires Meson version >=1.0.0') > +endif > +have_rust = false > +if not get_option('disable_rust') and add_languages('rust', required: get_option('have_rust'), native: false) > + rustc = meson.get_compiler('rust') > + have_rust = true > +endif Only a nit, "disable_rust" seems redundant, and "have_rust" is enough. Others LGTM, Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
On Tue, 23 Jul 2024 09:37, Zhao Liu <zhao1.liu@intel.com> wrote: >Hi Manos, > >On Mon, Jul 22, 2024 at 02:43:31PM +0300, Manos Pitsidianakis wrote: >> Date: Mon, 22 Jul 2024 14:43:31 +0300 >> From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> >> Subject: [RFC PATCH v5 1/8] build-sys: Add rust feature option >> X-Mailer: git-send-email 2.44.0 >> >> Add rust feature in meson.build, configure, to prepare for adding Rust >> code in the followup commits. >> >> Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> >> --- >> MAINTAINERS | 5 +++++ >> configure | 12 ++++++++++++ >> meson.build | 17 ++++++++++++++++- >> Kconfig | 1 + >> Kconfig.host | 3 +++ >> meson_options.txt | 5 +++++ >> rust/Kconfig | 0 >> scripts/meson-buildoptions.sh | 3 +++ >> 8 files changed, 45 insertions(+), 1 deletion(-) >> create mode 100644 rust/Kconfig >> > >[snip] > >> diff --git a/meson.build b/meson.build >> index a1e51277b0..a3f346ab3c 100644 >> --- a/meson.build >> +++ b/meson.build >> @@ -70,6 +70,14 @@ if host_os == 'darwin' and \ >> all_languages += ['objc'] >> objc = meson.get_compiler('objc') >> endif >> +if get_option('have_rust') and meson.version().version_compare('<1.0.0') >> + error('Rust support requires Meson version >=1.0.0') >> +endif >> +have_rust = false >> +if not get_option('disable_rust') and add_languages('rust', required: get_option('have_rust'), native: false) >> + rustc = meson.get_compiler('rust') >> + have_rust = true >> +endif > >Only a nit, "disable_rust" seems redundant, and "have_rust" is enough. > >Others LGTM, > >Reviewed-by: Zhao Liu <zhao1.liu@intel.com> > Hello Zhao, thank you for your review! Indeed it does seem redundant, I added it to allow graceful fallback to not using Rust if the compiler is not detected by meson. Manos
diff --git a/MAINTAINERS b/MAINTAINERS index 7d9811458c..d427f13b79 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4228,6 +4228,11 @@ F: docs/sphinx/ F: docs/_templates/ F: docs/devel/docs.rst +Rust build system integration +M: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> +S: Maintained +F: rust/Kconfig + Miscellaneous ------------- Performance Tools and Tests diff --git a/configure b/configure index 019fcbd0ef..8476968b96 100755 --- a/configure +++ b/configure @@ -173,6 +173,7 @@ fi # default parameters container_engine="auto" +have_rust="no" cpu="" cross_compile="no" cross_prefix="" @@ -757,6 +758,15 @@ for opt do ;; --gdb=*) gdb_bin="$optarg" ;; + --enable-rust) + have_rust="yes" ; + meson_option_add -Dhave_rust=true + ;; + --disable-rust) + have_rust="no" ; + meson_option_add -Dhave_rust=false + meson_option_add -Ddisable_rust=true + ;; # everything else has the same name in configure and meson --*) meson_option_parse "$opt" "$optarg" ;; @@ -874,6 +884,8 @@ Advanced options (experts only): start the emulator (only use if you are including desired devices in configs/devices/) --with-devices-ARCH=NAME override default configs/devices + --enable-rust enable compilation of Rust code + --disable-rust disable compilation of Rust code --enable-debug enable common debug build options --cpu=CPU Build for host CPU [$cpu] --disable-containers don't use containers for cross-building diff --git a/meson.build b/meson.build index a1e51277b0..a3f346ab3c 100644 --- a/meson.build +++ b/meson.build @@ -70,6 +70,14 @@ if host_os == 'darwin' and \ all_languages += ['objc'] objc = meson.get_compiler('objc') endif +if get_option('have_rust') and meson.version().version_compare('<1.0.0') + error('Rust support requires Meson version >=1.0.0') +endif +have_rust = false +if not get_option('disable_rust') and add_languages('rust', required: get_option('have_rust'), native: false) + rustc = meson.get_compiler('rust') + have_rust = true +endif dtrace = not_found stap = not_found @@ -2119,6 +2127,7 @@ endif config_host_data = configuration_data() +config_host_data.set('CONFIG_HAVE_RUST', have_rust) audio_drivers_selected = [] if have_system audio_drivers_available = { @@ -3038,7 +3047,8 @@ host_kconfig = \ (host_os == 'linux' ? ['CONFIG_LINUX=y'] : []) + \ (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : []) + \ (vfio_user_server_allowed ? ['CONFIG_VFIO_USER_SERVER_ALLOWED=y'] : []) + \ - (hv_balloon ? ['CONFIG_HV_BALLOON_POSSIBLE=y'] : []) + (hv_balloon ? ['CONFIG_HV_BALLOON_POSSIBLE=y'] : []) + \ + (have_rust ? ['CONFIG_HAVE_RUST=y'] : []) ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ] @@ -4242,6 +4252,11 @@ if 'objc' in all_languages else summary_info += {'Objective-C compiler': false} endif +summary_info += {'Rust support': have_rust} +if have_rust + summary_info += {'rustc version': rustc.version()} + summary_info += {'rustc': ' '.join(rustc.cmd_array())} +endif option_cflags = (get_option('debug') ? ['-g'] : []) if get_option('optimization') != 'plain' option_cflags += ['-O' + get_option('optimization')] diff --git a/Kconfig b/Kconfig index fb6a24a2de..63ca7f46df 100644 --- a/Kconfig +++ b/Kconfig @@ -4,3 +4,4 @@ source accel/Kconfig source target/Kconfig source hw/Kconfig source semihosting/Kconfig +source rust/Kconfig diff --git a/Kconfig.host b/Kconfig.host index 17f405004b..4ade7899d6 100644 --- a/Kconfig.host +++ b/Kconfig.host @@ -52,3 +52,6 @@ config VFIO_USER_SERVER_ALLOWED config HV_BALLOON_POSSIBLE bool + +config HAVE_RUST + bool diff --git a/meson_options.txt b/meson_options.txt index 0269fa0f16..9eef45f85b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -371,3 +371,8 @@ option('hexagon_idef_parser', type : 'boolean', value : true, option('x86_version', type : 'combo', choices : ['0', '1', '2', '3', '4'], value: '1', description: 'tweak required x86_64 architecture version beyond compiler default') + +option('have_rust', type: 'boolean', value: false, + description: 'Have Rust support') +option('disable_rust', type: 'boolean', value: false, + description: 'Disable Rust support') diff --git a/rust/Kconfig b/rust/Kconfig new file mode 100644 index 0000000000..e69de29bb2 diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index c97079a38c..bb5854115a 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -170,6 +170,7 @@ meson_options_help() { printf "%s\n" ' rbd Ceph block device driver' printf "%s\n" ' rdma Enable RDMA-based migration' printf "%s\n" ' replication replication support' + printf "%s\n" ' rust Rust support' printf "%s\n" ' rutabaga-gfx rutabaga_gfx support' printf "%s\n" ' sdl SDL user interface' printf "%s\n" ' sdl-image SDL Image support for icons' @@ -556,6 +557,8 @@ _meson_option_parse() { --enable-whpx) printf "%s" -Dwhpx=enabled ;; --disable-whpx) printf "%s" -Dwhpx=disabled ;; --x86-version=*) quote_sh "-Dx86_version=$2" ;; + --enable-with-rust) printf "%s" -Dhave_rust=true ;; + --disable-with-rust) printf "%s" -Dhave_rust=false ;; --enable-xen) printf "%s" -Dxen=enabled ;; --disable-xen) printf "%s" -Dxen=disabled ;; --enable-xen-pci-passthrough) printf "%s" -Dxen_pci_passthrough=enabled ;;
Add rust feature in meson.build, configure, to prepare for adding Rust code in the followup commits. Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> --- MAINTAINERS | 5 +++++ configure | 12 ++++++++++++ meson.build | 17 ++++++++++++++++- Kconfig | 1 + Kconfig.host | 3 +++ meson_options.txt | 5 +++++ rust/Kconfig | 0 scripts/meson-buildoptions.sh | 3 +++ 8 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 rust/Kconfig