[edk2-devel][PATCH] EmulatorPkg/Unix Prevents the compiler form optimizing unused variable

Yu Liu posted 1 patch 3 years, 6 months ago
Failed in applying to current master (apply log)
EmulatorPkg/Unix/Host/Host.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[edk2-devel][PATCH] EmulatorPkg/Unix Prevents the compiler form optimizing unused variable
Posted by Yu Liu 3 years, 6 months ago
gInXcode is only used by GDB script and if optimization is turned on then compiler
treats this variable as unused so it can't been linked in the final object.

Signed-off-by: LiuYu <liuyu@greatwall.com.cn>
---
 EmulatorPkg/Unix/Host/Host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/EmulatorPkg/Unix/Host/Host.c b/EmulatorPkg/Unix/Host/Host.c
index b4e5510613..b851264c8e 100644
--- a/EmulatorPkg/Unix/Host/Host.c
+++ b/EmulatorPkg/Unix/Host/Host.c
@@ -54,7 +54,7 @@ IMAGE_CONTEXT_TO_MOD_HANDLE  *mImageContextModHandleArray = NULL;
 EFI_PEI_PPI_DESCRIPTOR  *gPpiList;
 
 
-int gInXcode = 0;
+int gInXcode  __attribute__((used)) = 0;
 

 /*++
-- 
2.20.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#65607): https://edk2.groups.io/g/devel/message/65607
Mute This Topic: https://groups.io/mt/77074006/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel][PATCH] EmulatorPkg/Unix Prevents the compiler form optimizing unused variable
Posted by Ni, Ray 3 years, 6 months ago
Jordan, Andrew,
I will defer to you to review the patch.

Thanks,
Ray

> -----Original Message-----
> From: LiuYu <liuyu@greatwall.com.cn>
> Sent: Friday, September 25, 2020 1:49 PM
> To: Justen, Jordan L <jordan.l.justen@intel.com>; afish@apple.com; Ni, Ray <ray.ni@intel.com>
> Cc: devel@edk2.groups.io; LiuYu <liuyu@greatwall.com.cn>
> Subject: [edk2-devel][PATCH] EmulatorPkg/Unix Prevents the compiler form optimizing unused variable
> 
> gInXcode is only used by GDB script and if optimization is turned on then compiler
> treats this variable as unused so it can't been linked in the final object.
> 
> Signed-off-by: LiuYu <liuyu@greatwall.com.cn>
> ---
>  EmulatorPkg/Unix/Host/Host.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/EmulatorPkg/Unix/Host/Host.c b/EmulatorPkg/Unix/Host/Host.c
> index b4e5510613..b851264c8e 100644
> --- a/EmulatorPkg/Unix/Host/Host.c
> +++ b/EmulatorPkg/Unix/Host/Host.c
> @@ -54,7 +54,7 @@ IMAGE_CONTEXT_TO_MOD_HANDLE  *mImageContextModHandleArray = NULL;
>  EFI_PEI_PPI_DESCRIPTOR  *gPpiList;
> 
> 
> -int gInXcode = 0;
> +int gInXcode  __attribute__((used)) = 0;
> 
> 
>  /*++
> --
> 2.20.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#65619): https://edk2.groups.io/g/devel/message/65619
Mute This Topic: https://groups.io/mt/77074006/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-