meson: introduce serialize build option

With commit 5d20f89a ("scheds-rust: build rust schedulers in sequence"),
schedulers are now built serially one after the other to prevent meson
and cargo from forking NxN parallel tasks.

However, this change has made building a single scheduler much more
cumbersome, due to the chain of dependencies.

For example, building scx_rusty using the specific meson target would
still result in all schedulers being built, because they all depend on
each other.

To address this issue, introduce the new meson build option
`serialize=true|false` (default is false).

This option allows to disable the schedulers' build chain, restoring the
old behavior.

With this option enabled, it is now possible to build just a single
scheduler, parallelizing the cargo build properly, without triggering
the build of the others. Example:

  $ meson setup build -Dbuildtype=release -Dserialize=false
  $ meson compile -C build scx_rusty

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
This commit is contained in:
Andrea Righi 2024-06-28 09:42:04 +02:00
parent 769e6c4e55
commit cf4883fbf8
9 changed files with 47 additions and 6 deletions

View File

@ -264,6 +264,7 @@ options can be used in such cases.
- 'cargo_home': 'CARGO_HOME env to use when invoking cargo'
- `offline`: 'Compilation step should not access the internet'
- `enable_rust`: 'Enable the build of rust sub-projects'
- `serialize`: 'Enable/disable the sequential build of the schedulers. Set this to false if you need to build just one scheduler.'
For example, let's say you want to use `bpftool` and `libbpf` shipped in the
kernel tree located at `$KERNEL`. We need to build `bpftool` in the kernel

View File

@ -12,6 +12,8 @@ cc = meson.get_compiler('c')
enable_rust = get_option('enable_rust')
serialize = get_option('serialize')
bpf_clang = find_program(get_option('bpf_clang'))
enable_stress = get_option('enable_stress')

View File

@ -14,6 +14,8 @@ option('offline', type: 'boolean', value: 'false',
description: 'Compilation step should not access the internet')
option('enable_rust', type: 'boolean', value: 'true',
description: 'Enable rust sub-projects')
option('serialize', type: 'boolean', value: 'true',
description: 'Serialize the build of all schedulers')
option('enable_stress', type: 'boolean', value: 'true',
description: 'Enable stress tests')
option('kernel', type: 'string', value: 'vmlinuz',

View File

@ -1,8 +1,14 @@
if serialize
sched_deps = [libbpf, bpftool_target, sched]
else
sched_deps = [libbpf, bpftool_target]
endif
sched = custom_target('scx_lavd',
output: '@PLAINNAME@.__PHONY__',
input: 'Cargo.toml',
command: [cargo, 'build', '--manifest-path=@INPUT@', '--target-dir=@OUTDIR@',
cargo_build_args],
env: cargo_env,
depends: [sched],
depends: sched_deps,
build_always_stale: true)

View File

@ -1,8 +1,14 @@
if serialize
sched_deps = [libbpf, bpftool_target, sched]
else
sched_deps = [libbpf, bpftool_target]
endif
sched = custom_target('scx_layered',
output: '@PLAINNAME@.__PHONY__',
input: 'Cargo.toml',
command: [cargo, 'build', '--manifest-path=@INPUT@', '--target-dir=@OUTDIR@',
cargo_build_args],
env: cargo_env,
depends: [libbpf, bpftool_target, sched],
depends: sched_deps,
build_always_stale: true)

View File

@ -1,8 +1,14 @@
if serialize
sched_deps = [libbpf, bpftool_target, sched]
else
sched_deps = [libbpf, bpftool_target]
endif
sched = custom_target('scx_mitosis',
output: '@PLAINNAME@.__PHONY__',
input: 'Cargo.toml',
command: [cargo, 'build', '--manifest-path=@INPUT@', '--target-dir=@OUTDIR@',
cargo_build_args],
env: cargo_env,
depends: [libbpf, bpftool_target, sched],
depends: sched_deps,
build_always_stale: true)

View File

@ -1,8 +1,14 @@
if serialize
sched_deps = [libbpf, bpftool_target, sched]
else
sched_deps = [libbpf, bpftool_target]
endif
sched = custom_target('scx_rlfifo',
output: '@PLAINNAME@.__PHONY__',
input: 'Cargo.toml',
command: [cargo, 'build', '--manifest-path=@INPUT@', '--target-dir=@OUTDIR@',
cargo_build_args],
env: cargo_env,
depends: [libbpf, bpftool_target, sched],
depends: sched_deps,
build_always_stale: true)

View File

@ -1,8 +1,14 @@
if serialize
sched_deps = [libbpf, bpftool_target, sched]
else
sched_deps = [libbpf, bpftool_target]
endif
sched = custom_target('scx_rustland',
output: '@PLAINNAME@.__PHONY__',
input: 'Cargo.toml',
command: [cargo, 'build', '--manifest-path=@INPUT@', '--target-dir=@OUTDIR@',
cargo_build_args],
env: cargo_env,
depends: [libbpf, bpftool_target, sched],
depends: sched_deps,
build_always_stale: true)

View File

@ -1,8 +1,14 @@
if serialize
sched_deps = [libbpf, bpftool_target, sched]
else
sched_deps = [libbpf, bpftool_target]
endif
sched = custom_target('scx_rusty',
output: '@PLAINNAME@.__PHONY__',
input: 'Cargo.toml',
command: [cargo, 'build', '--manifest-path=@INPUT@', '--target-dir=@OUTDIR@',
cargo_build_args],
env: cargo_env,
depends: [libbpf, bpftool_target, sched],
depends: sched_deps,
build_always_stale: true)