VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/Config.kmk@ 108791

Last change on this file since 108791 was 108719, checked in by vboxsync, 7 weeks ago

tools,Devices/EFI/Firmware: Switch to a clang based cross compile toolchain for arm32 and arm64 UEFI images like we have on Windows, bugref:10874 bugref:4643

Using clang has several advantages:

  • It is far easier to build so updating the toolchain should be much simpler
  • A single toolchain can support multiple targets, no need to have two different toolchains for arm32 and arm64
  • The toolchain can be used for cross compilation (the current toolchain supports x86,amd64,arm32,arm64 and riscv...)
  • As clang is already used for the firmware images shipped in a release the resulting images compiled locally are much more close to what is built on the buildbox

The only downside is that the clang toolchain is a bit on the heavy side, even if stripped down. OTOH we only need a single toolchain opossed
to the two we had before.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.0 KB
Line 
1# $Id: Config.kmk 108719 2025-03-24 15:26:59Z vboxsync $
2## @file
3# kBuild configuration for the VBox EFI firmware.
4#
5# Note! kBuild is only used for the build tools, the rest is handled by the
6# very custom EFI build system.
7#
8
9#
10# Copyright (C) 2013-2024 Oracle and/or its affiliates.
11#
12# This file is part of VirtualBox base platform packages, as
13# available from https://www.215389.xyz.
14#
15# This program is free software; you can redistribute it and/or
16# modify it under the terms of the GNU General Public License
17# as published by the Free Software Foundation, in version 3 of the
18# License.
19#
20# This program is distributed in the hope that it will be useful, but
21# WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23# General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with this program; if not, see <https://www.gnu.org/licenses>.
27#
28# The contents of this file may alternatively be used under the terms
29# of the Common Development and Distribution License Version 1.0
30# (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
31# in the VirtualBox distribution, in which case the provisions of the
32# CDDL are applicable instead of those of the GPL.
33#
34# You may elect to license modified versions of this file under the
35# terms and conditions of either the GPL or the CDDL or both.
36#
37# SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
38#
39
40VBOX_EFI_FIRMWARE_CONFIG_KMK_INCLUDED = 1
41
42# Include the next configure file above us.
43ifndef VBOX_DEVICES_CONFIG_KMK_INCLUDED
44 include $(PATH_ROOT)/src/VBox/Devices/Config.kmk
45endif
46
47#
48# Globals.
49#
50VBOX_PATH_EFI_FIRMWARE = $(PATH_ROOT)/src/VBox/Devices/EFI/Firmware
51VBOX_PATH_STAGE_EFI_BLDPROGS = $(PATH_STAGE)/EfiBldProgs
52VBOX_EFI_BUILD_TARGET = $(if-expr $(intersects release profile, $(KBUILD_TYPE)),RELEASE,DEBUG)
53VBOX_EFI_OUTPUT_SUBDIR = $(VBOX_EFI_BUILD_TARGET)_$(VBOX_EFI_TOOL_CHAIN.$1)
54
55# VBox Yasm command
56## @todo r=andy Is this still needed? Or can we just use TOOL_YASM_AS?
57VBOX_YASMCMD ?= $(firstword $(wildcard $(KBUILD_DEVTOOLS_HST)/bin/yasm$(HOSTSUFF_EXE)) yasm$(HOSTSUFF_EXE))
58
59# VBox nasm command (we share this with ValKit/bootsector/Config.kmk, thus the TOOL-style variable name).
60include $(KBUILD_PATH)/tools/NASM.kmk
61ifndef TOOL_VBoxNasm_PATH
62 TOOL_VBoxNasm_PATH := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST)/nasm/v*.*)))
63 if "$(TOOL_VBoxNasm_PATH)" == "" && "$(KBUILD_DEVTOOLS_HST_ALT)" != ""
64 TOOL_VBoxNasm_PATH := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS_HST_ALT)/nasm/v*.*)))
65 endif
66endif
67ifneq ($(TOOL_VBoxNasm_PATH),)
68 VBOX_NASMCMD ?= $(TOOL_VBoxNasm_PATH)/nasm$(HOSTSUFF_EXE)
69else
70 VBOX_NASMCMD ?= nasm$(HOSTSUFF_EXE)
71endif
72
73
74#
75# Decide which tool chain to use for the EFI binaries.
76# Note! We're using our own stripped down tools_def.txt: vbox-tools_def.txt.
77#
78ifeq ($(KBUILD_HOST),win)
79 # The VS2019 template is the same as the VS2022 in upstream, so we stick with this till we upgrade.
80 VBOX_EFI_TOOL_CHAIN.x86 := VS2019
81 VBOX_EFI_TOOL_CHAIN.amd64 := VS2019
82else
83 VBOX_EFI_TOOL_CHAIN.x86 := GCC48
84 VBOX_EFI_TOOL_CHAIN.amd64 := GCC48
85endif
86
87VBOX_EFI_TOOL_CHAIN.arm32 := CLANGDWARF
88VBOX_EFI_TOOL_CHAIN.arm64 := CLANGDWARF
89
90
91#
92# Make a build program template of our own.
93#
94TEMPLATE_VBoxEfiBldProg = EFI build program.
95TEMPLATE_VBoxEfiBldProg_EXTENDS = VBoxBldProg
96TEMPLATE_VBoxEfiBldProg_INST = EfiBldProgs/
97TEMPLATE_VBoxEfiBldProg_INSTTYPE = stage
98TEMPLATE_VBoxEfiBldProg_DEFS.win = $(TEMPLATE_VBoxBldProg_DEFS.win) \
99 __STDC_VERSION__=199409L
100TEMPLATE_VBoxEfiBldProg_CFLAGS.win = $(TEMPLATE_VBoxBldProg_CFLAGS.win)
101TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4100 # warning C4100: '_text' : unreferenced formal parameter
102TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4189 # warning C4189: 'zzpf' : local variable is initialized but not referenced
103TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4255 # warning C4255: 'AllocateMemory' : no function prototype given: converting '()' to '(void)'
104TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4267 # warning C4267: '=' : conversion from 'size_t' to 'UINT32', possible loss of data
105TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4287 # warning C4287: '>' : unsigned/negative constant mismatch
106TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4334 # warning C4334: '<<' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
107TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4555 # warning C4555: expression has no effect; expected expression with side-effect
108TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4701 # warning C4701: potentially uninitialized local variable 'save_line' used
109TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4702 # warning C4702: unreachable code
110if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
111 TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4456 # antlr\gen.c(3000): warning C4456: declaration of 'f' hides previous local declaration
112 TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4774 # antlr\main.c(1244): warning C4774: 'sprintf' : format string expected in argument 2 is not a string literal
113 TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4703 # antlr\antlr.c(1403) : warning C4703: potentially uninitialized local pointer variable 'p' used
114 TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4477 # dlg\dlg_p.c(874): warning C4477: 'fprintf' : format string '%x' requires an argument of type 'unsigned int', but variadic argument 1 has type '_nfa_node *'
115 TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4313 # dlg\dlg_p.c(874): warning C4313: 'fprintf': '%x' in format string conflicts with argument 1 of type '_nfa_node *'
116 TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4459 # antlr\gen.c(756): warning C4459: declaration of 'output' hides global declaration
117 TEMPLATE_VBoxEfiBldProg_CFLAGS.win += -wd4668 # winioctl.h(10983): warning C4668: '_WIN32_WINNT_WIN10_TH2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
118endif
119TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win = $(TEMPLATE_VBoxBldProg_CXXFLAGS.win)
120TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd4018 # warning C4018: '>' : signed/unsigned mismatch
121TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd4101 # warning C4101: 'LineBuf' : unreferenced local variable
122TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd4102 # warning C4102: 'fail' : unreferenced label
123TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd4189 # warning C4189: 'zzpf' : local variable is initialized but not referenced
124TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd4267 # warning C4267: '=' : conversion from 'size_t' to 'UINT32', possible loss of data
125TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd4370 # warning C4370: 'ANTLRParser' : layout of class has changed from a previous version of the compiler due to better packing
126TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd4555 # warning C4555: expression has no effect; expected expression with side-effect
127TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd4625 # warning C4625: 'EfiVfrParser' : copy constructor could not be generated because a base class copy constructor is inaccessible
128TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd4626 # warning C4626: 'EfiVfrParser' : assignment operator could not be generated because a base class assignment operator is inaccessible
129TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd4701 # warning C4701: potentially uninitialized local variable 'save_line' used
130TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd4702 # warning C4702: unreachable code
131if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
132 TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd5204 # Pccts\h\ATokenStream.h(49): warning C5204: 'ANTLRTokenStream': class has virtual functions, but its trivial destructor is not virtual; instances of objects derived from this class may not be destructed correctly
133 TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd4774 # Pccts\h\AParser.cpp(653): warning C4774: 'sprintf' : format string expected in argument 2 is not a string literal
134 TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd4703 # VfrCompile\VfrFormPkg.cpp(1344) : warning C4703: potentially uninitialized local pointer variable 'pNodeBeforeAdjust' used
135 TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd5033 # DLexer.h(68): warning C5033: 'register' is no longer a supported storage class (in c++17 or later mode)
136endif
137if "$(VBOX_VCC_TOOL_STEM)" >= "VCC143"
138 TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd5264 # AParser.cpp(57): warning C5264: 'zzINF_DEF_TOKEN_BUFFER_SIZE': 'const' variable is not used
139 TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd5262 # VfrUtilityLib.cpp(687): warning C5262: implicit fall-through occurs here; are you missing a break statement? Use [[fallthrough]] when a break statement is intentionally omitted between cases
140 TEMPLATE_VBoxEfiBldProg_CXXFLAGS.win += -wd5267 # AToken.h(60): warning C5267: definition of implicit copy constructor for 'ANTLRAbstractToken' is deprecated because it has a user-provided destructor
141endif
142
143TEMPLATE_VBoxEfiBldProg_CFLAGS.linux = $(TEMPLATE_VBoxBldProg_CFLAGS.linux)
144TEMPLATE_VBoxEfiBldProg_CFLAGS.linux += -Wno-misleading-indentation
145TEMPLATE_VBoxEfiBldProg_CFLAGS.linux += -Wno-error=stringop-truncation # VfrCompile/Pccts/antlr/mrhoist.c:2216:5: error: 'strncpy' specified bound 50 equals destination size
146
147TEMPLATE_VBoxEfiBldProg_CXXFLAGS.darwin.arm64 = $(TEMPLATE_VBoxBldProg_CXXFLAGS.darwin.arm64)
148TEMPLATE_VBoxEfiBldProg_CXXFLAGS.darwin.arm64 += -Wno-register # BaseTools/Source/C/VfrCompile/Pccts/h/AParser.cpp:475:2: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
149TEMPLATE_VBoxEfiBldProg_CXXFLAGS.darwin.arm64 += -Wno-deprecated-declarations # out/darwin.arm64/debug/obj/VfrCompile/VfrSyntax.cpp:11241:3: error: 'sprintf' is deprecated: This function is provided for compatibility reasons only
150
151TEMPLATE_VBoxEfiBldProg_INCS = $(TEMPLATE_VBoxBldProg_INCS) \
152 $(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/C/Common \
153 $(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/C/Include \
154 $(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/C \
155 $(VBOX_PATH_EFI_FIRMWARE)/MdePkg/Include
156
157TEMPLATE_VBoxEfiBldProg_INCS.x86 = $(TEMPLATE_VBoxBldProg_INCS.x86) \
158 $(VBOX_PATH_EFI_FIRMWARE)/MdePkg/Include/Ia32
159
160TEMPLATE_VBoxEfiBldProg_INCS.amd64 = $(TEMPLATE_VBoxBldProg_INCS.amd64) \
161 $(VBOX_PATH_EFI_FIRMWARE)/MdePkg/Include/X64
162
163TEMPLATE_VBoxEfiBldProg_INCS.arm = $(TEMPLATE_VBoxBldProg_INCS.arm) \
164 $(VBOX_PATH_EFI_FIRMWARE)/MdePkg/Include/Arm
165
166TEMPLATE_VBoxEfiBldProg_INCS.arm64 = $(TEMPLATE_VBoxBldProg_INCS.arm64) \
167 $(VBOX_PATH_EFI_FIRMWARE)/MdePkg/Include/AArch64
168
169TEMPLATE_VBoxEfiBldProg_LATE_LIBS = \
170 $(VBOX_PATH_STAGE_EFI_BLDPROGS)/EfiBldCommonLib$(VBOX_SUFF_LIB) \
171 $(TEMPLATE_VBoxBldProg_LATE_LIBS)
172ifn1of ($(KBUILD_HOST), win) # This stuff isn't up to our standard at all! :/
173 TEMPLATE_VBoxEfiBldProg_CFLAGS = $(filter-out -pedantic,$(TEMPLATE_VBoxBldProg_CFLAGS)) \
174 -Wno-sign-compare -Wno-missing-prototypes -Wno-strict-prototypes \
175 -Wno-implicit-function-declaration -Wno-missing-declarations -Wno-shadow -Wno-format \
176 -Wno-empty-body -Wno-unused-parameter -Wno-unused-variable -Wno-unused-label
177 TEMPLATE_VBoxEfiBldProg_CXXFLAGS = $(filter-out -pedantic,$(TEMPLATE_VBoxBldProg_CXXFLAGS)) \
178 -Wno-all -Wno-shadow -Wno-empty-body -Wno-unused-parameter -Wno-unused-variable \
179 -Wno-unused-label
180endif
181
182
183# There isn't a BLDLIBRARIES target group, so we have to override the build
184# target for libraries used by build programs and keep them in LIBRARIES.
185TEMPLATE_VBoxEfiBldLib = Library for an EFI build program.
186TEMPLATE_VBoxEfiBldLib_EXTENDS = VBoxEfiBldProg
187TEMPLATE_VBoxEfiBldLib_BLD_TRG := $(KBUILD_HOST)
188TEMPLATE_VBoxEfiBldLib_BLD_TRG_ARCH := $(KBUILD_HOST_ARCH)
189TEMPLATE_VBoxEfiBldLib_BLD_TRG_CPU := $(KBUILD_HOST_CPU)
190
191
192#
193# The debug info suffix.
194#
195if1of ($(VBOX_EFI_TOOL_CHAIN.x86), VS2017 VS2019 VS2022 CLANGPDB)
196 VBOX_EFI_DBG_SUFF.x86 := .pdb
197else
198 VBOX_EFI_DBG_SUFF.x86 := .debug
199endif
200if1of ($(VBOX_EFI_TOOL_CHAIN.amd64), VS2017 VS2019 VS2022 CLANGPDB)
201 VBOX_EFI_DBG_SUFF.amd64 := .pdb
202else
203 VBOX_EFI_DBG_SUFF.amd64 := .debug
204endif
205if1of ($(VBOX_EFI_TOOL_CHAIN.arm32), VS2017 VS2019 VS2022 CLANGPDB)
206 VBOX_EFI_DBG_SUFF.arm32 := .pdb
207else
208 VBOX_EFI_DBG_SUFF.arm32 := .debug
209endif
210if1of ($(VBOX_EFI_TOOL_CHAIN.arm64), VS2017 VS2019 VS2022 CLANGPDB)
211 VBOX_EFI_DBG_SUFF.arm64 := .pdb
212else
213 VBOX_EFI_DBG_SUFF.arm64 := .debug
214endif
215
216include $(VBOX_PATH_EFI_FIRMWARE)/EfiModules.kmk
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette