summaryrefslogtreecommitdiff
path: root/BaseTools
AgeCommit message (Collapse)AuthorFilesLines
2026-07-22BaseTools: Add support for preserving build IDChris Fernald4-8/+110
Adds an optional flag that copies the GNU build-id note from the input ELF file into the output PE/COFF firmware image as a dedicated ".bldid" section. The build ID is emitted by the linker as a unique fingerprint of the binary and allows custom post-build and debugging tools to reliably match a firmware image against its corresponding unstripped ELF and debug symbols, without relying on file names, timestamps, or build paths. This notable opts to use a non-standard section name ".bldid" to store the build ID. This approach was chosen to keep genfw and the parsers simple since the full "build-id" name would require redirecting the section name. While this breaks from standard conventions, this is not impactful since GenFW is already creating a non-standard artifact for the PE image with the associated ELF symbol file. Signed-off-by: Chris Fernald <chfernal@microsoft.com>
2026-07-18BaseTools/Trim.py: Strip "#pragma once" from inlined ASL contentMichael Kubacki1-0/+4
When Trim processes an ASL file (`--asl-file`), it textually inlines the body of every `Include()`'d file directly into the constructed preprocessor input, once per include site. Its has duplicate protection in the form of a circular-include stack (`gIncludedAslFile`), that prevents A->B->A cycles. But, as far as the script is concerned, each `Include()` is a unique include site. Various combinations of includes and file types are possible and handled slightly differently. Starting with file types as defined in BaseTools\Conf\build_rule.template: - `.aslc`, `.act` files fall under `Acpi-Table-Code-File` and are compiled, linked, and processed by genfw. - `.asl`, `.Asl`, and `.ASL` files fall in `Acpi-Source-Language-File` and are processed by Trim: 1. `Trim --asl-file` to produce a single combined .i file with includes inlined. 2. `ASLPP` (ASL preprocessor, a C preprocessor) on the output of Trim to produce a .iii file with all macros expanded and conditional branches resolved. AutoGen.h is also included and processed here to resolve fixed PCD values if needed. 3. `Trim --source-code` which takes the pre-processed .iii file and produces a .iiii file with content like linemarkers cleaned up. 4. The ACPI compiler compiles the .iiii file to produce AML bytecode in a .aml file. Because the `.aslc`/`.act` files are directly passed to normal C processing tools, they are not part of the Trim change made in this commit and the remainder of this message focuses on the ACPI Source Language File case. ASL files can use either an ASL `Include()` directive or a C-style `#include` directive. In addition, different file types may be included such as a `.asl` file or a `.h` file. `Trim` handles these cases differently: - For ASL `Include()` directives, `Trim` inlines the content of the included file directly into the output at the include site. This is done for all included ASL files regardless of their extension. The inlining is purely textual and does not attempt to resolve or preserve any preprocessor directives such as `#pragma once` or include guards. - For C-style `#include` directives, `Trim` checks the file extension of the included file. If the file is an ASL file (`.asl` or `.asi`), `Trim` treats the file the same as the `Include()` case. Otherwise, `Trim` passes the directive through verbatim to the output, allowing the downstream C preprocessor (`ASLPP`) to handle it according to normal C preprocessor rules. This creates a situtation in which the resulting `.i` might include: - Inlined file content (from a `.asl` or `.h` file) depending on the include type and file extension. - Verbatim `#include` directives for non-ASL files which will be processed by the C preprocessor. Focusing on the "inlined" case, historically `.h` files would have traditional C include guards (`#ifndef`/`#define`, `#endif`). However, files might also include `#pragma once` as a guard. In that case, the inlined content of the `.i` file could contain multiple `#pragma once` directives, one per include site. When the C preprocessor (`ASLPP`) processes the `.i` file, it sees multiple `#pragma once` directives in what it considers the main file, and could emit a warning like the following from gcc: warning: '#pragma once' in main file [-Wpragma-once-outside-header] The remainder of this commit message describes the change made to address this warning. This change strips "#pragma once" lines on the ASL content path in `DoInclude()` in `Trim.py` so the directive is removed before it reaches the C preprocessor. - "#include" directives for non-ASL files are still passed through verbatim for the C preprocessor to resolve where the contents of those .h files might contain "#pragma once" or traditional guards. - Traditional include guards are untouched and continue to behave as before where multiple include sites might inline the same content in the .i file before reaching the C preprocessor. The change: In the case that a file is inlined with a `#pragma once` directive, the directive is stripped from the inlined content which prevents the warning. This is considered acceptable because it only removes the `#pragma once` directive from the inlined content for these specific cases. So, the `.i` file might contain multiple inlined copies of the same header content (like always in this inline case) but without the `#pragma once` directives. Because actual C content was already not processed or trimmed out (e.g. `typedef struct`) duplicate content is not considered to be a problem (`#define` multiple times is not a problem for the C preprocessor). Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-07-17BaseTools/build.py: Use full source file path for dependency generationkowsiks1-3/+26
During Silent build,NMAKE suppresses the command echo entirely. As a result, the only output in ProcOut is the MSVC compiler’s output lines. Without the command echo, there is no full path in the output to identify which source file is currently being compiled. For unique basenames this is not an issue, but for namesake files (for example, AmdSev.c located in different directories), it is impossible to determine which file’s includes are being listed. This change improves dependency generation for MSVC builds by introducing explicit handling for source files with duplicate basenames (namesake sources). A new variable current_source_abs is added to consistently track the resolved absolute path of the active source file instead of repeatedly recomputing it from SourceFileAbsPathMap. To correctly resolve namesake files in silent builds (where compiler commands are not echoed), a namesake_queue is introduced, which preserves source ordering and sequentially maps basename occurrences to their corresponding full paths. Additionally, a cc_cmd_in_output flag is implemented to detect the presence of compiler command lines in the output stream; when present, source paths are derived directly from command-line arguments, otherwise the queue-based resolution is used. This ensures correct mapping of basenames to absolute paths across the silent builds, fixing incorrect dependency generation when multiple source files share the same name. Signed-off-by: Kowsik S <kowsiks@ami.com>
2026-07-16BaseTools/Tests: Update TC6 for backward-compatible rebase behaviorMichael D Kinney1-10/+11
Update the test decision matrix and TC6 expected result to reflect the backward-compatible ForceRebase logic: when ForceRebase=TRUE and no files have the ,XIP suffix (XipFileCount==0), all files are rebased using the legacy behavior rather than skipping all files. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-07-16BaseTools/GenFv: Preserve legacy rebase behavior when Xip is unusedMichael D Kinney2-2/+6
Add XipFileCount to FV_INFO to track how many files have the ,XIP suffix. Update FfsRebase() to only apply selective XIP rebase when XipFileCount > 0. When no files have the ,XIP suffix (XipFileCount == 0), preserve the legacy ForceRebase=TRUE behavior of rebasing all files. This maintains backward compatibility for existing platforms that use FvForceRebase=TRUE without any Xip rules. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-07-11BaseTools/Plugin/CodeQL: Add CodeQL version update scriptMingjie Shen4-0/+327
Add a maintenance script that updates the CodeQL CLI dependency YAML files and CodeQlQueries.qls together. The script refreshes the CLI version, release digests, and cpp query pack pin from the GitHub release metadata and the corresponding qlpack.yml in the CodeQL CLI release branch. Add comments to the CodeQL CLI dependency YAML files that direct maintainers to use the script for future version updates. Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2026-07-11BaseTools/Plugin/CodeQL: Update CodeQL CLI to v2.25.3Mingjie Shen4-10/+10
Update CodeQL external dependency definitions to v2.25.3 for generic, Linux, and Windows archives, including refreshed SHA256 hashes from the release metadata. Pin the codeql/cpp-queries query pack to version 1.6.1, as specified in the qlpack.yml at: https://github.com/github/codeql/blob/codeql-cli/v2.25.3/cpp/ql/src/qlpack.yml Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2026-07-09BaseTools/GenFds: Print INF name on Depex eval failureChristopher Zurcher1-1/+5
Signed-off-by: Christopher Zurcher <christopher.zurcher@microsoft.com>
2026-07-07BaseTools: Enable stack protector for LoongArch64Chao Li1-2/+2
LoongArch64 GCC or CLANG currently does not support the parameter `-mstack-protector-guard=global`, but if `-fstack-protector` is enabled, the guard is global. The `-mstack-protector-guard` may be get supportted in the next GCC release, possibly GCC17. Signed-off-by: Chao Li <lichao@loongson.cn> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Guillermo Antonio Palomino Sosa <guillermo.a.palomino.sosa@intel.com> Cc: Yuwei Chen <yuwei.chen@intel.com> Cc: Poncho Figueroa <poncho.figueroa.esqueda@intel.com> Cc: Mike Beaton <mjsbeaton@gmail.com>
2026-07-01BaseTools: Remove VS2017 supportMichael Kubacki5-298/+6
Removes Visual Studio 2017 support from BaseTools. Newer toolchains (VS2019, VS2022, and VS2026) are supported in its place. This removes the VS2017 toolchain definitions from tools_def.template, the VS2017 environment setup logic in toolsetup.bat, set_vsprefix_envs.bat, and get_vsvars.bat, and the VS2017 configuration in the WindowsVsToolChain build plugin. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-07-01BaseTools: Remove VS2015 supportMichael Kubacki4-258/+3
REF: https://github.com/tianocore/edk2/issues/12490 Removes Visual Studio 2015 support from BaseTools since mainstream support ended on October 13, 2020 and extended support ended on October 14, 2025. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-07-01BaseTools: Remove SetVisualStudio.batMichael Kubacki1-82/+0
This file has: - Not been updated in 10 years. - Was used to build Nt32Pkg which no longer exists. - Is not needed to currenly build EmulatorPkg. - Was last updated to support Visual Studio 2015, which is no longer supported by Microsoft. It is removed as part of the Visual Studio 2015 removal. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-07-01BaseTools: Remove ShowEnvironment.batMichael Kubacki1-169/+0
This file: - Has not had a code change in 8 years. - Is not used by any other file in the repository. - Was last updated to support VS2015 which is no longer supported by Microsoft. As part of VS2015 support removal, this file is deleted. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-06-26BaseTools/Ecc: Add check for traditional include guardsMichael Kubacki4-0/+76
Adds a new ECC check, `IncludeFileCheckPragmaOnce` (error code 6006), that flags header files using a traditional `#ifndef`/`#define` include guard and recommends `#pragma once` instead. A guard is detected when a '#ifndef NAME' is immediately followed by a valueless '#define NAME' using the same macro name. Feature macros such as '#define FOO 1' and files already using '#pragma once' are not flagged. The check reports against the parsed preprocessor directive rows in the identifier tables rather than the File table. Those rows carry the actual source line number, whereas File-level findings resolve to "line 1" in the report. This gives an accurate line number, to the EccCheck CI plugin, so it can reconcile findings with the changed line ranges of a commit. It uses the binary extension list and the exception list, consistent with the other include file checks. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-06-26BaseTools: Fix MODEL_IDENTIFIER_MACRO_PROGMA typoMichael Kubacki4-5/+5
Fixes typo in the constant name. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-06-24BaseTools/tools_def RISCV: Enable -Os optimizationTuan Phan1-1/+1
Switch GCC RISCV builds to use GCC_ALL_CC_FLAGS so that the -Os compiler flag is applied during compilation. For RiscVVirt target, this reduces DXEFV size by ~30%. Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
2026-06-23BaseTools/Build: Fix arch macro expansion scope in DSC parserKirk Chou1-1/+11
Signed-off-by: Kirk Chou <kirk.chou@hpe.com>
2026-06-22BaseTools/Tests: Add FV section keyword order parser testsMichael D Kinney1-0/+115
Add TestFdfParserFvKeywordOrder test class with 8 parameterized subtests verifying that FV-level keywords (FvForceRebase, FvBaseAddress, FvAlignment) can be freely interleaved with FV attribute flags in any order within an [FV] section. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-06-22BaseTools/GenFds: Fix FV attribute parser to allow any keyword orderMichael D Kinney1-2/+2
Fix _GetFvAttributes() to return True when it has successfully parsed at least one attribute before encountering a non-attribute keyword. Previously it always returned False on encountering an unrecognized word, even after consuming prior attributes. This caused the outer parsing loop to break prematurely when FvForceRebase, FvBaseAddress, or FvAlignment appeared between FV attribute flags (e.g. between ERASE_POLARITY and MEMORY_MAPPED), resulting in a Python stack trace. Move IsWordToken assignment to after successful attribute parsing and change the early return from 'return False' to 'return IsWordToken'. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-06-22BaseTools/Tests: Add PE32 section keyword order parser testsMichael D Kinney1-0/+157
Add TestFdfParserPe32KeywordOrder test class with 17 parameterized subtests covering all permutations of Align, Xip, and RELOCS_STRIPPED/RELOCS_RETAINED keywords in PE32 section statements. Tests verify pairwise orderings, all 6 three-keyword permutations, single-keyword cases, and Xip=FALSE/RELOCS_RETAINED variants. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-06-22BaseTools/GenFds: Allow PE32 section keywords in any orderMichael D Kinney1-25/+26
Replace sequential if-statements for Align, Xip, and RELOCS_STRIPPED/RELOCS_RETAINED parsing in _GetEfiSection() with a while-loop that accepts these keywords in any permutation. Previously, specifying Xip before Align in a [Rule] PE32 section caused a Python stack trace. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-06-22BaseTools/Tests: Add unit and functional tests for XIP rebaseMichael D Kinney2-0/+849
Add TestGenFvXip.py with 19 parameterized subtests covering the complete XIP rebase decision matrix: - 11 unit subtests validating DetermineXipEnabled() with RuleComplexFile and RuleSimpleFile objects covering Xip attribute parsing (TRUE/FALSE/None, case insensitive, boolean vs string). - 8 functional subtests that run real edk2 builds with generated DSC/FDF files exercising all ForceRebase/BaseAddress/Xip combinations. Each test verifies: 1. FV INF file contains correct ,XIP suffixes 2. FV map file shows correct rebase status (Fixed Flash Address) 3. PE/COFF ImageBase in the FV binary matches expected value Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-06-22BaseTools/GenFv: Parse ,XIP suffix for per-file rebase controlMichael D Kinney2-2/+24
Update ParseFvInf() to detect and strip ",XIP" suffix from EFI_FILE_NAME values in the FV INF file. Store the per-file XIP flag in the new XipFile[] array in the FV_INFO structure. Add FileIndex parameter to FfsRebase() so it can look up the XIP flag for the current file. When ForceRebase is TRUE, only rebase files that have their XipFile[] entry set to TRUE. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-06-22BaseTools/GenFds: Propagate Xip flag to FV INF via ,XIP suffixMichael D Kinney4-0/+44
Add Xip attribute to FDF Rule class and parse the Xip keyword in EFI section rules of FDF files. Add XipEnabled attribute to FfsInfStatement that is determined from the applicable FDF Rule's section Xip setting. When generating the FV INF file, append ",XIP" to EFI_FILE_NAME entries for modules whose Rule specifies Xip=TRUE. This enables per-file XIP rebase control in GenFv by communicating which files require XIP rebase directly in the FV INF file format. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-06-22BaseTools/GenFw: Fix LoongArch ELF-to-PE RVA conversionDongyan Qian1-17/+31
GenFw converts linked ELF images to PE/COFF images using a new section layout. The generated PE/COFF section RVAs are not required to match the linked ELF section addresses, so relocation fixups that rewrite section contents must use the generated PE/COFF RVA space. A linker script layout change can expose this on LoongArch64 when .text and .data are linked with 0x1000 alignment while .hii still keeps a 0x4000 alignment. GenFw then keeps a 0x4000 PE/COFF section alignment because of .hii, producing different ELF and PE/COFF layouts. Fix two LoongArch relocation paths exposed by this layout mismatch. R_LARCH_64 entries stored in section contents, such as switch jump tables, must be translated from the linked ELF section address space to the generated PE/COFF RVA space. R_LARCH_PCALA_* and R_LARCH_GOT_PC_* must also convert the referenced symbol to its generated PE/COFF RVA before calculating the PC-relative offset. The LoongArch ELF ABI defines PCALA/GOT_PC relocations as page-based, but this GenFw path rewrites the HI/LO pair to PCADDU12I plus ADDI.D. After that rewrite, the offset split must be based on the generated PE/COFF instruction-relative offset. For example, in the failing LogoDxe image, _gUefiDriverRevision is at ELF address 0x5400 in .text, and the relocation referencing it is at ELF address 0x104c. With ELF .text at 0x1000 and PE/COFF .text at 0x4000, the generated PE/COFF RVAs are 0x8400 for the symbol and 0x404c for the relocation site. Mixing the ELF symbol address with the PE/COFF relocation-site RVA makes the entry wrapper read PE/COFF RVA 0x5400 instead of 0x8400, causing EFI_INCOMPATIBLE_VERSION. Use PE/COFF RVAs consistently when rewriting LoongArch absolute and PC-relative references during WriteSections64(). The existing WriteRelocations64() base relocation emission is kept for load-time image rebasing. Reported-by: Chao Li <lichao@loongson.cn> Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn> Signed-off-by: Chao Li <lichao@loongson.cn> Tested-by: Dongyan Qian <qiandongyan@loongson.cn>
2026-06-22BaseTools: strip trailing whitespace in build_rule.templateLeif Lindholm1-14/+14
Since most editors just ignore it, only source files get syntax checked, and next to no one looks at their diffs before raising a PR, trailing whitespace keep piling up in particularly this file. Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
2026-06-17BaseTools: Update tools_def.template version to 3.07Michael Kubacki1-1/+8
Commit 87e486f defined a 3.07 version for tools_def.template, but the version in the file was not updated. This commit updates the version to 3.07 and includes changes made since 3.06. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-06-12BaseTools/HostBasedUnitTestRunner.py: Fix SyntaxWarningsMichael Kubacki1-3/+3
Three invalid escape sequence SyntaxWarnings are reported because `'\|'` is being escaped. This change consistently wraps all cases where the character is used in double quotes, so the character is preserved and the warnings are resolved. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-05-29BaseTools: Edk2BaseToolsBuild.py: Clean Before Building on WindowsOliver Smith-Denny1-3/+42
Currently, Edk2BaseToolsBuild.py cleans before doing the build on Linux, but doesn't do so on Windows. It has been observed on Windows that the incremental build can lead to a bad state of some logic from the old build and some from the new build. This commit aligns Windows to Linux and always do a clean before building on both OSes. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-05-26BaseTools: Add CLANGDWARF support for LoongArch64Chao Li1-3/+50
Added LoongArch64 CLANGDWARF compiler support. It requires the LLVM version 22.1.0-rc1 or higher. Signed-off-by: Chao Li <lichao@loongson.cn> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Guillermo Antonio Palomino Sosa <guillermo.a.palomino.sosa@intel.com> Cc: Yuwei Chen <yuwei.chen@intel.com> Cc: Poncho Figueroa <poncho.figueroa.esqueda@intel.com> Cc: Mike Beaton <mjsbeaton@gmail.com>
2026-05-26BaseTools: Adjust the LoongArch PC related static relocationChao Li1-60/+85
The relocation methods of R_LARCH_PCALA_HI20, R_LARCH_PCALA_LO12, R_LARCH_GOT_PC_HI20 and R_LARCH_GOT_PC_LO12 have been optimized to support cases where HI is not adjacent to LO and where one HI corresponds to multiple LOs. Signed-off-by: Chao Li <lichao@loongson.cn> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Guillermo Antonio Palomino Sosa <guillermo.a.palomino.sosa@intel.com> Cc: Yuwei Chen <yuwei.chen@intel.com> Cc: Poncho Figueroa <poncho.figueroa.esqueda@intel.com> Cc: Mike Beaton <mjsbeaton@gmail.com>
2026-05-26BaseTools/Capsule: Prevent to Read the STDOUT Content as SignatureJason1 Lin1-6/+30
- Within the capsule generate script, it is using the STDOUT result as signature while signing the hash digest via OpenSSL tool. - There would have incorrect result when the user terminal have the output when executing the startup script. - Incorrect the content of signature would make the verification failed. - Use the "-output" flag to export the signature then read it back as the resolution. Signed-off-by: Jason1 Lin <jason1.lin@intel.com>
2026-05-23BaseTools/Conf: Add -malign-double to IA32 ASLCC flagsAaron Pop1-4/+4
When compiling an IA32 .aslc source file that includes Base.h, the GCC static asserts for fundamental type sizes fail because 64-bit types such as UINT64 are only 4-byte aligned by default in 32-bit mode. Adding -malign-double causes the compiler to align 64-bit values on 8-byte boundaries, matching the alignment assumed by the static asserts. This fix is applied to the GCC, GCCNOLTO, CLANGPDB, and CLANGDWARF toolchain IA32 ASLCC_FLAGS entries. REF: #12517 Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
2026-04-28BaseTools: Add GENFWHII_FLAGS to fix VS2026 GenFw build issueYang Gang1-0/+1
Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
2026-04-27BaseTools/PatchCheck.py: Skip length check for Co-authored-by lineYang Gang1-0/+1
Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
2026-04-23BaseTools: Add missing machine types while dumping Option RomQihang Gao1-0/+2
When dumping LOONGARCH64 or RISCV64 Option Rom by `EfiRom -d test.rom` command, the machine type is showed as `unknown`. This patch adds type lookup strings for the two architectures. Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
2026-04-21BaseTools: Reject Inline Comments in tools_defOliver Smith-Denny1-0/+4
There is a bug in BaseTools currently when an inline comment is used in tools_def. The comment is not stripped out and wreaks havoc down the line, causing BaseTools to get confused elsewhere and drop build options it should be applying. This fixes that behavior by following the build spec which states: Comments are only allows on separate lines and may not be appended appear on actual entry lines. Inline comments are now not allowed and the build will fail and specify why and where. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-04-15BaseTools: tools_def: Align X64 CLANGDWARF and CLANGPDB DefsOliver Smith-Denny1-2/+2
Currently, CLANGPDB X64 has 4KB section alignment and unwind tables. CLANGDWARF has neither. 4KB section alignment is up for review in a separate PR, so this commit adds unwind tables to DEBUG/NOOPT, matching both CLANGPDB and other toolchains. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-04-15BaseTools: tools_def: Canonicalize CLANGDWARF DefsOliver Smith-Denny1-120/+123
Currently, the CLANGDWARF definitions for AARCH64 and RISCV64 (which was copied from the AARCH64 definitions originally) don't follow the same pattern as CLANGDWARF IA32/X64 and the rest of tools_def.template. This makes it harder to read and easier to make an error (e.g. other toolchain define cc/dlink flags in debug, release, noopt order, they do it in debug, noopt, release order, so it would be easy to swap flags intended for release and noopt). This is a whitespace and comment only change, no flags are changed. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-04-11BaseTools/Conf: Add missing CLANGDWARF OBJCOPY_FLAGSMichael D Kinney1-0/+2
Fix CLANGDWARF OBJCOPY errors for AARCH64 and RISCV64 by setting OBJCOPY_FLAGS to an empty string so OBJCOPY actions do not generate an error. This matches the IA32 and X64 settings for CLANGDWARF OBJCOPY_FLAGS. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-04-10BaseTools: add --apply-dynamic-relocs option for AARCH64 CLAGNDWARFYeoreum Yun1-3/+3
StandaloneMm is loaded failure when it built with clang-22. This is because mMmMemoryMap is intialised incorrectly by compiler: MmMain - 0xFF025040 [StandaloneMmMain:849] mMmMemoryMap: 0xFF21D238 [StandaloneMmMain:850] mMmMemoryMap->ForwardLink: 0xFF201000 [StandaloneMmMain:851] mMmMemoryMap->BackLink: 0xFF201000 The 0xFF20100 is loaded image address. However list_head -- mMemoryMap doesn't initialised properly by ld-lld. Here, ld with gcc initialised mMmMemoryMap list head properly: // 0x12490: &mMmMemoryMap # hexdump -Cv -s 0x12490 -n 64 StandaloneMmCore.efi 00012490 90 24 01 00 00 00 00 00 90 24 01 00 00 00 00 00 |.$.......$......| ... However, ld-lld with clang doesn't: // 0x1c238: &mMmMemoryMap # hexdump -Cv -s 0x1c238 -n 64 StandaloneMmCore.efi 0001c238 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| To address this, add --apply-dynamic-relocs linker option. After this patch, StandaloneMm is loaded preoperly and mMmMemoryMap is intialised correctly: ld-lld with clang with --aply-dynamic-reclos option: // 0x1d238: &mMmMemoryMap # hexdump -Cv -s 0x1d238 -n 64 StandaloneMmCore.efi 0001d238 38 d2 01 00 00 00 00 00 38 d2 01 00 00 00 00 00 |8.......8.......| Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
2026-04-09BaseTools: Ecc: Update to ANTLR 4.13.2Oliver Smith-Denny5-1407/+857
ANTLR 4.9 is broken in python 3.13 because it uses a library in the autogenerated files that is removed. This updates to 4.13.2 and also updates the autogen files, which contain support for python 3.13 as well as backwards compat. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-04-09BaseTools: Ecc: Use SPDX in AutoGen TemplateOliver Smith-Denny1-10/+2
The ANTLR autogen files are currently created without an SPDX identifer. Add the BSD-2-Clause-Patent ID. While here, correct the command to do the autogeneration by using the right filename. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-04-09BaseTools: Ecc: Drop ANTLR 3 SupportOliver Smith-Denny4-24447/+0
BaseTools hasn't been using ANTLR3 since at least 2019. Drop the files. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-04-03BaseTools: Only check for GCC prefixes when targetingAaron Pop1-13/+16
LinuxGccToolChain is checking for the environment variable GCC_AARCH64_PREFIX when GCC_AARCH64_INSTALL is set in the environment variables. GCC_AARCH64_INSTALL is set when any gcc aarch64 compiler is installed (i.e. aarch64-none-elf, aarch64-linux-gnu, aarch64-unknown-elf all result in a GCC_AARCH64_INSTALL environment variable). When compiling for an X86 target, if an AARCH64 tool chain is installed in the system, this will result in an error due to the GCC_AARCH64_PREFIX not being set. Add a check based upon TARGET_ARCH and and only verify the prefixes when attempting to build AARCH64. Replicate the same check for RISCV and LOONGARCH64 architectures as well. Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
2026-04-02BaseTools: Enable 4k alignment for tool chainsAaron Pop2-27/+32
Reordering x64 toolchain defines (GCCS) to use a DLINK_XIPFLAGS to set common-page-size to 0x40. Otherwise use default align (0x1000 for x64). Reorder CLANGDWARF toolchain defines to use DLINK_XIPFLAGS to set common-page-size to 0x40 (matching existing behavior) and otherwise use default linker value (0x1000 for x64). Required modifying build_rule.template to support CLANGDWARF build family for SEC, PEI_CORE, PEIM type files. Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
2026-04-01BaseTools/Plugin: Add lcov error tolerance for vendored source treesDoug Flick1-2/+7
lcov v2.0+ treats several gcov/source-related conditions as fatal errors that were previously warnings in v1.x. This causes coverage capture to abort when the build tree includes vendored third-party sources (e.g. OpenSSL) that produce gcov mismatches, missing source references, unexpected gcov output, or non-zero gcov return codes. Signed-off-by: Doug Flick <dougflick@microsoft.com>
2026-03-26BaseTools: Enable control flow guard for Windows buildsKun Qin2-6/+6
Certain environments require Control Flow Guard (CFG) to be enabled at build time as part of their security hardening requirements. This change adds the necessary compiler and linker flags to enable CFG support. Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2026-03-26BaseTools: Suppress C4028 warning to support older VS toolchain buildsKun Qin1-0/+6
Add conditional suppression of MSVC warning C4028 (formal parameter different from declaration) when building with Visual Studio 2017 or earlier toolchain. This warning is triggered by brotli submodule and not emitted by newer compilers, hence a conditional supression is used. Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2026-03-13BaseTools: GenFfs/GenFv/GenSec: Fixing Warning 4319 from MSVCKun Qin3-3/+3
This change fixes a warning newly emitted by the latest MSVC, which now treats this warning as an error and causes the build to fail. This change aligns operand types in bitwise expressions by casting sizeof results to UINT32, and promoting a UINT32 to UINTN where required to correctly apply the bitmask. Signed-off-by: Kun Qin <kun.qin@microsoft.com>