bao-hypervisor icon indicating copy to clipboard operation
bao-hypervisor copied to clipboard

feat(clang): add clang support for riscv64 and aarch64

Open ninolomata opened this issue 1 year ago • 5 comments

ninolomata avatar Jul 20 '23 19:07 ninolomata

I haven't delved too deeply into this yet, but I have a small suggestion. Could you please provide additional information in the PR description about how and in what targets you have tested this?

Also, for arm targets, we should test this with armclang, not just clang.

Plus, aarch32 must also be supported. @AfonsoSantos96 could you try to take a look at this?

josecm avatar Jul 20 '23 21:07 josecm

For Ubuntu 20.04, I've used

16:43 $ ~/toolchains/arm/clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang-cpp --version
clang version 16.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/daniel/toolchains/arm/clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/bin

and I've effectively run bao on qemu-aarch64-virt platform:

=> go 0x50000000
## Starting application at 0x50000000 ...
Bao Hypervisor w/ clang compilation
Bao bare-metal test guest
cpu 1 up
cpu 2 up
cpu 3 up
cpu 0 up
cpu0: timer_handler
cpu1: ipi_handler
cpu2: ipi_handler
cpu3: ipi_handler
QEMU: Terminated

danielRep avatar Jul 27 '23 15:07 danielRep

@ninolomata , could you separate the changes into x number of meaningful commits? It would be easier to understand some of the changes made. I feel that e.g. with the bao code changes it was an iterative process, maybe that would be sufficient to map it to significant commits.

danielRep avatar Jul 27 '23 16:07 danielRep

Also, @ninolomata , could you clarify exactly what is need to compile the code with clang? I'm guessing:

make PLATFORM=... CONFIG=... LLVM=/path/to/llvm/install

Is my assumption correct?

I've installed clang via a package manager. So all the executables are in /usr/bin. Could you clarify how you have installed clang also?

josecm avatar Aug 15 '23 20:08 josecm

Another point is that we should include build checks for clang now that we have a CI pipeline.

josecm avatar Oct 20 '23 17:10 josecm

I've rebase this branch with main, and replaced the proposed flag with CC_IS_* to distinguish between GCC and CLANG compilers both on the Makefile and in the source code (e.g., on src/arch/armv8/aarch64/boot.S).

I also propose to use the LLVM variable as a full path, so if one wants to use the package manager (to install clang llvm lld) it is possible to simply pass LLVM=/usr/bin/ as a Makefile argument.

Another change is replacing the use of CROSS_COMPILE variable to create the target architecture variable for clang, with ARCH_TARGET. I feel that CROSS_COMPILE variable having different meaning depending on the compiler used can be confusing.

DavidMCerdeira avatar Jul 25 '24 09:07 DavidMCerdeira

@miguelafsilva5 I don't think those commit tags make sense. Maybe always use 'clang', e.g. fix(clang): fix inline functions

josecm avatar Jul 26 '24 10:07 josecm