Date
1 - 6 of 6
edk2 app size
Roman Bacik
Hi Andrew,
toggle quoted message
Show quoted text
That is great, you are right, overriding flags in the dsc file sounds like a better way. Thank you very much for your help, Roman On Thu, Jan 27, 2022 at 12:26 PM Andrew Fish <afish@...> wrote:
I forgot to mention you can also override the flags per driver/app in the --
This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it. |
|
Andrew Fish
I forgot to mention you can also override the flags per driver/app in the DSC. You can use <BuldOptions>. I don’t see an example of that. Here is an example that overrides <LibraryClasses>. The syntax in the block would be the same as the global [LibraryClasses] block.
toggle quoted message
Show quoted text
https://github.com/tianocore/edk2/blob/master/OvmfPkg/OvmfPkgX64.dsc#L745 MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf { <LibraryClasses> PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf } Thanks, Andrew Fish On Jan 27, 2022, at 12:19 PM, Roman Bacik <roman.bacik@...> wrote: |
|
Roman Bacik
Hi Andrew,
toggle quoted message
Show quoted text
Yes, that is correct, our efi app is 25MB or so. Thanks, Roman *From:* Andrew Fish <afish@...> *Sent:* Thursday, January 27, 2022 12:18 PM *To:* discuss <discuss@edk2.groups.io>; Roman Bacik < roman.bacik@...> *Cc:* Ard Biesheuvel <ard.biesheuvel@...>; Vladimir Olovyannikov < vladimir.olovyannikov@...> *Subject:* Re: [edk2-discuss] edk2 app size Roman, I assume your issue is due to your driver being larger? So you expect the tiny model to not work? https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html -mcmodel=tiny Generate code for the tiny code model. The program and its statically defined symbols must be within 1MB of each other. Programs can be statically or dynamically linked. -mcmodel=small Generate code for the small code model. The program and its statically defined symbols must be within 4GB of each other. Programs can be statically or dynamically linked. This is the default code model. -mcmodel=large Generate code for the large code model. This makes no assumptions about addresses and sizes of sections. Programs can be statically linked only. The -mcmodel=large option is incompatible with -mabi=ilp32, -fpic and -fPIC. If you want a solution that does not require you to override the default compiler settings you could try to set the flag in your DSC file. Usually with the compiler the last version of a flag wins so you could try to overload to -mcmodel=small in the DSC. Here is an example. If you don’t want to restrict to a specific module type you can just use [BuildOptions] https://github.com/tianocore/edk2/blob/master/OvmfPkg/OvmfPkgX64.dsc#L98 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 XCODE:*_*_*_DLINK_FLAGS = -seg1addr 0x1000 -segalign 0x1000 XCODE:*_*_*_MTOC_FLAGS = -align 0x1000 CLANGPDB:*_*_*_DLINK_FLAGS = /ALIGN:4096 You can also replace the * with something that better matches the compiler version you are using if you want to be more targeted, and be portable with other compilers. Thanks, Andrew Fish On Jan 25, 2022, at 8:31 AM, Roman Bacik via groups.io <
roman.bacik@...> wrote: Hi Andrew, We use gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu. This is the settings of the flags: DEBUG_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -O0 -mcmodel=small DEBUG_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -z common-page-size=0x1000 DEBUG_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20 RELEASE_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -flto -Wno-unused-but-set-variable -mcmodel=tiny -fomit-frame-pointer RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 NOOPT_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -O0 -mcmodel=small NOOPT_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -z common-page-size=0x1000 -O0 NOOPT_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20 -O0 Based on your comment, we have made the following change to the RELEASE flags settings, which seems to work: RELEASE_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -flto -Wno-unused-but-set-variable -mcmodel=small -fomit-frame-pointer RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -z common-page-size=0x1000 RELEASE_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20 Thank you very much for your help, Roman On Mon, Jan 24, 2022 at 7:32 PM Andrew Fish <afish@...> wrote: On Jan 24, 2022, at 4:13 PM, Roman Bacik <roman.bacik@...> wrote: We have created bnxtmt.efi app running in edk2 shell. It builds and runs ok when created with NOOPT and DEBUG options. But it fails to link when using RELEASE option. The errors we see: ... /local/ldk/netxtreme/main/Cumulus/util/bnxt-mt/src/bnxtmt/tcl/dos/tclAppIn it.c:224:(.text.Tcl_AppInit+0x50): relocation truncated to fit: R_AARCH64_ADR_PREL_LO21 against `.rodata.str1.1' bnxtmt.dll.ltrans0.ltrans.o: In function `init_efi': /local/ldk/netxtreme/main/Cumulus/util/bnxt-mt/src/bnxtmt/os_util/uefi/os_ uefi.c:363:(.text.Tcl_AppInit+0x60): relocation truncated to fit: R_AARCH64_ADR_PREL_LO21 against symbol `NX2_BootServices' defined in .bss.NX2_BootServices section in bnxtmt.dll.ltrans22.ltrans.o bnxtmt.dll.ltrans0.ltrans.o: In function `tcl_al_diag_init': /local/ldk/netxtreme/main/Cumulus/util/bnxt-mt/src/common/tcl_al/tcl_al.c: 367:(.text.Tcl_AppInit+0x68): relocation truncated to fit: R_AARCH64_ADR_PREL_LO21 against `.rodata.str1.1' bnxtmt.dll.ltrans0.ltrans.o: In function `dg_get_no_pci_flag': /local/ldk/netxtreme/main/Cumulus/util/bnxt-mt/src/common/diag_manager/dg_ init.c:231:(.text.Tcl_AppInit+0x78): relocation truncated to fit: R_AARCH64_ADR_PREL_LO21 against symbol `no_pci_flag.lto_priv.844' defined in .bss.no_pci_flag.lto_priv.844 section in bnxtmt.dll.ltrans9.ltrans.o bnxtmt.dll.ltrans0.ltrans.o: In function `console_init': /local/ldk/netxtreme/main/Cumulus/util/bnxt-mt/src/common/util/debug.c:64: (.text.Tcl_AppInit+0x88): relocation truncated to fit: R_AARCH64_ADR_PREL_LO21 against `.bss.console_buffer.lto_priv.1155' ... Do you have any suggestions on how to fix it? Thanks, Roman, Which toolchain are you using? If you look in Conf/tools_def.txt (it was copied from BaseTools/Conf/tools_def.template [1]) it should show you the compiler and linker flags. So you could take a quick look to see if something is unique about the RELEASE build. <build type or * for all>_<compiler>_AARCH64_CC_FLAGS <build type or * for all>_<compiler_AARCH64_DLINK_FLAGS You can change the Conf/tools_def.txt locally to test things out, but it will get copied back over from the template file on a new build. It looks like these are likely 32-bit relocations that don’t resolve. So the other thing to look for is does you RELEASE build add any large global data structures? [1] https://github.com/tianocore/edk2/blob/master/BaseTools/Conf/tools_def.template Thanks, Andrew Fish Roman -- This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it. -- This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it. -- This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it. |
|
Andrew Fish
Roman,
toggle quoted message
Show quoted text
I assume your issue is due to your driver being larger? So you expect the tiny model to not work? https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html -mcmodel=tiny <>Generate code for the tiny code model. The program and its statically defined symbols must be within 1MB of each other. Programs can be statically or dynamically linked. -mcmodel=small <>Generate code for the small code model. The program and its statically defined symbols must be within 4GB of each other. Programs can be statically or dynamically linked. This is the default code model. -mcmodel=large <>Generate code for the large code model. This makes no assumptions about addresses and sizes of sections. Programs can be statically linked only. The -mcmodel=large option is incompatible with -mabi=ilp32, -fpic and -fPIC. If you want a solution that does not require you to override the default compiler settings you could try to set the flag in your DSC file. Usually with the compiler the last version of a flag wins so you could try to overload to -mcmodel=small in the DSC. Here is an example. If you don’t want to restrict to a specific module type you can just use [BuildOptions] https://github.com/tianocore/edk2/blob/master/OvmfPkg/OvmfPkgX64.dsc#L98 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 XCODE:*_*_*_DLINK_FLAGS = -seg1addr 0x1000 -segalign 0x1000 XCODE:*_*_*_MTOC_FLAGS = -align 0x1000 CLANGPDB:*_*_*_DLINK_FLAGS = /ALIGN:4096 You can also replace the * with something that better matches the compiler version you are using if you want to be more targeted, and be portable with other compilers. Thanks, Andrew Fish On Jan 25, 2022, at 8:31 AM, Roman Bacik via groups.io <roman.bacik@...> wrote: |
|
Roman Bacik
Hi Andrew,
toggle quoted message
Show quoted text
We use gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu. This is the settings of the flags: DEBUG_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -O0 -mcmodel=small DEBUG_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -z common-page-size=0x1000 DEBUG_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20 RELEASE_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -flto -Wno-unused-but-set-variable -mcmodel=tiny -fomit-frame-pointer RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 NOOPT_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -O0 -mcmodel=small NOOPT_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -z common-page-size=0x1000 -O0 NOOPT_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20 -O0 Based on your comment, we have made the following change to the RELEASE flags settings, which seems to work: RELEASE_GCC5_AARCH64_CC_FLAGS = DEF(GCC5_AARCH64_CC_FLAGS) -flto -Wno-unused-but-set-variable -mcmodel=small -fomit-frame-pointer RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -z common-page-size=0x1000 RELEASE_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20 Thank you very much for your help, Roman On Mon, Jan 24, 2022 at 7:32 PM Andrew Fish <afish@...> wrote:
--
This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it. |
|
Andrew Fish
On Jan 24, 2022, at 4:13 PM, Roman Bacik <roman.bacik@...> wrote:Roman, Which toolchain are you using? If you look in Conf/tools_def.txt (it was copied from BaseTools/Conf/tools_def.template [1]) it should show you the compiler and linker flags. So you could take a quick look to see if something is unique about the RELEASE build. <build type or * for all>_<compiler>_AARCH64_CC_FLAGS <build type or * for all>_<compiler_AARCH64_DLINK_FLAGS You can change the Conf/tools_def.txt locally to test things out, but it will get copied back over from the template file on a new build. It looks like these are likely 32-bit relocations that don’t resolve. So the other thing to look for is does you RELEASE build add any large global data structures? [1] https://github.com/tianocore/edk2/blob/master/BaseTools/Conf/tools_def.template Thanks, Andrew Fish Roman |
|