How to Compile EDKII Based BIOS Source using Clang (https://en.wikipedia.org/wiki/Clang)?
1. Files to be modified:
1.1. MSFT_DEF.txt = Microsoft Tool Chain Definition
--> This is main Tool Chain file
1.2. MSFT_DEF.txt, GCC_DEF.txt, ...
MYTOOLS_DEF.txt --->
!include MSFT_DEF.txt
*_MYTOOLS_*_*_FAMILY = MSFT
VS2015_DEF.txt --->
!include MSFT_DEF.txt
*_VS2015_*_*_FAMILY = MSFT
DEBUG_VS2015_IA32_CC_FLAGS = DEF(DEBUG_CC_FLAGS) DEF(COMMON_CC_FLAGS) /arch:IA32
RELEASE_VS2015_IA32_CC_FLAGS = DEF(COMMON_CC_FLAGS) /arch:IA32
Since MYTOOLS_DEF.txt and VS2015_DEF.txt are sharing the usage of MSFT_DEF.txt, we need to list the difference between them. (MyTools as Default)
1.3. The usage of MYTOOLS_DEF.txt is selected in target.txt
This file is generated in main.mak
target.txt --->
ACTIVE_PLATFORM = Build/Platform.dsc
TARGET = RELEASE
TOOL_CHAIN_CONF = AmiPkg/Configuration/MYTOOLS_DEF.txt
TOOL_CHAIN_TAG = MYTOOLS
MAX_CONCURRENT_THREAD_NUMBER = 8
BUILD_RULE_CONF = AmiPkg/Configuration/build_rule.txt
The make command in main.mak as follows:
# Create Conf/target.txt, based on SDL tokens
Conf/target.txt : $(TOKEN_MAK) $(MAIN_MAK) Conf
@$(ECHO) \
"ACTIVE_PLATFORM = $(subst \,/, $(ACTIVE_PLATFORM))\
$(EOL)\
$(EOL)TARGET = $(TARGET)\
$(EOL)\
$(EOL)TOOL_CHAIN_CONF = $(TOOL_DEFINITION_FILE)\
$(EOL)\
$(EOL)TOOL_CHAIN_TAG = $(TOOL_CHAIN_TAG)\
$(EOL)\
$(EOL)MAX_CONCURRENT_THREAD_NUMBER = $(NUMBER_OF_BUILD_PROCESS_THREADS)\
$(EOL)\
$(EOL)BUILD_RULE_CONF = $(BUILD_RULE_FILE)" > Conf/target.txt
-----------------------------------------------------------------
TOKEN
Name = "TOOL_DEFINITION_FILE"
Value = "$(CONFIGURATION_DIR)$(TOOL_CHAIN_TAG)_DEF.txt"
Help = "Name of the tool definition file.\This value goes to to auto-generated Conf/target.txt."
TokenType = Expression
TargetMAK = Yes
End
--------------------------------------------------------------
Conf/target.txt : $(TOKEN_MAK) $(MAIN_MAK) Conf
@$(ECHO) \
"ACTIVE_PLATFORM = $(subst \,/, $(ACTIVE_PLATFORM))\
$(EOL)\
$(EOL)TARGET = $(TARGET)\
$(EOL)\
$(EOL)TOOL_CHAIN_CONF = $(TOOL_DEFINITION_FILE)\
$(EOL)\
$(EOL)TOOL_CHAIN_TAG = $(TOOL_CHAIN_TAG)\
$(EOL)\
$(EOL)MAX_CONCURRENT_THREAD_NUMBER = $(NUMBER_OF_BUILD_PROCESS_THREADS)\
$(EOL)\
$(EOL)BUILD_RULE_CONF = $(BUILD_RULE_FILE)" > Conf/target.txt
---------------------------------------------------------------
1.4. Search "Clang Support" for building on Mac OS X (in EDK2_Build_Spec.pdf), where the full sample of Clang_DEF.txt
1.5. Complete Flow:
1.5.1. Veb Calls Tools (make.exe) -> makefile
1.5.2. makefile gives the control to main.mak
1.5.3. main.mak in charge of including all makefiles came from module.mak
1.5.4. Based on definition of toolchain, main.mak will generate target.txt
1.5.5. main.mak calls EDK2 build.exe
1.5.6. Compile Example of a EDKII "Driver"
Control Tool: C:\WinDDK\7600.16385.1\bin\x86\amd64\cl.exe
Generated File: v3_lib.obj
Source File: v3_lib.c
---------------------------------------------------------------
2. target.txt
# Platform.dsc:
ACTIVE_PLATFORM = Build/Platform.dsc
TARGET = RELEASE
TOOL_CHAIN_CONF = AmiPkg/Configuration/MYTOOLS_DEF.txt
TOOL_CHAIN_TAG = MYTOOLS
MAX_CONCURRENT_THREAD_NUMBER = 8
BUILD_RULE_CONF = AmiPkg/Configuration/build_rule.txt
No comments:
Post a Comment