Scott, I agree that updating tools_def.txt for this use case is difficult, and I would not recommend that either.
There are other methods to customize compiler/linker. The compiler/link flags are built up from several sources. 1) tools_def.txt 2) build_rules.txt 3) [BuildOptions] section of a DSC file. 4) [BuildOptions] section of an INF file. For example, you can implement the same type of feature using a combination of the -D arguments to the build command and a [BuildOptions] section in a DSC file. DSC file ======== [BuildOptions] MSFT:*_*_*_CC_FLAGS = $(MSFT_EXTRA_CC_FLAGS) GCC:*_*_*_CC_FLAGS = $(GCC_EXTRA_CC_FLAGS) MSFT Build command example (disable all warnings) ======================================== build -a IA32 -t VS2013x86 -p OvmfPkg\OvmfPkgIa32.dsc -D MSFT_EXTRA_CC_FLAGS=/w MSFT Build command example (disable all warnings and disable optimizations) ======================================== build -a IA32 -t VS2013x86 -p OvmfPkg\OvmfPkgIa32.dsc -D MSFT_EXTRA_CC_FLAGS="/Od /w" GCC Build command example (msabi flag) ======================================== build -a IA32 -t VS2013x86 -p OvmfPkg\OvmfPkgIa32.dsc -D GCC_EXTRA_CC_FLAGS="-mabi=ms" Best regards, Mike -----Original Message----- From: Scott Duplichan [mailto:sc...@notabs.org] Sent: Wednesday, July 15, 2015 12:03 AM To: Kinney, Michael D; edk2-devel@lists.sourceforge.net Subject: RE: [edk2] [PATCH] BaseTools: Add mechanism to override or add CC_FLAGS Kinney, Michael D [mailto:michael.d.kin...@intel.com] wrote: ]Sent: Tuesday, July 14, 2015 06:29 PM ]To: Scott Duplichan; edk2-devel@lists.sourceforge.net; Kinney, Michael D ]Subject: RE: [edk2] [PATCH] BaseTools: Add mechanism to override or add CC_FLAGS ] ]Scott, ] ]We try to minimize the build dependencies on environment variables. There are several mechanisms already ]available to append CC_FLAGS. Can you please provide more details on why the environment variable based ]method is better than the existing methods? ] ]Thanks, ] ]Mike Hello Mike, First of all, this patch is not an essential, must-have. I just find it useful. For example, what if you want to test the code size reduction effect of gcc option -mabi=ms ? With this patch applied, a single command does it. Without the patch, you have to carefully edit the 7,000 line tools_def.txt file. For example, it might seem that adding -mabi=ms to GCC_ALL_CC_FLAGS would be proper. But looking more closely at that definition shows that it does not affect GCC44-GCC49. If there is a need to append a new flag to the existing flags, then several changes are needed. Once the changes are made, how can they be saved for future use? I suppose a patch file would work, but the patch might not work for some future EDK2 revision. The environment variable method of modifying build flags seems to be universal for gnu projects. It is not something I invented. Imagine trying to customize gcc build flags without using environment variables. I am surprised to hear objections to the use of environment variables. Here is why. I like to download a pristine source code project into its own directory. Customizations, experimental settings, and environment specific settings are kept somewhere else. That way, I can clean, update, or replace the project's source code independently of my customizations. Environment variables seem like a perfect way to implement this. An example is environment variable GCC49_X64_PREFIX. My build wrapper batch file sets this variable to match my machine. I can download a new EDK2 and build successfully without modifying anything. But what about the hard-coded paths for Microsoft tools? If my Microsoft tools are on a D drive, then what do I do? I suppose I could write some sed commands to modify tools_def every time I build. But that is a pain. Windows has no sed for one thing. With the environment variable setup of GCC44-49, I can build a new EDK2 download without modifying a single file. So how did I solve the Microsoft hard-coded path problem? I ended up retiring my old computer and building up a new one with a bigger C-drive hard disk. Thanks, Scott -----Original Message----- From: Scott Duplichan [mailto:sc...@notabs.org] Sent: Tuesday, July 14, 2015 9:47 AM To: edk2-devel@lists.sourceforge.net Subject: [edk2] [PATCH] BaseTools: Add mechanism to override or add CC_FLAGS BaseTools: Add mechanism to override or add CC_FLAGS If environment variable MSFT_EXTRA_CC_FLAGS exists, its contents are appended to the C compiler flags string for MSFT and INTEL tool chains. If environment variable GCC_EXTRA_CC_FLAGS exists, its contents are appended to the C compiler flags string for GCC and RVCT tool chains. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Scott Duplichan <sc...@notabs.org> --- This patch must be applied after the gcc49lto. Setting environment variable GCC_EXTRA_CC_FLAGS=-Wno-error overrides the gcc warnings as error option so that gcc lto builds can finish and generate a complete list of warnings. A similar option is added for Microsoft tool chains. Set environment variable MSFT_EXTRA_CC_FLAGS=/WX- to override warning as error for Microsoft tool chains. These settings are also useful for overnight batch building of many EDK2 projects. By overriding warning as error, the build will continue after a warning is encountered, allowing more files to be processed. BaseTools/Conf/build_rule.template | 4 ++-- BaseTools/Conf/tools_def.template | 30 ++++++++++++++++++------------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule.template index 86ea464..e9802ea 100644 --- a/BaseTools/Conf/build_rule.template +++ b/BaseTools/Conf/build_rule.template @@ -128,11 +128,11 @@ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj <Command.MSFT, Command.INTEL> - "$(CC)" /Fo${dst} $(CC_FLAGS) $(INC) ${src} + "$(CC)" /Fo${dst} $(CC_FLAGS) $(MSFT_EXTRA_CC_FLAGS) $(INC) ${src} <Command.GCC, Command.RVCT> # For RVCTCYGWIN CC_FLAGS must be first to work around pathing issues - "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src} + "$(CC)" $(CC_FLAGS) $(GCC_EXTRA_CC_FLAGS) -o ${dst} $(INC) ${src} <Command.ARMGCC, Command.ARMLINUXGCC, command.XCODE> "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src} diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template index 8d1b319..fa98b66 100644 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -4692,9 +4692,9 @@ RELEASE_GCC49_AARCH64_CC_FLAGS = DEF(GCC49_AARCH64_CC_FLAGS) -Wno-unused-but-s DEBUG_GCC49LTO_IA32_CC_FLAGS = DEF(GCC49LTO_IA32_BASE_CC_FLAGS) DEF(GCC49LTO_IA32_DEBUG_FLAGS) -c RELEASE_GCC49LTO_IA32_CC_FLAGS = DEF(GCC49LTO_IA32_BASE_CC_FLAGS) DEF(GCC49LTO_IA32_RELEASE_FLAGS) -c NOOPT_GCC49LTO_IA32_CC_FLAGS = DEF(GCC49LTO_IA32_BASE_CC_FLAGS) DEF(GCC49LTO_IA32_NOOPT_FLAGS) -c - DEBUG_GCC49LTO_IA32_DLINK_FLAGS = DEF(GCC49LTO_IA32_DLINK_FLAGS) DEF(GCC49LTO_IA32_BASE_CC_FLAGS) DEF(GCC49LTO_IA32_DEBUG_FLAGS) -RELEASE_GCC49LTO_IA32_DLINK_FLAGS = DEF(GCC49LTO_IA32_DLINK_FLAGS) DEF(GCC49LTO_IA32_BASE_CC_FLAGS) DEF(GCC49LTO_IA32_RELEASE_FLAGS) - NOOPT_GCC49LTO_IA32_DLINK_FLAGS = DEF(GCC49LTO_IA32_DLINK_FLAGS) DEF(GCC49LTO_IA32_BASE_CC_FLAGS) DEF(GCC49LTO_IA32_NOOPT_FLAGS) + DEBUG_GCC49LTO_IA32_DLINK_FLAGS = DEF(GCC49LTO_IA32_DLINK_FLAGS) DEF(GCC49LTO_IA32_BASE_CC_FLAGS) DEF(GCC49LTO_IA32_DEBUG_FLAGS) ENV(GCC_EXTRA_CC_FLAGS) +RELEASE_GCC49LTO_IA32_DLINK_FLAGS = DEF(GCC49LTO_IA32_DLINK_FLAGS) DEF(GCC49LTO_IA32_BASE_CC_FLAGS) DEF(GCC49LTO_IA32_RELEASE_FLAGS) ENV(GCC_EXTRA_CC_FLAGS) + NOOPT_GCC49LTO_IA32_DLINK_FLAGS = DEF(GCC49LTO_IA32_DLINK_FLAGS) DEF(GCC49LTO_IA32_BASE_CC_FLAGS) DEF(GCC49LTO_IA32_NOOPT_FLAGS) ENV(GCC_EXTRA_CC_FLAGS) *_GCC49LTO_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS) *_GCC49LTO_IA32_OBJCOPY_FLAGS = *_GCC49LTO_IA32_NASM_FLAGS = -f elf32 @@ -4720,9 +4720,9 @@ RELEASE_GCC49LTO_IA32_DLINK_FLAGS = DEF(GCC49LTO_IA32_DLINK_FLAGS) DEF(GCC49L DEBUG_GCC49LTO_X64_CC_FLAGS = DEF(GCC49LTO_X64_BASE_CC_FLAGS) DEF(GCC49LTO_X64_DEBUG_FLAGS) -c RELEASE_GCC49LTO_X64_CC_FLAGS = DEF(GCC49LTO_X64_BASE_CC_FLAGS) DEF(GCC49LTO_X64_RELEASE_FLAGS) -c NOOPT_GCC49LTO_X64_CC_FLAGS = DEF(GCC49LTO_X64_BASE_CC_FLAGS) DEF(GCC49LTO_X64_NOOPT_FLAGS) -c - DEBUG_GCC49LTO_X64_DLINK_FLAGS = DEF(GCC49LTO_X64_DLINK_FLAGS) DEF(GCC49LTO_X64_BASE_CC_FLAGS) DEF(GCC49LTO_X64_DEBUG_FLAGS) -RELEASE_GCC49LTO_X64_DLINK_FLAGS = DEF(GCC49LTO_X64_DLINK_FLAGS) DEF(GCC49LTO_X64_BASE_CC_FLAGS) DEF(GCC49LTO_X64_RELEASE_FLAGS) - NOOPT_GCC49LTO_X64_DLINK_FLAGS = DEF(GCC49LTO_X64_DLINK_FLAGS) DEF(GCC49LTO_X64_BASE_CC_FLAGS) DEF(GCC49LTO_X64_NOOPT_FLAGS) + DEBUG_GCC49LTO_X64_DLINK_FLAGS = DEF(GCC49LTO_X64_DLINK_FLAGS) DEF(GCC49LTO_X64_BASE_CC_FLAGS) DEF(GCC49LTO_X64_DEBUG_FLAGS) ENV(GCC_EXTRA_CC_FLAGS) +RELEASE_GCC49LTO_X64_DLINK_FLAGS = DEF(GCC49LTO_X64_DLINK_FLAGS) DEF(GCC49LTO_X64_BASE_CC_FLAGS) DEF(GCC49LTO_X64_RELEASE_FLAGS) ENV(GCC_EXTRA_CC_FLAGS) + NOOPT_GCC49LTO_X64_DLINK_FLAGS = DEF(GCC49LTO_X64_DLINK_FLAGS) DEF(GCC49LTO_X64_BASE_CC_FLAGS) DEF(GCC49LTO_X64_NOOPT_FLAGS) ENV(GCC_EXTRA_CC_FLAGS) *_GCC49LTO_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS) *_GCC49LTO_X64_OBJCOPY_FLAGS = *_GCC49LTO_X64_NASM_FLAGS = -f elf64 @@ -4756,9 +4756,9 @@ RELEASE_GCC49LTO_X64_DLINK_FLAGS = DEF(GCC49LTO_X64_DLINK_FLAGS) DEF(GCC49LT DEBUG_GCC49LTO_ARM_CC_FLAGS = DEF(GCC49LTO_ARM_BASE_CC_FLAGS) DEF(GCC49LTO_ARM_DEBUG_FLAGS) -c RELEASE_GCC49LTO_ARM_CC_FLAGS = DEF(GCC49LTO_ARM_BASE_CC_FLAGS) DEF(GCC49LTO_ARM_RELEASE_FLAGS) -c NOOPT_GCC49LTO_ARM_CC_FLAGS = DEF(GCC49LTO_ARM_BASE_CC_FLAGS) DEF(GCC49LTO_ARM_NOOPT_FLAGS) -c - DEBUG_GCC49LTO_ARM_DLINK_FLAGS = DEF(GCC49LTO_ARM_DLINK_FLAGS) DEF(GCC49LTO_ARM_BASE_CC_FLAGS) DEF(GCC49LTO_ARM_DEBUG_FLAGS) -RELEASE_GCC49LTO_ARM_DLINK_FLAGS = DEF(GCC49LTO_ARM_DLINK_FLAGS) DEF(GCC49LTO_ARM_BASE_CC_FLAGS) DEF(GCC49LTO_ARM_RELEASE_FLAGS) - NOOPT_GCC49LTO_ARM_DLINK_FLAGS = DEF(GCC49LTO_ARM_DLINK_FLAGS) DEF(GCC49LTO_ARM_BASE_CC_FLAGS) DEF(GCC49LTO_ARM_NOOPT_FLAGS) + DEBUG_GCC49LTO_ARM_DLINK_FLAGS = DEF(GCC49LTO_ARM_DLINK_FLAGS) DEF(GCC49LTO_ARM_BASE_CC_FLAGS) DEF(GCC49LTO_ARM_DEBUG_FLAGS) ENV(GCC_EXTRA_CC_FLAGS) +RELEASE_GCC49LTO_ARM_DLINK_FLAGS = DEF(GCC49LTO_ARM_DLINK_FLAGS) DEF(GCC49LTO_ARM_BASE_CC_FLAGS) DEF(GCC49LTO_ARM_RELEASE_FLAGS) ENV(GCC_EXTRA_CC_FLAGS) + NOOPT_GCC49LTO_ARM_DLINK_FLAGS = DEF(GCC49LTO_ARM_DLINK_FLAGS) DEF(GCC49LTO_ARM_BASE_CC_FLAGS) DEF(GCC49LTO_ARM_NOOPT_FLAGS) ENV(GCC_EXTRA_CC_FLAGS) ################## # GCC49LTO AARCH64 definitions @@ -4785,9 +4785,9 @@ RELEASE_GCC49LTO_ARM_DLINK_FLAGS = DEF(GCC49LTO_ARM_DLINK_FLAGS) DEF(GCC49LT DEBUG_GCC49LTO_AARCH64_CC_FLAGS = DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) DEF(GCC49LTO_AARCH64_DEBUG_FLAGS) -c RELEASE_GCC49LTO_AARCH64_CC_FLAGS = DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) DEF(GCC49LTO_AARCH64_RELEASE_FLAGS) -c NOOPT_GCC49LTO_AARCH64_CC_FLAGS = DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) DEF(GCC49LTO_AARCH64_NOOPT_FLAGS) -c - DEBUG_GCC49LTO_AARCH64_DLINK_FLAGS = DEF(GCC49LTO_AARCH64_DLINK_FLAGS) DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) DEF(GCC49LTO_AARCH64_DEBUG_FLAGS) -RELEASE_GCC49LTO_AARCH64_DLINK_FLAGS = DEF(GCC49LTO_AARCH64_DLINK_FLAGS) DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) DEF(GCC49LTO_AARCH64_RELEASE_FLAGS) - NOOPT_GCC49LTO_AARCH64_DLINK_FLAGS = DEF(GCC49LTO_AARCH64_DLINK_FLAGS) DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) DEF(GCC49LTO_AARCH64_NOOPT_FLAGS) + DEBUG_GCC49LTO_AARCH64_DLINK_FLAGS = DEF(GCC49LTO_AARCH64_DLINK_FLAGS) DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) DEF(GCC49LTO_AARCH64_DEBUG_FLAGS) ENV(GCC_EXTRA_CC_FLAGS) +RELEASE_GCC49LTO_AARCH64_DLINK_FLAGS = DEF(GCC49LTO_AARCH64_DLINK_FLAGS) DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) DEF(GCC49LTO_AARCH64_RELEASE_FLAGS) ENV(GCC_EXTRA_CC_FLAGS) + NOOPT_GCC49LTO_AARCH64_DLINK_FLAGS = DEF(GCC49LTO_AARCH64_DLINK_FLAGS) DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) DEF(GCC49LTO_AARCH64_NOOPT_FLAGS) ENV(GCC_EXTRA_CC_FLAGS) #################################################################################### # @@ -7129,3 +7129,9 @@ RELEASE_ARMLINUXGCC_AARCH64_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC # Build rule order ################# *_*_*_*_BUILDRULEORDER = nasm asm Asm ASM S s + +################# +# Extra C compiler flags +################# +*_*_*_*_MSFT_EXTRA_CC_FLAGS = ENV(MSFT_EXTRA_CC_FLAGS) +*_*_*_*_GCC_EXTRA_CC_FLAGS = ENV(GCC_EXTRA_CC_FLAGS) ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel