Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 41 additions & 24 deletions .sync/rust/Makefiles/Makefile-patina-readiness-tool.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
default_to_workspace = false

[env]
# This is needed due to uefi-sdk's use of unstable features.
RUSTC_BOOTSTRAP = 1

AARCH64_STD_WINDOWS_TARGET = "--target aarch64-pc-windows-msvc"
X86_64_STD_WINDOWS_TARGET = "--target x86_64-pc-windows-msvc"
AARCH64_STD_LINUX_TARGET = "--target aarch64-unknown-linux-gnu"
X86_64_STD_LINUX_TARGET = "--target x86_64-unknown-linux-gnu"
AARCH64_UEFI_TARGET = "--target aarch64-unknown-uefi"
X86_64_UEFI_TARGET = "--target x86_64-unknown-uefi"

Expand All @@ -22,11 +24,13 @@ CAPTURE_UEFI_SHELL_FLAGS = "${DXE_READINESS_PKG} --features uefishell --bin uefi
# DXE Readiness Capture UEFI binaries to run from UEFI Shell.
[tasks.build-x64-uefishell]
description = "Builds the DXE Readiness Capture UEFI binary to run in UEFI Shell."
env = { RUSTFLAGS = "-C force-unwind-tables -C link-arg=/base:0x0 -C link-arg=/subsystem:efi_application -C link-arg=/PDBALTPATH:uefishell_dxe_readiness_capture.pdb" }
command = "cargo"
args = [ "build", "@@split(CAPTURE_UEFI_SHELL_FLAGS, )", "@@split(X86_64_UEFI_TARGET, )", "${@}", ]

[tasks.build-aarch64-uefishell]
description = "Builds the DXE Readiness Capture UEFI binary to run in UEFI Shell."
env = { RUSTFLAGS = "-C force-unwind-tables -C link-arg=/base:0x0 -C link-arg=/subsystem:efi_application -C link-arg=/PDBALTPATH:uefishell_dxe_readiness_capture.pdb" }
command = "cargo"
args = [ "build", "@@split(CAPTURE_UEFI_SHELL_FLAGS, )", "@@split(AARCH64_UEFI_TARGET, )", "${@}", ]

Expand All @@ -36,47 +40,65 @@ args = [ "build", "@@split(CAPTURE_UEFI_SHELL_FLAGS, )", "@@split(AARCH64_UEFI_T
[tasks.build-intel-common]
description = "Builds the Intel DXE Readiness Capture UEFI binary."
private = true
env = { RUSTFLAGS = "-C force-unwind-tables -C link-arg=/base:0x0 -C link-arg=/subsystem:efi_boot_service_driver -C link-arg=/PDBALTPATH:intel_dxe_readiness_capture.pdb" }
command = "cargo"
args = ["build", "@@split(CAPTURE_BIN_FLAGS, )", "@@split(X86_64_UEFI_TARGET, )", "--bin", "intel_dxe_readiness_capture", "${@}"]

# Intel Lunar Lake capture binary.
[tasks.build-intel-lnl]
description = "Builds the Intel DXE Readiness Capture UEFI binary for Lunar Lake."
dependencies = ["build-intel-common"]

# Intel Panther Lake capture binary.
[tasks.build-intel-ptl]
description = "Builds the Intel DXE Readiness Capture UEFI binary for Panther Lake."
dependencies = ["build-intel-common"]

# Builds EFI binaries for virtual platform (QEMU).
[tasks.build-x64-uefi]
description = "Builds the x64 DXE Readiness Capture UEFI binary."
env = { RUSTFLAGS = "-C force-unwind-tables -C link-arg=/base:0x0 -C link-arg=/subsystem:efi_boot_service_driver -C link-arg=/PDBALTPATH:qemu_dxe_readiness_capture.pdb" }
command = "cargo"
args = ["build", "@@split(CAPTURE_BIN_FLAGS, )", "@@split(X86_64_UEFI_TARGET, )", "--bin", "qemu_dxe_readiness_capture", "${@}"]

[tasks.build-aarch64-uefi]
description = "Builds the aarch64 DXE Readiness Capture UEFI binary."
env = { RUSTFLAGS = "-C force-unwind-tables -C link-arg=/base:0x0 -C link-arg=/subsystem:efi_boot_service_driver -C link-arg=/PDBALTPATH:qemu_dxe_readiness_capture.pdb" }
command = "cargo"
args = ["build", "@@split(CAPTURE_BIN_FLAGS, )", "@@split(AARCH64_UEFI_TARGET, )", "--bin", "qemu_dxe_readiness_capture", "${@}"]

# Builds Validation binary for the host platform.
[tasks.build-validation-binary]
description = "Builds the DXE Readiness Validation binary."
[tasks.build-validation-binary-windows-x64]
description = "Builds the Windows x64 DXE Readiness Validation binary."
env = { RUSTFLAGS = "" } # Env variables are not cleaned up after execution, meaning that tasks following the executed task will inherit the variables set by the previous task.
condition = { platforms = ["windows"]}
command = "cargo"
args = [ "build", "-p", "dxe_readiness_validator", "@@split(X86_64_STD_WINDOWS_TARGET, )", "${@}", ]

[tasks.build-validation-binary-windows-aarch64]
description = "Builds the Windows aarch64 DXE Readiness Validation binary."
env = { RUSTFLAGS = "" } # Env variables are not cleaned up after execution, meaning that tasks following the executed task will inherit the variables set by the previous task.
condition = { platforms = ["windows"]}
command = "cargo"
args = [ "build", "-p", "dxe_readiness_validator", "@@split(AARCH64_STD_WINDOWS_TARGET, )", "${@}", ]
Copy link
Contributor

@Javagedes Javagedes Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this possible? Cross compilation support when it comes to target triples where there is an "STD" that relies on the operating system (e.g. a target triple with an OS) is not exactly supported from my understanding.

e.g. I can't really compile an aarch64-unknown-linux target on a aarch64-pic-windows-msvc target).

Seems like you should just not specify a target and let the compiler auto pick the host target.

Just have a generic build-validation-host-binary

If you need to set some feature flags or something based off the target tripple then you could not specify the target, then have a duckscript use the CARGO_MAKE_RUST_TARGET_TRIPLE to set feature flags.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then CI would just compile a different target of the binary based off the host its being run on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here is that, without explicitly specifying the target triple, the host binaries are produced under target/debug/... instead of target/<triple>/debug. This is usually not a problem for a normal development workflow, but if we want to release all flavors of host binaries (x64 and aarch64) using a workflow like .github/workflows/publish-binaries.yml, I am not sure how to identify each flavor when copying the artifacts.

cp target/x86_64-pc-windows-msvc/debug/dxe_readiness_validator.exe artifacts/validator/dxe_readiness_validator.exe
cp target/x86_64-pc-windows-msvc/debug/dxe_readiness_validator.pdb artifacts/validator/dxe_readiness_validator.pdb
cp target/aarch64-pc-windows-msvc/debug/dxe_readiness_validator.exe artifacts/validator/dxe_readiness_validator.exe
cp target/aarch64-pc-windows-msvc/debug/dxe_readiness_validator.pdb artifacts/validator/dxe_readiness_validator.pdb

So the patina-readiness-tool repo already has an explicit way of specifying the target triple for consistency(across platforms/arch), and unfortunately the makefile.toml in patina-devops is out of sync. This is being addressed in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I see two routes -

  1. Have a duckscript call that calls either rustc -vV or cargo metadata (see below) to grab the target triple, then set the triple so that it goes in the folder
output = exec cargo metadata --format-version 1 --no-deps --manifest-path ${repo}/Cargo.toml
if not eq ${output.code} 0
            echo "Error running cargo metadata on ${repo}"
            exit 1
        end

        metadata = json_parse --collection ${output.stdout}
  1. do the copying based off the image in the github workflow. e.g. if the workflow is running on windows-x86 image then copy it to the right target triple folder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a big fan of duck script 😄 and as mentioned before this is mainly to address below

  1. To make it consistent for the publish binaries workflow to package the artifacts
  2. Sync back what we already have in the patina-readiness-tool repo as a baseline.


[tasks.build-validation-binary-linux-x64]
description = "Builds the Linux x64 DXE Readiness Validation binary."
env = { RUSTFLAGS = "" } # Env variables are not cleaned up after execution, meaning that tasks following the executed task will inherit the variables set by the previous task.
condition = { platforms = ["linux"], env = { CARGO_MAKE_RUST_TARGET_ARCH = "x86_64" }}
command = "cargo"
args = [ "build", "-p", "dxe_readiness_validator", "@@split(X86_64_STD_LINUX_TARGET, )", "${@}", ]

[tasks.build-validation-binary-linux-aarch64]
description = "Builds the Linux aarch64 DXE Readiness Validation binary."
env = { RUSTFLAGS = "" } # Env variables are not cleaned up after execution, meaning that tasks following the executed task will inherit the variables set by the previous task.
condition = { platforms = ["linux"], env = { CARGO_MAKE_RUST_TARGET_ARCH = "aarch64" }}
command = "cargo"
args = [ "build", "-p", "dxe_readiness_validator", "${@}", ]
args = [ "build", "-p", "dxe_readiness_validator", "@@split(AARCH64_STD_LINUX_TARGET, )", "${@}", ]

[tasks.build]
description = "Build all binaries."
clear = true
dependencies = [
"build-x64-uefishell",
"build-aarch64-uefishell",
"build-intel-lnl",
"build-intel-ptl",
"build-intel-common", # Build Intel LNL and PTL binaries
"build-x64-uefi",
"build-aarch64-uefi",
"build-validation-binary",
"build-validation-binary-windows-x64",
"build-validation-binary-windows-aarch64",
"build-validation-binary-linux-x64",
"build-validation-binary-linux-aarch64",
]

# Tests will be built and run based on the host platform.
Expand All @@ -90,15 +112,10 @@ description = "Build and run tests for DXE Readiness Validation binary."
command = "cargo"
args = ["test", "-p", "dxe_readiness_validator", "${@}"]

[tasks.test-common]
description = "Build and run tests for Common lib."
command = "cargo"
args = ["test", "-p", "common", "${@}"]

[tasks.test]
description = "Build and run tests for all binaries."
clear = true
dependencies = ["test-capture-binary", "test-validation-binary", "test-common"]
dependencies = ["test-capture-binary", "test-validation-binary"]

# Run validator binary for all supported targets.
[tasks.run-validator]
Expand Down