[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191219170602.4xkljpjowi4i2e3q@ast-mbp.dhcp.thefacebook.com>
Date: Thu, 19 Dec 2019 09:06:04 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Andrii Nakryiko <andriin@...com>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org, ast@...com,
daniel@...earbox.net, andrii.nakryiko@...il.com, kernel-team@...com
Subject: Re: [PATCH bpf-next 1/3] bpftool: add extra CO-RE mode to btf dump
command
On Wed, Dec 18, 2019 at 11:06:56PM -0800, Andrii Nakryiko wrote:
> + if (core_mode) {
> + printf("#if defined(__has_attribute) && __has_attribute(preserve_access_index)\n");
> + printf("#define __CLANG_BPF_CORE_SUPPORTED\n");
> + printf("#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record)\n");
> + printf("#endif\n\n");
I think it's dangerous to automatically opt-out when clang is not new enough.
bpf prog will compile fine, but it will be missing co-re relocations.
How about doing something like:
printf("#ifdef NEEDS_CO_RE\n");
printf("#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record)\n");
printf("#endif\n\n");
and emit it always when 'format c'.
Then on the program side it will look:
#define NEEDS_CO_RE
#include "vmlinux.h"
If clang is too old there will be a compile time error which is a good thing.
Future features will have different NEEDS_ macros.
Powered by blists - more mailing lists