On Sat, Jun 12, 2021, 1:56 AM Nathan Chancellor <nathan@kernel.org> wrote:
On 6/11/2021 1:58 AM, Hyeonggon Yoo wrote:> After playing with clang
more a bit, I got to know that
> compiletime_assert makes weird link error (undefined reference to
> compiletime_assert_XXX), Not a compile error.
>
>
> I think it's time to CC ClangBuiltLinux maintainers, who work on
> clang/llvm build support.
>
> [+CC Nathan and Nick]
>
> I assumeed that compiletime_assert (in linux/compiler.h) will make
> compiler error, but it makes no compile error, just makes weird link error.
>
> I'm not sure it it works well with clang, or somewhat buggy status?

I am guessing this alone is why we were keyed into the thread so I am
just going to respond to this.

Thank you for quick reply!



As you noticed, building the full kernel will result in a link error but
it would certainly be nicer if it were a compiler error. Something for
us to improve indeed but I am not sure when we will be able to allocate
resources for that.

I wanted to be sure if we can use compiletime_assert for clang. Then there is room for improvement, but it seems okay.

Until then, you can build a full kernel to get the
failing translation unit then use nm or readelf when building the single
translation unit to see if there are any "__compiletime_assert" symbols.

Okay, then we should find symbol like that until improved.

It may confuse developer, but it seems okay for our code to support clang as it meets minimal condition - build failure.

And I hope it become improved in future!

Thanks,
Hyeonggon

Cheers,
Nathan