Commit Graph
3231 Commits
Author SHA1 Message Date
Oliver Smith-Dennyandmergify[bot] b313503a60 BaseTools: Edk2BaseToolsBuild.py: Clean Before Building on Windows
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-29 05:28:53 +00:00
Chao Liandmergify[bot] ee6abc021d BaseTools: Add CLANGDWARF support for LoongArch64
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-26 13:07:30 +00:00
Chao Liandmergify[bot] 1416dcb8df BaseTools: Adjust the LoongArch PC related static relocation
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-26 13:07:30 +00:00
Jason1 Linandmergify[bot] ddd94f778b BaseTools/Capsule: Prevent to Read the STDOUT Content as Signature
- 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-26 06:51:14 +00:00
Aaron Popandmergify[bot] 80fd66aef9 BaseTools/Conf: Add -malign-double to IA32 ASLCC flags
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-05-23 01:10:40 +00:00
Yang Gangandmergify[bot] 3449c60bab BaseTools: Add GENFWHII_FLAGS to fix VS2026 GenFw build issue
Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
2026-04-28 01:30:25 +00:00
Yang Gangandmergify[bot] b6c1c1afdc BaseTools/PatchCheck.py: Skip length check for Co-authored-by line
Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
2026-04-27 06:23:00 +00:00
Qihang Gaoandmergify[bot] 5e2bea1a74 BaseTools: Add missing machine types while dumping Option Rom
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-23 05:31:47 +00:00
Oliver Smith-Dennyandmergify[bot] be4fc071eb BaseTools: Reject Inline Comments in tools_def
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-21 00:18:43 +00:00
Oliver Smith-Dennyandmergify[bot] 0d44f421a5 BaseTools: tools_def: Align X64 CLANGDWARF and CLANGPDB Defs
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-15 01:57:51 +00:00
Oliver Smith-Dennyandmergify[bot] 192b5a92b3 BaseTools: tools_def: Canonicalize CLANGDWARF Defs
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-15 01:57:51 +00:00
Michael D Kinneyandmergify[bot] d4a6e02659 BaseTools/Conf: Add missing CLANGDWARF OBJCOPY_FLAGS
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-11 00:40:10 +00:00
Yeoreum Yunandmergify[bot] ec1f28670a BaseTools: add --apply-dynamic-relocs option for AARCH64 CLAGNDWARF
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-10 05:14:40 +00:00
Oliver Smith-Dennyandmergify[bot] 35c03c1c9f BaseTools: Ecc: Update to ANTLR 4.13.2
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-08 22:23:35 +00:00
Oliver Smith-Dennyandmergify[bot] 9b676f7cc2 BaseTools: Ecc: Use SPDX in AutoGen Template
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-08 22:23:35 +00:00
Oliver Smith-Dennyandmergify[bot] 229600664e BaseTools: Ecc: Drop ANTLR 3 Support
BaseTools hasn't been using ANTLR3 since at
least 2019. Drop the files.

Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-04-08 22:23:35 +00:00
Aaron Popandmergify[bot] b7cf7e465c BaseTools: Only check for GCC prefixes when targeting
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-03 05:32:14 +00:00
Aaron Popandmergify[bot] 87e486f622 BaseTools: Enable 4k alignment for tool chains
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-02 19:56:18 +00:00
Doug Flickandmergify[bot] 233eddb8e3 BaseTools/Plugin: Add lcov error tolerance for vendored source trees
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-31 22:24:43 +00:00
Kun Qinandmergify[bot] ef23e3c9e7 BaseTools: Enable control flow guard for Windows builds
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-26 02:28:23 +00:00
Kun Qinandmergify[bot] 4e0376c48b BaseTools: Suppress C4028 warning to support older VS toolchain builds
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-26 02:28:23 +00:00
Kun Qinandmergify[bot] 8c298e1104 BaseTools: GenFfs/GenFv/GenSec: Fixing Warning 4319 from MSVC
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>
2026-03-13 19:14:49 +00:00
Mike Beatonandmergify[bot] 4057d2959c BaseTools/WindowsVsToolChain.py: Minor code style updates
Fixes: 0b867b65a2

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
2026-03-07 18:30:01 +00:00
Michael D Kinneyandmergify[bot] e22f4a61c9 BaseTools/Source/Python/Trim: Add -f/--source-code-format option
Add --source-code-format option that can be NASM or not
specified. This can be used for file format specific actions
when --source-code is used.

A NASM specific action is added to convert #line to %line to
preserve reference the originating NASM source file for source
level debug in NASM format.

Without this change, the source level debug of NASM files
loads the generated intermediate file in the build output
directory.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-03-06 19:47:31 +00:00
Sherry Fanandmergify[bot] 75cce8c66f BaseTools: fix mdlint issues
Fix markdownlint formatting issues in READMEs.

Signed-off-by: Sherry Fan <sherryfan@microsoft.com>
2026-03-04 22:02:33 +00:00