From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) by mx.groups.io with SMTP id smtpd.web11.13285.1653518905958236259 for ; Wed, 25 May 2022 15:48:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GjojJL6w; spf=pass (domain: gmail.com, ip: 209.85.222.52, mailfrom: pedro.falcato@gmail.com) Received: by mail-ua1-f52.google.com with SMTP id 63so40700uaw.10 for ; Wed, 25 May 2022 15:48:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=S5i2OvuZLOf3cuMnYtMYI0y7LOCCgVImU0gd8gPA7Kc=; b=GjojJL6wd8mZQI1Ryl44bgDwF4xr08k/ZBA50DFaYinTb+aLllPgM8IXzr3j371UBj cFMXyFElEVJ5/YyMqakuUxlj8VbHhBZJh0M7uRyhDDCkMDEhXrnNuLYEYoSa4jAASQ1a xvm9Q7JmUlaBHMClyw5lMjb30fG5P1xMFdwLkqICjkzzEu8jacvg2PwFzm29gFlb9G8N 8GaZzWMcxBhkH0vKA7oMBqBD6XB8jCn0RQqx8VofYqtiGtGKogSa1dWrosqLJHoEAqB0 nbJzXpM2Y9aOL1z118yfHTFEgXKeIpbq3+LE8W2jUdCvN47+5AWTtMZA5/BANwqNTLRE rdHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=S5i2OvuZLOf3cuMnYtMYI0y7LOCCgVImU0gd8gPA7Kc=; b=seqAUrorbMQ38g1vuUTqqym0tsx3MtKXc7krn3OIS0eAySUmLG0ph685lQGqxd6ioc D7YK1VVGPhEEM7IEghwFA+6ql4+oVPfj1rZILJ1TqpdfRwUjEKjLhusLn4jWzn5ntOgE Uej+CO6zItKO+1dQnj/t1nMjTJAs1nbHG8PxcTwRDqN/JPVfsZdTrHMXfmPK50ArjyjR on48A8DAXkyDmKJks6Gqimgz2htxY3GHHrXFD6kyuHD8Wk5BoVeXSsi228n+td0eFWV5 BT82TY75FwdRDrlX7yFpGY0ZQKvKiFhpEzPxA7QKAcGhJPYPF9StqpLJrSN/IgbaPQ9z MYSg== X-Gm-Message-State: AOAM533roFeZJ/jrkDq/+F62DI/sN3Bh+6+bo8a3bzeP1EN04h+RN/1x 1WijQTgizVAAtqmrfg62hPTtx5Vxn4l9bmWiwE0= X-Google-Smtp-Source: ABdhPJyH8SKBRQwSNYyepGUqJUUWu3vJyV/229O24InQkAy/rG6AFfROWjMqNJ44PclWlZsy6wb+V4kcN7sF2a3IYQE= X-Received: by 2002:ab0:4a1c:0:b0:368:a05b:ef41 with SMTP id q28-20020ab04a1c000000b00368a05bef41mr12102208uae.40.1653518905092; Wed, 25 May 2022 15:48:25 -0700 (PDT) MIME-Version: 1.0 References: <19fda580-50da-302b-4c4e-0457fb28174b@quicinc.com> In-Reply-To: From: "Pedro Falcato" Date: Wed, 25 May 2022 23:48:15 +0100 Message-ID: Subject: Re: [edk2-devel] OvmfPkgX64 doesn't build with CLANG38 (clang 14.0.3) NOOPT - undefined reference to `memcpy' To: "Yao, Jiewen" Cc: Ard Biesheuvel , edk2-devel-groups-io , Rebecca Cran , Ard Biesheuvel , "Justen, Jordan L" , Gerd Hoffmann Content-Type: multipart/alternative; boundary="000000000000f7ae2905dfddde57" --000000000000f7ae2905dfddde57 Content-Type: text/plain; charset="UTF-8" Is there a legitimate reason not to define memcpy? It'd be easier to do so and comply to the compiler's requirements. On Wed, 25 May 2022, 23:38 Yao, Jiewen, wrote: > Hi > > Would you please use CopyMem() for the structure assignment? > > VgpuGop->GopModeInfo = *GopModeInfo; > > > > That is best known method to resolve memcpy symbol issue. > > > > Thank you > > Yao Jiewen > > > > > > *From:* Pedro Falcato > *Sent:* Thursday, May 26, 2022 1:01 AM > *To:* Ard Biesheuvel > *Cc:* edk2-devel-groups-io ; Rebecca Cran < > quic_rcran@quicinc.com>; Ard Biesheuvel ; Yao, > Jiewen ; Justen, Jordan L ; > Gerd Hoffmann > *Subject:* Re: [edk2-devel] OvmfPkgX64 doesn't build with CLANG38 (clang > 14.0.3) NOOPT - undefined reference to `memcpy' > > > > On Wed, May 25, 2022 at 5:45 PM Ard Biesheuvel wrote: > > On Wed, 25 May 2022 at 18:44, Pedro Falcato > wrote: > > > > > > > > On Wed, May 25, 2022 at 4:50 PM Ard Biesheuvel wrote: > >> > >> On Wed, 25 May 2022 at 17:08, Rebecca Cran > wrote: > >> > > >> > I noticed OvmfPkg/OvmfPkgX64.dsc doesn't build with `-t CLANG38 -b > >> > NOOPT` (with clang version 14.0.2) with the latest edk2 master > >> > (07c0c2eb0a5970db614ebce1060fc79d6904bdfd): > >> > > >> > make: Nothing to be done for 'tbuild'. > >> > /usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM > value: > >> > 0x23 > >> > > /home/bcran/src/upstream/uefi/edk2/Build/OvmfX64/NOOPT_CLANG38/X64/OvmfPkg/VirtioGpuDxe/VirtioGpu/OUTPUT/VirtioGpuDxe.lib(Gop.obj): > >> > in function `GopSetMode': > >> > Gop.c:(.text.GopSetMode+0x418): undefined reference to `memcpy' > >> > >> Can you dump the object file to see where the memcpy() call is emitted? > > > > I think I found the smoking gun: > https://github.com/tianocore/edk2/blob/916f90baa547b3ebef8fa87c530e2f0c8e35e1e3/OvmfPkg/VirtioGpuDxe/Gop.c#L512 > > Indeed. We don't support struct assignment in Tianocore code, exactly > for this reason. > > Note: We should think about providing some basic libc functions in base > EDK2 as some are required by the clang/GCC compilers (see > https://gcc.gnu.org/onlinedocs/gcc/Standards.html, grep for memcpy or > freestanding). > > Passing -ffreestanding would also be a good idea as to let the compiler > know it's dealing with a freestanding environment vs a hosted user-space > one. > > > > All the best, > > Pedro > --000000000000f7ae2905dfddde57 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Is there a legitimate reason not to define memcpy? It'= ;d be easier to do so and comply to the compiler's requirements.
<= br>
On Wed,= 25 May 2022, 23:38 Yao, Jiewen, <jiewen.yao@intel.com> wrote:

Hi

Would you please use CopyMem() for the structure ass= ignment?

VgpuGop->GopModeInfo=C2=A0 =3D *GopModeInfo;

=C2=A0

That is best known method to resolve memcpy symbol i= ssue.

=C2=A0

Thank you

Yao Jiewen

=C2=A0

=C2=A0

From: Pedro Falcato <pedro.falcato@gm= ail.com>
Sent: Thursday, May 26, 2022 1:01 AM
To: Ard Biesheuvel <ardb@kernel.org>
Cc: edk2-devel-groups-io <devel@edk2.groups.io>; Rebecca= Cran <quic_rcran@quicinc.com>; Ard Biesheuvel <ardb+tianocore@kernel.org>; Yao, Jiewen <jiewen.yao@intel.com= >; Justen, Jordan L <jordan.l.justen@intel.com>; Ge= rd Hoffmann <kraxel@redhat.com>
Subject: Re: [edk2-devel] OvmfPkgX64 doesn't build with CLANG38 = (clang 14.0.3) NOOPT - undefined reference to `memcpy'

=C2=A0

On Wed, May 25, 2022 at 5:45 PM Ard Biesheuvel <<= a href=3D"mailto:ardb@kernel.org" target=3D"_blank" rel=3D"noreferrer">ardb= @kernel.org> wrote:

On Wed, 25 May 2022 at 18:44, Pedro Falcato <pedro.falcato@gmail.com> wrote:
>
>
>
> On Wed, May 25, 2022 at 4:50 PM Ard Biesheuvel <ardb@kernel.org>= ; wrote:
>>
>> On Wed, 25 May 2022 at 17:08, Rebecca Cran <quic_rcran@quic= inc.com> wrote:
>> >
>> > I noticed OvmfPkg/OvmfPkgX64.dsc doesn't build with `-t C= LANG38 -b
>> > NOOPT` (with clang version 14.0.2) with the latest edk2 maste= r
>> > (07c0c2eb0a5970db614ebce1060fc79d6904bdfd):
>> >
>> > make: Nothing to be done for 'tbuild'.
>> > /usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled F= ORM value:
>> > 0x23
>> > /home/bcran/src/upstream/uefi/edk2/Build/OvmfX64/NOOPT_CLANG3= 8/X64/OvmfPkg/VirtioGpuDxe/VirtioGpu/OUTPUT/VirtioGpuDxe.lib(Gop.obj):
>> > in function `GopSetMode':
>> > Gop.c:(.text.GopSetMode+0x418): undefined reference to `memcp= y'
>>
>> Can you dump the object file to see where the memcpy() call is emi= tted?
>
> I think I found the smoking gun: https://github.com/tianocore/edk2/blob/916f90baa547b3ebef8fa87c530e2f0c8e35= e1e3/OvmfPkg/VirtioGpuDxe/Gop.c#L512

Indeed. We don't support struct assignment in Tianocore code, exactly for this reason.

Note: We should think about providing some basic lib= c functions in base EDK2 as some are required by the clang/GCC compilers (s= ee https://gcc.gnu.org/onlinedocs/gcc/Standards.html, grep for memcpy or freestanding).

Passing -ffreestanding would also be a good idea as = to let the compiler know it's dealing with a freestanding environment v= s a hosted user-space one.

=C2=A0

All the best,

Pedro

--000000000000f7ae2905dfddde57--