public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ardb@kernel.org>
To: Rebecca Cran <rebecca@bsdio.com>
Cc: devel@edk2.groups.io,
	Michael D Kinney <michael.d.kinney@intel.com>,
	 Liming Gao <gaoliming@byosoft.com.cn>,
	Zhiguang Liu <zhiguang.liu@intel.com>,
	 Bob Feng <bob.c.feng@intel.com>,
	Yuwei Chen <yuwei.chen@intel.com>,  Andrew Fish <afish@apple.com>,
	Leif Lindholm <quic_llindhol@quicinc.com>,
	 Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Jordan Justen <jordan.l.justen@intel.com>,
	 Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [PATCH 3/9] BaseTools: Update CLANGDWARF toolchain and remove CLANG35 and CLANG38
Date: Thu, 23 Mar 2023 14:14:07 +0100	[thread overview]
Message-ID: <CAMj1kXG6FuZVKP6N3R472dowfa9cWXca2i7VyJKMDAR3pAcbHQ@mail.gmail.com> (raw)
In-Reply-To: <CAMj1kXFAd_jKNyergq2X+wf34dJgUPNaE-CojRy3xUjN1rvyuA@mail.gmail.com>

On Thu, 23 Mar 2023 at 10:04, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Thu, 23 Mar 2023 at 02:30, Rebecca Cran <rebecca@bsdio.com> wrote:
> >
> > On 3/22/23 5:49 AM, Ard Biesheuvel wrote:
> >
> > >
> > > The reason I added CLANG3x support for ARM in the past is to ensure
> > > compatibility with the ARM proprietary, Clang based toolchain. At the
> > > time, we went with GNU ld, but I would actually prefer if we could
> > > make this work with LLD as well.
> >
> > Just to confirm, I'll keep lld for X64 and IA32, but I won't add
> > -fuse-ld=lld for ARM or AARCH64 since none of the toolchain definitions
> > currently do so.
> >
> >
> > The problem with trying to use lld for aarch64 is the following error:
> >
> >
> > GenFw: ERROR 3000: Invalid
> >    WriteSections64():
> > /home/bcran/uefi/edk2/Build/ArmVirtQemu-AARCH64/RELEASE_CLANGDWARF/AARCH64/ArmVirtPkg/MemoryInitPei/MemoryInitPeim/DEBUG/MemoryInit.dll
> > due to its size (> 1 MB), this module requires 4 KB section alignment.
> >
>
> That seems to be a false positive error in GenFw.
>
> It looks like LLD turns
>
> ADRP
> ADD
>
> into
>
> NOP
> ADR
>
> if the target is within -/+ 1 MiB but it doesn't update the
> relocations, so GenFw goes off into the weeds. I.e..
>
>  304:   d503201f        nop
>                         304: R_AARCH64_ADR_PREL_PG_HI21 .data
>  308:   100015c1        adr     x1, 5c0 <gArmMpCoreInfoPpiGuid>
>                         308: R_AARCH64_ADD_ABS_LO12_NC  .data
>
> This is just another indication that using --emit-relocs is a bad
> idea, and we should really be building PIE executables and converting
> those based on the dynamic relocation instead.
>
> Adding -Wl,--no-relax to the DLINK flags should help with this,
> although I notice that there are other LLD related issues, in the ID
> map code I added to ArmVirtQemu a while ago, so ArmVirtQemu.dsc still
> does not build.

So I played around with this a bit more, also on ARM, and it seems to
me that simply disabling PIE linking is the best approach here - the
PE/COFF conversion essentially turns it into a relocatable binary
already, and so PIE linking does not actually add anything useful
here, and on ARM, the resulting ELF binary triggers an assert in GenFw

So adding

 -fuse-ld=lld -Wl,--no-relax,--no-pie

to both CLANG38_AARCH64_DLINK_FLAGS and CLANG38_ARM_DLINK_FLAGS works
for me locally, i.e., builds complete without errors and can boot
successfully.

We will also be able to drop the GccLto plugin pass through libraries,
which is rather nice as well.

  reply	other threads:[~2023-03-23 13:14 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-22  1:30 [PATCH 0/9] BaseTools,CryptoPkg,MdePkg,OvmfPkg: Delete CLANG35,CLANG38 and update CLANGDWARF, delete VS 2008-2013, EBC Rebecca Cran
2023-03-22  1:30 ` [PATCH 1/9] OvmfPkg: Replace static struct initialization with ZeroMem call Rebecca Cran
2023-03-22  5:55   ` Gerd Hoffmann
2023-03-22  1:30 ` [PATCH 2/9] CryptoPkg: Add CLANGDWARF and remove CLANG35 and CLANG38 compiler flags Rebecca Cran
2023-03-22  1:30 ` [PATCH 3/9] BaseTools: Update CLANGDWARF toolchain and remove CLANG35 and CLANG38 Rebecca Cran
2023-03-22  4:57   ` [edk2-devel] " Guo, Gua
2023-03-22 13:10     ` Rebecca Cran
2023-03-22 22:07       ` Guo, Gua
2023-03-22 22:23         ` Rebecca Cran
2023-03-22 22:46           ` Guo, Gua
2023-03-27 22:15             ` Rebecca Cran
2023-03-22 11:49   ` Ard Biesheuvel
2023-03-22 12:28     ` [edk2-devel] " Rebecca Cran
2023-03-22 12:32       ` Ard Biesheuvel
2023-03-22 13:03         ` Gerd Hoffmann
2023-03-22 13:05           ` Ard Biesheuvel
2023-03-23  1:30     ` Rebecca Cran
2023-03-23  9:04       ` Ard Biesheuvel
2023-03-23 13:14         ` Ard Biesheuvel [this message]
2023-03-22  1:30 ` [PATCH 4/9] BaseTools: Remove VS2008, 2010, 2012 and 2013 toolchain definitions Rebecca Cran
2023-03-22  1:30 ` [PATCH 5/9] BaseTools: Remove VS2008-VS2013 remnants Rebecca Cran
2023-03-22  1:30 ` [PATCH 6/9] MdePkg: " Rebecca Cran
2023-03-22  1:30 ` [PATCH 7/9] edksetup.bat: " Rebecca Cran
2023-03-22  1:30 ` [PATCH 8/9] BaseTools: Remove unused IPHONE_TOOLS and SOURCERY_CYGWIN_TOOLS defs Rebecca Cran
2023-03-22  1:30 ` [PATCH 9/9] BaseTools: Remove EBC (EFI Byte Code) compiler definitions Rebecca Cran
2023-03-22  9:04 ` [PATCH 0/9] BaseTools,CryptoPkg,MdePkg,OvmfPkg: Delete CLANG35,CLANG38 and update CLANGDWARF, delete VS 2008-2013, EBC Ard Biesheuvel
2023-03-22 16:37 ` [edk2-devel] " Oliver Smith-Denny
2023-03-23  1:05   ` 回复: " gaoliming
2023-03-23  1:10     ` Rebecca Cran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMj1kXG6FuZVKP6N3R472dowfa9cWXca2i7VyJKMDAR3pAcbHQ@mail.gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox