[edk2-devel] [PATCH] StandaloneMmPkg: Support CLANGPDB X64 builds

Marvin Häuser posted 1 patch 2 years, 8 months ago
Failed in applying to current master (apply log)
StandaloneMmPkg/Core/StandaloneMmCore.inf                                         | 9 +++++++--
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf | 7 ++++++-
2 files changed, 13 insertions(+), 3 deletions(-)
[edk2-devel] [PATCH] StandaloneMmPkg: Support CLANGPDB X64 builds
Posted by Marvin Häuser 2 years, 8 months ago
Currently, the flag "-fpie" is passed for all builds with a GCC
family toolchain, including CLANGPDB. CLANGPDB however does not
support this flag as it generates PE/COFF files directly.

As the flag is mostly required for AArch64-specific self-relocation,
drop it for X64 builds and document the limitation to enable X64
CLANGPDB builds of StandaloneMmCore.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
---
 StandaloneMmPkg/Core/StandaloneMmCore.inf                                         | 9 +++++++--
 StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf | 7 ++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf b/StandaloneMmPkg/Core/StandaloneMmCore.inf
index 87bf6e9440a7..e3349fff29cc 100644
--- a/StandaloneMmPkg/Core/StandaloneMmCore.inf
+++ b/StandaloneMmPkg/Core/StandaloneMmCore.inf
@@ -76,6 +76,11 @@ [Guids]
   gEfiEventExitBootServicesGuid

   gEfiEventReadyToBootGuid

 

+#

+# This configuration fails for CLANGPDB, which does not support PIE in the GCC

+# sense. Such however is required for AArch64 StandaloneMmCore self-relocation,

+# and thus the CLANGPDB toolchain is unsupported for AArch64 for this module.

+#

 [BuildOptions]

-  GCC:*_*_*_CC_FLAGS = -fpie

-  GCC:*_*_*_DLINK_FLAGS = -Wl,-z,text,-Bsymbolic,-pie

+  GCC:*_*_AARCH64_CC_FLAGS = -fpie

+  GCC:*_*_AARCH64_DLINK_FLAGS = -Wl,-z,text,-Bsymbolic,-pie

diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
index 4fa426f58ef4..dcbb082d4ab8 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
@@ -54,5 +54,10 @@ [Guids]
 [FeaturePcd.AARCH64]

   gArmTokenSpaceGuid.PcdFfaEnable

 

+#

+# This configuration fails for CLANGPDB, which does not support PIE in the GCC

+# sense. Such however is required for AArch64 StandaloneMmCore self-relocation,

+# and thus the CLANGPDB toolchain is unsupported for AArch64 for this module.

+#

 [BuildOptions]

-  GCC:*_*_*_CC_FLAGS = -fpie

+  GCC:*_*_AARCH64_CC_FLAGS = -fpie

-- 
2.31.1



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


Re: [edk2-devel] [PATCH] StandaloneMmPkg: Support CLANGPDB X64 builds
Posted by Steven Shi 2 years, 6 months ago
Hi Marvin,

Thank you to offer a path for the CLANGPDB '-fpie' issue. I find a simpler way to only skip the '-fpie' option in CLANGPDB but keep it for all other build toolchain. It is to explicitly define the CLANGPDB build option and override the GCC family definition in the INF file. What do you think?



diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf b/StandaloneMmPkg/Core/StandaloneMmCore.inf

[BuildOptions]

   GCC:*_*_*_CC_FLAGS = -fpie

   GCC:*_*_*_DLINK_FLAGS = -Wl,-z,text,-Bsymbolic,-pie

+  CLANGPDB:*_*_*_CC_FLAGS= -fno-pie

+  CLANGPDB:*_*_*_DLINK_FLAGS =



diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf

[BuildOptions]

   GCC:*_*_*_CC_FLAGS = -fpie

+  CLANGPDB:*_*_*_CC_FLAGS= -fno-pie







Thanks

Steven Shi





> -----Original Message-----

> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Marvin

> Häuser

> Sent: Monday, August 9, 2021 3:40 AM

> To: devel@edk2.groups.io

> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>; Sami Mujawar

> <sami.mujawar@arm.com>; Yao, Jiewen <jiewen.yao@intel.com>; Supreeth

> Venkatesh <supreeth.venkatesh@arm.com>; Vitaly Cheptsov

> <vit9696@protonmail.com>

> Subject: [edk2-devel] [PATCH] StandaloneMmPkg: Support CLANGPDB X64

> builds

>

> Currently, the flag "-fpie" is passed for all builds with a GCC

> family toolchain, including CLANGPDB. CLANGPDB however does not

> support this flag as it generates PE/COFF files directly.

>

> As the flag is mostly required for AArch64-specific self-relocation,

> drop it for X64 builds and document the limitation to enable X64

> CLANGPDB builds of StandaloneMmCore.

>

> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org<mailto:ardb+tianocore@kernel.org>>

> Cc: Sami Mujawar <sami.mujawar@arm.com<mailto:sami.mujawar@arm.com>>

> Cc: Jiewen Yao <jiewen.yao@intel.com<mailto:jiewen.yao@intel.com>>

> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com<mailto:supreeth.venkatesh@arm.com>>

> Cc: Vitaly Cheptsov <vit9696@protonmail.com<mailto:vit9696@protonmail.com>>

> Signed-off-by: Marvin Häuser <mhaeuser@posteo.de<mailto:mhaeuser@posteo.de>>

> ---

>  StandaloneMmPkg/Core/StandaloneMmCore.inf                                         | 9

> +++++++--

>

> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmC

> oreEntryPoint.inf | 7 ++++++-

>  2 files changed, 13 insertions(+), 3 deletions(-)

>

> diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf

> b/StandaloneMmPkg/Core/StandaloneMmCore.inf

> index 87bf6e9440a7..e3349fff29cc 100644

> --- a/StandaloneMmPkg/Core/StandaloneMmCore.inf

> +++ b/StandaloneMmPkg/Core/StandaloneMmCore.inf

> @@ -76,6 +76,11 @@ [Guids]

>    gEfiEventExitBootServicesGuid

>

>    gEfiEventReadyToBootGuid

>

>

>

> +#

>

> +# This configuration fails for CLANGPDB, which does not support PIE in the

> GCC

>

> +# sense. Such however is required for AArch64 StandaloneMmCore self-

> relocation,

>

> +# and thus the CLANGPDB toolchain is unsupported for AArch64 for this

> module.

>

> +#

>

>  [BuildOptions]

>

> -  GCC:*_*_*_CC_FLAGS = -fpie

>

> -  GCC:*_*_*_DLINK_FLAGS = -Wl,-z,text,-Bsymbolic,-pie

>

> +  GCC:*_*_AARCH64_CC_FLAGS = -fpie

>

> +  GCC:*_*_AARCH64_DLINK_FLAGS = -Wl,-z,text,-Bsymbolic,-pie

>

> diff --git

> a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMm

> CoreEntryPoint.inf

> b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMm

> CoreEntryPoint.inf

> index 4fa426f58ef4..dcbb082d4ab8 100644

> ---

> a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMm

> CoreEntryPoint.inf

> +++

> b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMm

> CoreEntryPoint.inf

> @@ -54,5 +54,10 @@ [Guids]

>  [FeaturePcd.AARCH64]

>

>    gArmTokenSpaceGuid.PcdFfaEnable

>

>

>

> +#

>

> +# This configuration fails for CLANGPDB, which does not support PIE in the

> GCC

>

> +# sense. Such however is required for AArch64 StandaloneMmCore self-

> relocation,

>

> +# and thus the CLANGPDB toolchain is unsupported for AArch64 for this

> module.

>

> +#

>

>  [BuildOptions]

>

> -  GCC:*_*_*_CC_FLAGS = -fpie

>

> +  GCC:*_*_AARCH64_CC_FLAGS = -fpie

>

> --

> 2.31.1

>

>

>

> 

>




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