A Reproducible Test Design for Evaluating LLM-Assisted Firmware Compilation

    This article details a reproducible test methodology for evaluating whether large language models (LLMs) can complete a real-world compilation task—specifically, building a UEFI firmware image from the edk2 source tree. We define the exact scope, the criteria for success, a required data-recording checklist for reproducibility, and a comparative breakdown of model performance. We observe that six earlier general-purpose models completed the task, while two newer models did not. We also analyze common failure points and provide a practical checklist for teams looking to run similar evaluations, emphasizing the importance of version pinning, build cleanups, and log preservation for verifying conclusions.

    Key Takeaways

    • Test Scope: A single UEFI firmware compilation task (EmulatorPkg), with the sole success criterion being whether a bootable image is generated.
    • Observation: Six earlier general-purpose models completed the task; two newer models did not.
    • Limitations: This is based on a single task with one run per model, and version information was incomplete. The results only reflect performance under these specific conditions and should not be interpreted as a model ranking.

    Test Objective and Boundaries

    This evaluation was designed to answer one question: Can a model modify the build description files in a given edk2 source tree and successfully compile a firmware image? The test does not assess code generation quality, explanatory ability, or other engineering tasks.

    The task involved four distinct types of work:

    1. Identifying the toolchain.
    2. Modifying module and library declarations in the .dsc file.
    3. Adjusting the image layout in the .fdf file.
    4. Handling header file paths and link order.

    The definition of success was binary: the firmware image file must exist, and the emulator must boot to a pre-specified target interface, such as the UEFI Shell.

    Required Data Checklist for Reproducibility

    Before beginning any test, the following items must be defined and recorded. Without this data, the conclusions cannot be verified. The original test logs were missing several of these entries; therefore, this article provides observational conclusions rather than a precise ranking.

    Item Data to Record Notes
    Model Name, version, sampling temperature, max output tokens Sampling parameters can affect result randomness.
    edk2 Source Git commit hash Capture with git rev-parse HEAD.
    Toolchain Compiler name and version (e.g., GCC, Clang) Capture with commands like gcc --version.
    System Environment OS, kernel version, Python version Capture with commands like uname -a.
    Dependency Tools Versions for tools like nasm, iasl Different versions can produce different error messages.
    Initial Files Hash of .dsc and .fdf before test start Record with sha256sum to enable diffing changes.
    Build Command Full command line, including platform, architecture, and toolchain Example: build -a X64 -t GCC5 -p EmulatorPkg/EmulatorPkg.dsc (verify against the actual project).
    Success Criteria Image file path and emulator boot marker Image exists and emulator reaches the specified interface.
    Scoring Method Score 1 for success, 0 for failure; log the round of first success Set a round limit in advance (e.g., 20 rounds).

    Model Performance Comparison

    The original models are referenced by code names in this article. The original test records did not fully preserve version information, and since this article does not rank specific vendors, actual names are not disclosed.

    Model Result Attempts Primary Failure Stage Original Log Notes
    Reference Model A Completed Not recorded Dependency resolution Resolved all dependency issues in approximately 3 rounds.
    Reference Model B Completed Not recorded .fdf segment address mapping Supplied missing mappings by referencing similar project templates.
    Reference Models C to F Completed Not recorded Not recorded The original log did not differentiate between them.
    V-Pro Not Completed Not recorded Header paths, link stage Repeatedly assumed environment variables were not set.
    V-Flash Not Completed Stopped after 2 attempts Build terminated prematurely Suggested a LibraryClasses order that broke the build.

    Observations from Reference Models: The behavior of the reference models suggests they could trace compilation errors back to module declarations in the .dsc file and could reference templates to complete the .fdf. However, since the original record did not save per-round logs, these specific actions cannot be verified.

    V-Pro Failure Analysis: Across multiple attempts, V-Pro repeatedly modified the DEFINE macros and Flash size. When encountering “header file not found” errors, it chose to install or switch dependencies instead of checking the #include paths. In later stages, it hypothesized that environment variables were unset and suggested running source commands, but did not verify the actual impact of those commands on the edk2 build.

    V-Flash Failure Analysis: After two attempts, V-Flash suggested debugging on real hardware rather than analyzing the cause of the cross-compilation failure. In a subsequent follow-up, its suggested LibraryClasses ordering caused the build to terminate prematurely.

    How to Validate Failure Reasons

    The original record contains several judgments about failure causes, but the corresponding logs were not attached. These judgments may be correct but must be verified using the following methods.

    Example Validation: The “NULL pointer initialization error”
    To verify if an error originates from the linker rather than runtime code, follow these steps:

    1. Check the error line prefix: Compilation errors typically point to a source file and line number. Linker errors often contain terms like undefined reference or multiple definition.
    2. Determine the build phase: Identify whether the failure occurred during pre-processing, compilation, linking, or runtime. If the log shows undefined reference during the link phase, the original judgment is likely correct. If it is only a warning during compilation, the judgment needs to be revised.
    3. Clean and rebuild: Remove the build directory (or use edk2’s clean mechanism) and rebuild to rule out interference from stale intermediate artifacts.

    The Impact of Stale Build Artifacts: Build systems retain intermediate files. If a model only modifies source files without cleaning the cache, subsequent results can be affected by old objects. For instance, V-Pro deleted module references to get past the compilation phase, which could lead to undefined symbols during the link phase. To confirm this, one would need to diff the file changes and link logs between two builds.

    Selection Checklist

    1. Pin Versions: Record the hashes of the edk2 commit, toolchain, and any container images.
    2. Clean Before Each Round: Use the edk2-provided cleanup method or delete the Build/ directory to minimize cache interference.
    3. Preserve Logs: Save standard output, standard error, and relevant build artifacts for every attempt. Without this data, subsequent failure analysis cannot be validated.