public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Jean-Philippe Brucker <jean-philippe@linaro.org>, ast@kernel.org
Cc: songliubraving@fb.com, Jakov Petrina <jakov.petrina@sartura.hr>,
	john.fastabend@gmail.com, kpsingh@chromium.org, yhs@fb.com,
	bpf@vger.kernel.org, andriin@fb.com, kafai@fb.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH bpf] libbpf: Handle GCC built-in types for Arm NEON
Date: Tue, 11 Aug 2020 16:10:31 +0200	[thread overview]
Message-ID: <65afcc0c-5468-1654-83d6-dade2c848745@iogearbox.net> (raw)
In-Reply-To: <20200810122835.2309026-1-jean-philippe@linaro.org>

On 8/10/20 2:28 PM, Jean-Philippe Brucker wrote:
> When building Arm NEON (SIMD) code, GCC emits built-in types __PolyXX_t,
> which are not recognized by Clang. This causes build failures when
> including vmlinux.h generated from a kernel built with CONFIG_RAID6_PQ=y
> and CONFIG_KERNEL_MODE_NEON. Emit typedefs for these built-in types,
> based on the Clang definitions. poly64_t is unsigned long because it's
> only defined for 64-bit Arm.
> 
> Including linux/kernel.h to use ARRAY_SIZE() incidentally redefined
> max(), causing a build bug due to different types, hence the seemingly
> unrelated change.
> 
> Reported-by: Jakov Petrina <jakov.petrina@sartura.hr>
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

Looks like this was fixed here [0], but not available on older clang/LLVM
versions, right?

   [0] https://reviews.llvm.org/D79711

[...]
>   
> +static const char *builtin_types[][2] = {
> +	/*
> +	 * GCC emits typedefs to its internal __PolyXX_t types when compiling
> +	 * Arm SIMD intrinsics. Alias them to the same standard types as Clang.
> +	 */
> +	{ "__Poly8_t",		"unsigned char" },
> +	{ "__Poly16_t",		"unsigned short" },
> +	{ "__Poly64_t",		"unsigned long" },
> +	{ "__Poly128_t",	"unsigned __int128" },

In that above LLVM link [0], they typefdef this to signed types ... which one
is correct now?

   // For now, signedness of polynomial types depends on target
   OS << "#ifdef __aarch64__\n";
   OS << "typedef uint8_t poly8_t;\n";
   OS << "typedef uint16_t poly16_t;\n";
   OS << "typedef uint64_t poly64_t;\n";
   OS << "typedef __uint128_t poly128_t;\n";
   OS << "#else\n";
   OS << "typedef int8_t poly8_t;\n";
   OS << "typedef int16_t poly16_t;\n";
   OS << "typedef int64_t poly64_t;\n";
   OS << "#endif\n";

> +};
> +
> +static void btf_dump_emit_int_def(struct btf_dump *d, __u32 id,
> +				  const struct btf_type *t)
> +{
> +	const char *name = btf_dump_type_name(d, id);
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(builtin_types); i++) {
> +		if (strcmp(name, builtin_types[i][0]) == 0) {
> +			btf_dump_printf(d, "typedef %s %s;\n\n",
> +					builtin_types[i][1], name);
> +			break;
> +		}
> +	}
> +}
> +
>   static void btf_dump_emit_enum_fwd(struct btf_dump *d, __u32 id,
>   				   const struct btf_type *t)
>   {
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-08-11 14:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-10 12:28 [PATCH bpf] libbpf: Handle GCC built-in types for Arm NEON Jean-Philippe Brucker
2020-08-11 14:10 ` Daniel Borkmann [this message]
2020-08-11 15:04   ` Jean-Philippe Brucker
2020-08-12  3:30 ` Andrii Nakryiko
2020-08-12 14:37   ` Jean-Philippe Brucker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=65afcc0c-5468-1654-83d6-dade2c848745@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=jakov.petrina@sartura.hr \
    --cc=jean-philippe@linaro.org \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox