Skip to content

Commit

Permalink
Adding base tool build for Linux ARM (microsoft#362)
Browse files Browse the repository at this point in the history
Please ensure you have read the [contribution
docs](https://github.com/microsoft/mu/blob/master/CONTRIBUTING.md) prior
to submitting the pull request. In particular,
[pull request
guidelines](https://github.com/microsoft/mu/blob/master/CONTRIBUTING.md#pull-request-best-practices).

This change added the build script to cross compile the base tool
binaries for Linux ARM system.

The needed libuuid system library is pulled from source file and rebuilt
to support the corresponding library dependencies. Individual tools'
makefiles are also updated to link the cross compiled library as well.

This is the first step of
microsoft#369.

For each item, place an "x" in between `[` and `]` if true. Example:
`[x]`.
_(you can also check items in the GitHub UI)_

- [x] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [ ] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [ ] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

This was tested functional on Linux ARM host system building QEMU
virtual platforms (Q35 and SBSA).

Update the basetool nuget version, once it is published.
  • Loading branch information
kuqin12 authored and os-d committed Jun 19, 2024
1 parent e3cbaa1 commit 2f06628
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 7 deletions.
6 changes: 6 additions & 0 deletions BaseTools/Source/C/DevicePath/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ ifeq ($(CYGWIN), CYGWIN)
endif

ifeq ($(LINUX), Linux)
# MU_CHANGE STARTs: Support cross compiling
ifndef CROSS_LIB_UUID
LIBS += -luuid
else
LIBS += -L$(CROSS_LIB_UUID)
endif
# MU_CHANGE ENDs
endif

13 changes: 12 additions & 1 deletion BaseTools/Source/C/GenFv/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ include $(MAKEROOT)/Makefiles/app.makefile

LIBS = -lCommon
ifeq ($(CYGWIN), CYGWIN)
LIBS += -L/lib/e2fsprogs
LIBS += -L/lib/e2fsprogs -luuid
endif

ifeq ($(LINUX), Linux)
# MU_CHANGE STARTs: Support cross compiling
ifndef CROSS_LIB_UUID
LIBS += -luuid
else
LIBS += -L$(CROSS_LIB_UUID)
BUILD_CFLAGS += -D__CROSS_LIB_UUID__ -I $(CROSS_LIB_UUID_INC)
endif
# MU_CHANGE ENDs
endif

12 changes: 11 additions & 1 deletion BaseTools/Source/C/GenFv/GenFvInternalLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Include files
//

#if defined(__FreeBSD__)
#include <uuid.h>
#elif defined(__GNUC__)
// MU_CHANGE STARTs: Support cross compiling
#if !defined(__CROSS_LIB_UUID__)
#include <uuid/uuid.h>
#else
#include <uuid.h>
#endif
// MU_CHANGE ENDs
#endif
#ifdef __GNUC__
#include <sys/stat.h>
#endif
Expand Down Expand Up @@ -2286,7 +2297,6 @@ Routine Description:
bSecCore |= 0x6F; //JAL opcode

memcpy(FvImage->FileImage, &bSecCore, sizeof(bSecCore));

return EFI_SUCCESS;
}

Expand Down
6 changes: 6 additions & 0 deletions BaseTools/Source/C/GenFw/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ ifeq ($(CYGWIN), CYGWIN)
endif

ifeq ($(LINUX), Linux)
# MU_CHANGE STARTs: Support cross compiling
ifndef CROSS_LIB_UUID
LIBS += -luuid
else
LIBS += -L$(CROSS_LIB_UUID)
endif
# MU_CHANGE ENDs
endif

6 changes: 6 additions & 0 deletions BaseTools/Source/C/GenSec/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ ifeq ($(CYGWIN), CYGWIN)
endif

ifeq ($(LINUX), Linux)
# MU_CHANGE STARTs: Support cross compiling
ifndef CROSS_LIB_UUID
LIBS += -luuid
else
LIBS += -L$(CROSS_LIB_UUID)
endif
# MU_CHANGE ENDs
endif

12 changes: 7 additions & 5 deletions BaseTools/Source/C/Makefiles/header.makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ AS ?= $(CLANG_BIN)clang
AR ?= $(CLANG_BIN)llvm-ar
LD ?= $(CLANG_BIN)llvm-ld
else ifeq ($(origin CC),default)
CC = gcc
CXX = g++
AS = gcc
AR = ar
LD = ld
# MU_CHANGE STARTs: Support GCC prefix
CC ?= $(GCC_PREFIX)gcc
CXX ?= $(GCC_PREFIX)g++
AS ?= $(GCC_PREFIX)gcc
AR ?= $(GCC_PREFIX)ar
LD ?= $(GCC_PREFIX)ld
# MU_CHANGE ENDs
endif
LINKER ?= $(CC)
ifeq ($(HOST_ARCH), IA32)
Expand Down

0 comments on commit 2f06628

Please sign in to comment.