Re: [PATCH] KVM: arm64: nVHE: gen-hyprel: Silent build warnings

From: Nick Desaulniers
Date: Thu Oct 10 2024 - 11:24:03 EST


On Thu, Oct 10, 2024 at 1:13 AM tianjia.zhang
<tianjia.zhang@xxxxxxxxxxxxxxxxx> wrote:
>
>
>
> On 10/9/24 7:07 PM, Marc Zyngier wrote:
> > On Wed, 09 Oct 2024 09:57:51 +0100,
> > Tianjia Zhang <tianjia.zhang@xxxxxxxxxxxxxxxxx> wrote:
> >>
> >> This patch silent the some mismatch format build warnings
> >> with clang, like:
> >>
> >> arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:233:2: warning: format specifies
> >> type 'unsigned long' but the argument has type 'Elf64_Off'
> >> (aka 'unsigned long long') [-Wformat]
> >> 233 | assert_ne(off, 0UL, "%lu");
> >> | ^~~~~~~~~~~~~~~~~~~~~~~~~~
> >> | %llu
> >> arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:193:34: note: expanded from macro 'assert_ne'
> >> 193 | #define assert_ne(lhs, rhs, fmt) assert_op(lhs, rhs, fmt, !=)
> >> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >> arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:188:19: note: expanded from macro 'assert_op'
> >> 187 | " failed (lhs=" fmt ", rhs=" fmt \
> >> | ~~~
> >> 188 | ", line=%d)", _lhs, _rhs, __LINE__); \
> >> | ^~~~
> >> arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:167:17: note: expanded from macro 'fatal_error'
> >> 166 | fprintf(stderr, "error: %s: " fmt "\n", \
> >> | ~~~
> >> 167 | elf.path, ## __VA_ARGS__); \
> >> | ^~~~~~~~~~~
> >>
> >> Signed-off-by: Tianjia Zhang <tianjia.zhang@xxxxxxxxxxxxxxxxx>
> >
> > I don't see these warnings. What version of LLVM are you using?
> >
>
> I compiled the kernel on Apple Silicon M3 Pro in macOS 15.0.1, Maybe this is
> a special scenario that is rarely used.

Right, so I had an initial patch set for building the kernel from a
MacOS host. I sent a v1, but didn't chase sending a v2 at the time
because there didn't appear to be any interest.

https://www.phoronix.com/news/Linux-Compile-On-macOS

Since then, I saw a v2 or even a v3 fly by (I was cc'ed).

One issue I recall building from MacOS was that MacOS does not have an
<elf.h> (their object file format is not ELF, but Mach-O). I had to
install some dependency through homebrew for that header.

Just a guess but:
Perhaps it defines Elf64_Off as a `unsigned long` incorrectly, and
should be defining it as an `unsigned long long`. I'd check if that's
the case and if so, Tianjia, you may want to report that issue on the
thread where folks are reposting the MacOS host support.

>
> Details of clang:
>
> # clang --version
> Homebrew clang version 19.1.1
> Target: arm64-apple-darwin24.0.0
> Thread model: posix
> InstalledDir: /opt/homebrew/Cellar/llvm/19.1.1/bin
>
> Cheers,
> Tianjia
>


--
Thanks,
~Nick Desaulniers