Skip to content

Commit

Permalink
[antlir2][appliance_vm] build kernel using exec_layer
Browse files Browse the repository at this point in the history
Summary:
Use a build layer compiled for the execution platform so that we don't have to
run builds under the excruciatingly slow qemu user emulation.

Test Plan:
```
❯ buck2 build --show-output -c fbcode.arch=aarch64 fbcode//antlir/antlir2/appliance_vm:kernel
Buck UI: https://www.internalfb.com/buck2/9791ab49-857f-44c0-acca-e69f1b32132b
Note:    Using experimental modern dice
Network: Up: 0B  Down: 0B
Command: build.                                                                                               Jobs completed: 8. Time elapsed: 0.6s.
BUILD SUCCEEDED
fbcode//antlir/antlir2/appliance_vm:kernel buck-out/v2/gen/fbcode/a28d00ef89d2aebb/antlir/antlir2/appliance_vm/__kernel__/out

❯ zcat buck-out/v2/gen/fbcode/a28d00ef89d2aebb/antlir/antlir2/appliance_vm/__kernel__/out > ~/tmp/aarch64kernel

❯ file ~/tmp/aarch64kernel
/home/vmagro/tmp/aarch64kernel: Linux kernel ARM64 boot executable Image, little-endian, 4K pages
```

Reviewed By: sergeyfd

Differential Revision: D59333790

fbshipit-source-id: 58029e642f87166a1c3bcb546e8ae2d47603c20b
  • Loading branch information
vmagro authored and facebook-github-bot committed Jul 3, 2024
1 parent 7624474 commit fc04e95
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions antlir/antlir2/appliance_vm/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ export_file(
name = "kernelconfig.aarch64",
)

image.layer(
name = "build-appliance",
features = [
"//antlir/antlir2/genrule_in_image:prep",
],
parent_layer = internal_external(
fb = "//kernel/build/image:_appliance.layer",
oss = ":appliance",
),
)

genrule_in_image(
name = "kernel",
out = "vmlinuz",
Expand All @@ -36,21 +47,23 @@ genrule_in_image(
"ovr_config//cpu:arm64": ":kernelconfig.aarch64",
"ovr_config//cpu:x86_64": ":kernelconfig.x86_64",
}),
make_arch = select({
"ovr_config//cpu:arm64": "arm64",
"ovr_config//cpu:x86_64": "x86_64",
}),
),
lambda sel: """
odir=`realpath $BUCK_SCRATCH_PATH`
cp $(location {config}) "$odir/.config"
make O="$odir" -C $(location :kernel.git) -j`nproc`
make O="$odir" -C $(location :kernel.git) ARCH={arch} LLVM=1 -j`nproc`
cp "$odir/{out}" $OUT
""".format(
out = sel.out,
arch = sel.make_arch,
config = sel.config,
),
),
layer = internal_external(
fb = "//kernel/build/image:_appliance.layer",
oss = ":appliance",
),
exec_layer = ":build-appliance",
)

image.layer(
Expand Down

0 comments on commit fc04e95

Please sign in to comment.