diff --git a/CHANGELOG.md b/CHANGELOG.md index 01c675d6f7c..845b8972d47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,8 @@ build to the output of `git describe --dirty`, if the git repo is available. - MicroVM process is only attached to the cgroups defined by using `--cgroups` or the ones defined indirectly by using `--node`. +- Changed `devtool build` to build jailer binary for `musl` only targets. Building + jailer binary for `non-musl` targets have been removed. ## [0.22.0] diff --git a/Cargo.toml b/Cargo.toml index 799712f7f1d..91195d909aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = ["src/firecracker", "src/jailer"] +default-members = ["src/firecracker"] [profile.dev] panic = "abort" diff --git a/tests/host_tools/cargo_build.py b/tests/host_tools/cargo_build.py index d862607ca4f..48862bf099b 100644 --- a/tests/host_tools/cargo_build.py +++ b/tests/host_tools/cargo_build.py @@ -56,24 +56,39 @@ def get_firecracker_binaries(): building them in case they do not exist at the specified root_path. """ target = DEFAULT_BUILD_TARGET - cd_cmd = "cd {}".format(FC_WORKSPACE_DIR) - flags = 'RUSTFLAGS="{}"'.format(get_rustflags()) - cargo_cmd = "cargo build --release --target {}".format(target) - cmd = "{} && {} {}".format(cd_cmd, flags, cargo_cmd) - - utils.run_cmd(cmd) - out_dir = "{target_dir}/{target}/release".format( target_dir=FC_WORKSPACE_TARGET_DIR, target=target ) fc_bin_path = "{}/{}".format(out_dir, FC_BINARY_NAME) jailer_bin_path = "{}/{}".format(out_dir, JAILER_BINARY_NAME) + if getattr(get_firecracker_binaries, 'binaries_built', False): + return fc_bin_path, jailer_bin_path + + cd_cmd = "cd {}".format(FC_WORKSPACE_DIR) + flags = 'RUSTFLAGS="{}"'.format(get_rustflags()) + cargo_default_cmd = "cargo build --release --target {}".format( + target + ) + cargo_jailer_cmd = "cargo build -p jailer --release --target {}".format( + target + ) + cmd = "{0} && {1} {2} && {1} {3}".format( + cd_cmd, + flags, + cargo_default_cmd, + cargo_jailer_cmd + ) + + utils.run_cmd(cmd) + utils.run_cmd( "strip --strip-debug {} {}" .format(fc_bin_path, jailer_bin_path) ) + setattr(get_firecracker_binaries, 'binaries_built', True) + return fc_bin_path, jailer_bin_path diff --git a/tools/devtool b/tools/devtool index 9019c8924cb..9970d89d8bc 100755 --- a/tools/devtool +++ b/tools/devtool @@ -517,6 +517,22 @@ cmd_build() { "${cargo_args[@]}" ret=$? + [ $ret -ne 0 ] && return $ret + + # Build jailer only in case of musl for compatibility reasons + if [ "$libc" == "musl" ];then + run_devctr \ + --user "$(id -u):$(id -g)" \ + --workdir "$CTR_FC_ROOT_DIR" \ + -- \ + cargo build -p jailer \ + --target-dir "$CTR_CARGO_TARGET_DIR" \ + "${cargo_args[@]}" + + fi + + ret=$? + # If `cargo build` was successful, let's copy the binaries to a more # accessible location. [ $ret -eq 0 ] && {