Clang builds of Tiano?

35 views
Skip to first unread message

Warkentin, Andrei

unread,
Apr 25, 2023, 4:40:01 PM4/25/23
to fw-ex...@riscv.org
Hi folks,

Is anyone playing around with clang builds of TianoCore EDK2? Is there a known-good toolchain and/or pointers to an appropriate tools_def definitions?

A

Sunil V L

unread,
Apr 26, 2023, 11:37:04 PM4/26/23
to fw-ex...@riscv.org
Hi Andrei,

Sorry for delayed response as I am currently on vacation. This is in
TODO list. Since Rebecca is cleaning up things related to this and
moving to clangdwarf + lld for other archs, we can try after her work
gets merged.

Thanks,

Sunil

Sunil V L

unread,
Jun 28, 2023, 3:24:04 AM6/28/23
to fw-ex...@riscv.org
Hi Andrei,

Below branch has changes required to build edk2 with clang+lld. I plan
to send the patches upstream sometime next week. It will be great if you
can review and test these changes.

https://github.com/vlsunil/edk2/tree/clang_lld_lto

Thanks!

Sunil

On 26/04/23 02:09, Warkentin, Andrei wrote:

Heinrich Schuchardt

unread,
Jun 28, 2023, 5:36:57 AM6/28/23
to Sunil V L, fw-ex...@riscv.org
On 6/28/23 09:24, Sunil V L wrote:
> Hi Andrei,
>
> Below branch has changes required to build edk2 with clang+lld. I plan
> to send the patches upstream sometime next week. It will be great if you
> can review and test these changes.
>
> https://github.com/vlsunil/edk2/tree/clang_lld_lto
>
> Thanks!
>
> Sunil
>

Hello Sunil,

Great to see this happening. It might be helpful to add clang build
instructions to OvmfPkg/RiscVVirt/README.md.

Best regards

Heinrich

Sunil V L

unread,
Jun 28, 2023, 7:41:14 AM6/28/23
to Heinrich Schuchardt, fw-ex...@riscv.org
Hi Heinrich,

Good point! Added another patch in this series to update the
readme. Updated the same branch with latest patches.

Thanks!
Sunil

Heinrich Schuchardt

unread,
Jun 28, 2023, 8:29:55 AM6/28/23
to Sunil V L, fw-ex...@riscv.org
I followed the README. This is just the last step:

$ build -a RISCV64 --buildtarget RELEASE -p
OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc -t CLANGDWARF
Build environment: Linux-6.3.0-7-generic-x86_64-with-glibc2.37
Build start time: 13:59:38, Jun.28 2023

WORKSPACE = /home/user/workspace/edk2-build
PACKAGES_PATH = /home/user/workspace/edk2-build/edk2
EDK_TOOLS_PATH = /home/user/workspace/edk2-build/edk2/BaseTools
CONF_PATH = /home/user/workspace/edk2-build/edk2/Conf
PYTHON_COMMAND = python3

Processing meta-data
.
Architecture(s) = RISCV64
Build target = RELEASE
Toolchain = CLANGDWARF

Active Platform =
/home/user/workspace/edk2-build/edk2/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc


build.py...
: error F000: CC_PATH doesn't exist in CLANGDWARF ToolChain and
RISCV64 Arch.

[/home/user/workspace/edk2-build/edk2/MdeModulePkg/Universal/PCD/Dxe/Pcd.inf]
.

- Failed -
Build end time: 13:59:40, Jun.28 2023
Build total time: 00:00:01

---

The missing piece is:

rm -f edk2/Conf/tools_def.txt

before all other steps.

I restarted after deleting the old configuration file and ended up with:

Building ...
/home/user/workspace/edk2-build/edk2/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
[RISCV64]
clang: error: invalid linker name in argument '-fuse-ld=lld'
clang: error: invalid linker name in argument '-fuse-ld=lld'

Some cleanup before switching to clang seems to be still missing.

On a clean checkout I ran into

BrotliCompress.c:20:10: fatal error: ./brotli/c/common/constants.h: No
such file or directory
20 | #include "./brotli/c/common/constants.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following commands are missing in the instructions:

git submodules init
git submodules update

Currently I am stuck on these errors:

clang: error: no such file or directory:
'/tmp/Build/RiscVVirtQemu/RELEASE_CLANGDWARF/RISCV64/MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib/DEBUG/BootManagerVfr.c'
clang: error: no input files
clang: error: no such file or directory:
'/tmp/Build/RiscVVirtQemu/RELEASE_CLANGDWARF/RISCV64/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib/DEBUG/DeviceManagerVfr.c'
clang: error: no input files

Best regards

Heinrich

Heinrich Schuchardt

unread,
Jun 28, 2023, 8:46:36 AM6/28/23
to Sunil V L, fw-ex...@riscv.org
Missing package lld causes this message. The README might better
indicate which packages are needed for building with clang.

Best regards

Heinrich

Sunil V L

unread,
Jun 28, 2023, 10:51:22 AM6/28/23
to Heinrich Schuchardt, fw-ex...@riscv.org
Thanks. I have updated the doc indicating what needs to be installed.

> Best regards
>
> Heinrich
>
> >
> > Some cleanup before switching to clang seems to be still missing.
> >
> > On a clean checkout I ran into
> >
> > BrotliCompress.c:20:10: fatal error: ./brotli/c/common/constants.h: No
> > such file or directory
> >    20 | #include "./brotli/c/common/constants.h"
> >       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > The following commands are missing in the instructions:
> >
> > git submodules init
> > git submodules update
> >
Typically, edk2 users are aware of this. But I have added one more
section on how to clone with submodules.

> > Currently I am stuck on these errors:
> >
> > clang: error: no such file or directory: '/tmp/Build/RiscVVirtQemu/RELEASE_CLANGDWARF/RISCV64/MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib/DEBUG/BootManagerVfr.c'
> > clang: error: no input files
> > clang: error: no such file or directory: '/tmp/Build/RiscVVirtQemu/RELEASE_CLANGDWARF/RISCV64/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib/DEBUG/DeviceManagerVfr.c'
> > clang: error: no input files
> >
Is this resolved after installing lld? Were you able to build (and
boot) with CLANGDWARF?

Thanks for your help!
Sunil

Heinrich Schuchardt

unread,
Jun 28, 2023, 11:01:39 AM6/28/23
to Sunil V L, fw-ex...@riscv.org
Thanks for adding the --reconfig flag.

Will lld installed I was able to build EDK II and run the image.

For "OvmfPkg/RiscVVirt: Update README for CLANGDWARF support" you may add

Reviewed-by: Heinrich Schuchardt <heinrich....@canonical.com>
Reply all
Reply to author
Forward
0 new messages