Re: [edk2] How to pass flags/arguments to the compiler?

Subject: Re: [edk2] How to pass flags/arguments to the compiler?

From: Don Hiatt <donhiatt@gmail.com>

To: edk2-devel@lists.sourceforge.net

Date: 2010-09-10 00:20:47

Thanks! This is what I had in mind. However, I'll look at your PCD
suggestion too. I'm very new to the EDK and really appreciate everyone's
help. 

Cheers!

don

On Thu, 2010-09-09 at 16:08 -0700, Andrew Fish wrote:
> In the edk2 you can use  [BuildOptions] 
> 
> So for example here are the build options for the BeagleBoard build. The tool prefix lets you specify which compiler you are using to make sure the flags match your compiler. This does the entire platform build. 
> 
> 
> [BuildOptions]
>   XCODE:*_*_ARM_ARCHCC_FLAGS     == -arch armv7 -march=armv7
>   XCODE:*_*_ARM_ARCHASM_FLAGS    == -arch armv7
>   XCODE:*_*_ARM_ARCHDLINK_FLAGS  == -arch armv7
>   XCODE:RELEASE_*_*_CC_FLAGS     = -DMDEPKG_NDEBUG 
> 
>   GCC:*_*_ARM_ARCHCC_FLAGS     == -march=armv7-a -mthumb
>   GCC:*_*_ARM_ARCHASM_FLAGS    == -march=armv7-a
>   GCC:RELEASE_*_*_CC_FLAGS     = -DMDEPKG_NDEBUG 
> 
>   RVCT:*_*_ARM_ARCHCC_FLAGS  == --cpu Cortex-A8 --thumb
>   RVCT:*_*_ARM_ARCHASM_FLAGS == --cpu Cortex-A8 
>   RVCT:RELEASE_*_*_CC_FLAGS  = -DMDEPKG_NDEBUG 
> 
> You can also do a per module basis in the .DSC file 
> 
> Here is an example from the GccShell https://gcc-shell.svn.sourceforge.net/svnroot/gcc-shell/trunk/GccShellPkg/GccShellPkg.dsc
> 
> [Components]
>   $(EDK_SHELL_DIR)/Shell.inf {
>     
>       #
>       # Can not do this in nmake section of edk INF
>       #
>       GCC:*_*_*_CC_FLAGS     = -DEFI_MONOSHELL 
>       GCC:*_*_*_VFRPP_FLAGS  = -DEFI_MONOSHELL 
>       GCC:*_*_*_APP_FLAGS    = -DEFI_MONOSHELL 
>       GCC:*_*_*_PP_FLAGS     = -DEFI_MONOSHELL 
> 
>       RVCT:*_*_ARM_CC_FLAGS     = -DEFI_MONOSHELL 
>       RVCT:*_*_ARM_VFRPP_FLAGS  = -DEFI_MONOSHELL
>       RVCT:*_*_ARM_APP_FLAGS    = -DEFI_MONOSHELL 
>       RVCT:*_*_ARM_PP_FLAGS     = -DEFI_MONOSHELL 
>   }
> 
> In general we like to use PCD FeatureFlags for this kind of thing and not #ifdefs. So the edk2 code does not have #ifdef for features, other than DEPKG_NDEBUG. The nice thing about a PCD FeatureFlag is that both sides of the code compile every time. It does depend on a good optimizing compiler to remove the dead code. 
> 
> On the PCD front it is important to remember:
> .DEC file defines the existence and default value for a PCD setting like a feature flag. A PCD must exist to use it.
> .INF file defines that you driver/application is using the PCD feature flag.
> .DSC file sets the value of the PCD feature flag for your given platform. 
> 
> Andrew Fish
> 
> 
> 
> 
> 
> On Sep 9, 2010, at 3:56 PM, Don Hiatt wrote:
> 
> > Thanks! I'll have a look. The only thing, these names seem to imply they
> > would be applied build-wide (e.g. all modules would get them). Isn't
> > there a way to set the values on a per module basis? Basically, I have a
> > bunch of code that has:
> > 	 #if defined(foo)
> >           ...
> >         #else
> > 	   ...
> > 	 #endif
> > 
> > and I'd like to pass gcc '-Dfoo' when building my module but not affect
> > everything else.
> > 
> > I found those .env files in 'EdkCompatibilityPkg/Sample/' and will have
> > a look. Thanks again!!
> > 
> > don
> > 
> > 
> > On Thu, 2010-09-09 at 15:48 -0700, rangasai C wrote:
> >> Depending on whether your flags/arguments are platform specific or
> >> chipset specific or applicable to all, you should use it one of
> >> the .env files. I recall for EDK, it used to be PlatformTools.env
> >> ( for platform specific flags)
> >> LocalTools.env
> >> CommonTools.env. 
> >> 
> >> 
> >> You might also want to make sure your C compilers are pointing to the
> >> right path.
> >> 
> >> 
> >> Hope this helps !
> >> 
> >> 
> >> Sai
> >> 
> >> On Thu, Sep 9, 2010 at 3:32 PM, Don Hiatt  wrote:
> >>        Hello,
> >> 
> >>         I'm trying to understand the build process and I'm wondering
> >>        how you
> >>        go about passing flags/arguments to the compiler. For example,
> >>        in
> >>        HelloWorld, if I wanted gcc to get a '-Dfoo=bar' just where
> >>        would I add
> >>        the flag such that the build script picks it up?
> >> 
> >>        Thanks!
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >>        ------------------------------------------------------------------------------
> >>        Automate Storage Tiering Simply
> >>        Optimize IT performance and efficiency through flexible,
> >>        powerful,
> >>        automated storage tiering capabilities. View this brief to
> >>        learn how
> >>        you can reduce costs and improve performance.
> >>        http://p.sf.net/sfu/dell-sfdev2dev
> >>        _______________________________________________
> >>        edk2-devel mailing list
> >>        edk2-devel@lists.sourceforge.net
> >>        https://lists.sourceforge.net/lists/listinfo/edk2-devel
> >> 
> >> 
> >> ------------------------------------------------------------------------------
> >> Automate Storage Tiering Simply
> >> Optimize IT performance and efficiency through flexible, powerful, 
> >> automated storage tiering capabilities. View this brief to learn how
> >> you can reduce costs and improve performance. 
> >> http://p.sf.net/sfu/dell-sfdev2dev
> >> _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel
> > 
> > 
> > 
> > ------------------------------------------------------------------------------
> > Automate Storage Tiering Simply
> > Optimize IT performance and efficiency through flexible, powerful, 
> > automated storage tiering capabilities. View this brief to learn how
> > you can reduce costs and improve performance. 
> > http://p.sf.net/sfu/dell-sfdev2dev
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/edk2-devel
> 
> 
> ------------------------------------------------------------------------------
> Automate Storage Tiering Simply
> Optimize IT performance and efficiency through flexible, powerful, 
> automated storage tiering capabilities. View this brief to learn how
> you can reduce costs and improve performance. 
> http://p.sf.net/sfu/dell-sfdev2dev
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel



------------------------------------------------------------------------------
Automate Storage Tiering Simply
Optimize IT performance and efficiency through flexible, powerful, 
automated storage tiering capabilities. View this brief to learn how
you can reduce costs and improve performance. 
http://p.sf.net/sfu/dell-sfdev2dev
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel