Branch: refs/heads/master
  Home:   https://github.com/tianocore/edk2
  Commit: 18fdec11b1ab6475d1c3f328953f225547983dd5
      
https://github.com/tianocore/edk2/commit/18fdec11b1ab6475d1c3f328953f225547983dd5
  Author: Nate DeSimone <nathaniel.l.desim...@intel.com>
  Date:   2025-06-07 (Sat, 07 Jun 2025)

  Changed paths:
    M BaseTools/Tests/TestTools.py

  Log Message:
  -----------
  BaseTools: Add Unit Test Support for X64 BaseTools on Windows

Fixes a BaseTools Bin directory path detection bug in the the BaseTools
Unit Tests. The script incorrectly assumes that sys.platform
will be win64 on a 64-bit Python interperter.
The "win64" platform string has not been used for 64-bit Python
interperters since May 10, 2000:

https://github.com/python/cpython/commit/da5cc82d

Moreover, this patch was merged before the Python 2.0 release, so there
never has been a released Python interperter that used the "win64"
string.

Signed-off-by: Nate DeSimone <nathaniel.l.desim...@intel.com>


  Commit: c0ef2b017855177903d87937ac4cdaec5c7851db
      
https://github.com/tianocore/edk2/commit/c0ef2b017855177903d87937ac4cdaec5c7851db
  Author: Nate DeSimone <nathaniel.l.desim...@intel.com>
  Date:   2025-06-07 (Sat, 07 Jun 2025)

  Changed paths:
    M BaseTools/Makefile
    M BaseTools/Source/C/BrotliCompress/BrotliCompress.c
    M BaseTools/Source/C/Common/CommonLib.c
    M BaseTools/Source/C/Common/CommonLib.h
    M BaseTools/Source/C/DevicePath/GNUmakefile
    M BaseTools/Source/C/GNUmakefile
    M BaseTools/Source/C/GenFv/GenFvInternalLib.c
    A BaseTools/Source/C/Makefiles/GnuMakeUtils.py
    M BaseTools/Source/C/Makefiles/app.makefile
    M BaseTools/Source/C/Makefiles/footer.makefile
    M BaseTools/Source/C/Makefiles/header.makefile
    M BaseTools/Source/C/VfrCompile/GNUmakefile
    M BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile
    M BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile
    M BaseTools/Source/Python/Workspace/DscBuildData.py
    M BaseTools/Tests/GNUmakefile
    M BaseTools/toolsetup.bat
    M edksetup.bat

  Log Message:
  -----------
  BaseTools: Add support for mingw-w64

Adds support for building the C language BaseTools for Windows using
toolchains based on mingw-w64.

Mingw-w64 is a collection of header files, libraries, and tools that
when combined with a compiler enable development of Windows software.
Mingw-w64 is a fork of the original MinGW (Minimalist GNU for Windows).
Most active development on MinGW has ceased and mingw-w64 is now the
actively maintained successor.  Mingw-w64 provides a libc implementation
built on top of Microsoft's UCRT (Universal C Runtime) with all
nessesary compiler bindings needed to support the C++11 feature set.

Modern mingw-w64 development appears to have coalesced around MSYS2,
which produces a distributions of both GCC and LLVM/Clang that use
mingw-w64 to target the Windows OS. This MSYS2 Clang distribution has a
UNIX-like directory layout and includes Windows binaries of GNU Make.
Combined with the open source licensing, MSYS2's Clang distribution is a
highly attractive choice as an alternative Windows SDK for open source
projects such as TianoCore.

If one wishes to use EDK II to build UEFI firmware on the Windows
platform, then the C BaseTools need to be compiled as Windows
applications. This includes the PcdValueInit.exe program, which needs
to be recompiled every time a firmware build is run in order to
regenerate the initial values for structured PCDs. Currently, BaseTools
only supports the Visual C++ toolchain on the Windows platform. The
following new features have been added to enable usage of the toolchains
derived from mingw-w64:

 - Fixes to the BaseTools C source code to support the use of a
   GCC-style compiler on the Windows OS.
 - The GNU Make-style Makefiles for the C BaseTools have been modified
   to support Windows. Both GCC + mingw-w64 and Clang + mingw-w64 have
   been tested and confirmed to build a working BaseTools.
 - BaseTools now supports generating GNU Make-style Makefiles on the
   Windows platform for the purpose of building firmware.
 - edksetup.bat has been modified to optionally build BaseTools via
   mingw-w64. There is no impact to the existing support for Visual C++
   and Visual C++ remains the default toolchain.

Usage Instructions:

For the vast majority of users, the only system setup change nessesary
to use a mingw-w64 toolchain is to set the BASETOOLS_MINGW_PATH to the
directory containing the desired mingw-w64 based toolchain.

A new command line argument has been added to edksetup.bat: Mingw-w64
If this command line argument is set, then the script will set the
BASETOOLS_MINGW_BUILD environment variable. The user can also opt to set
this environment variable manually before running edksetup.bat

If BASETOOLS_MINGW_BUILD is defined, then the BASETOOLS_MINGW_PATH
environment variable must point to the directory containing the
mingw-w64 toolchain.

If CLANG_BIN is not defined and %BASETOOLS_MINGW_PATH%\bin\clang.exe
exists, then edksetup.bat will set CLANG_BIN=%BASETOOLS_MINGW_PATH%\bin\
This removes the requirement to configure the CLANG_BIN environment
variable manually in order to run a CLANGPDB or CLANGDWARF build if one
has the MSYS2 Clang distribution installed. If one wishes to use a
different copy of Clang (for example official LLVM binaries) to build
firmware and only use the MSYS2 Clang to build BaseTools, then one can
continue to set the CLANG_BIN environment variable, same as before. I
have tested the MSYS2 Clang distribution against the official LLVM
distribution and can confirm that if the compiler version is the same
the emitted machine code is identical between the two. Interestingly,
the MSYS2 Clang distribution emits the path to the PDB file using "/" as
the path seperator instead of "\". That appears to be the only
difference in output. Therefore, using the MSYS2 Clang distribution to
compile firmware seems a reasonable choice.

If CLANG_HOST_BIN is not defined and BASETOOLS_MINGW_BUILD is defined
and %BASETOOLS_MINGW_PATH%\bin\mingw32-make.exe exists, then
edksetup.bat will add %BASETOOLS_MINGW_PATH%\bin\ to the PATH and set
CLANG_HOST_BIN=mingw32-
This enable usage of the GNU Make included in the mingw-w64 toolchain
to build firmware in addition to BaseTools. if BASETOOLS_MINGW_BUILD is
not defined, edksetup.bat will continue to set CLANG_HOST_BIN=n, which
uses nmake to build firmware. This behavior can be overridden by
manually setting the value of CLANG_HOST_BIN before executing
edksetup.bat if one wishes to use a specific Make utility for the
CLANGPDB/CLANGDWARF toolchains.

References:
 - https://www.mingw-w64.org/
 - https://www.msys2.org/

Co-authored-by: Sandesh Jain <sandesh.j...@intel.com>
Signed-off-by: Nate DeSimone <nathaniel.l.desim...@intel.com>


Compare: https://github.com/tianocore/edk2/compare/a55d933064f7...c0ef2b017855

To unsubscribe from these emails, change your notification settings at 
https://github.com/tianocore/edk2/settings/notifications


_______________________________________________
edk2-commits mailing list
edk2-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to