BPF List
 help / color / mirror / Atom feed
From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
To: Eduard Zingerman <eddyz87@gmail.com>
Cc: Ihor Solodrai <ihor.solodrai@pm.me>,
	"gcc@gcc.gnu.org" <gcc@gcc.gnu.org>,
	Cupertino Miranda <cupertino.miranda@oracle.com>,
	David Faust <david.faust@oracle.com>,
	Elena Zannoni <elena.zannoni@oracle.com>,
	Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Manu Bretelle <chantra@meta.com>,
	Mykola Lysenko <mykolal@meta.com>,
	Yonghong Song <yonghong.song@linux.dev>,
	bpf <bpf@vger.kernel.org>
Subject: Re: Errors compiling BPF programs from Linux selftests/bpf with GCC
Date: Fri, 03 Jan 2025 11:17:13 +0100	[thread overview]
Message-ID: <87pll4xkuu.fsf@oracle.com> (raw)
In-Reply-To: <4accd577b1486fb8074e7913c3e81d76174ad3d6.camel@gmail.com> (Eduard Zingerman's message of "Thu, 02 Jan 2025 16:46:27 -0800")


> On Fri, 2025-01-03 at 01:16 +0100, Jose E. Marchesi wrote:
>
> [...]
>
>> Yes, in the GCC BPF backend we are using
>> 
>>   use_gcc_stdint=provide
>> 
>> which makes GCC to provide the version of stdint.h that assumes
>> freestanding ("baremetal") mode.  If we changed it to use
>> 
>>   use_gcc_stdint=wrap
>> 
>> then it would install a stdint.h that does somethins similar to what
>> clang does, at least in hosts providing C99 headers (note the lack of
>> __has_include_next):
>> 
>>   #ifndef _GCC_WRAP_STDINT_H
>>   #if __STDC_HOSTED__
>>   # if defined __cplusplus && __cplusplus >= 201103L
>>   #  undef __STDC_LIMIT_MACROS
>>   #  define __STDC_LIMIT_MACROS
>>   #  undef __STDC_CONSTANT_MACROS
>>   #  define __STDC_CONSTANT_MACROS
>>   # endif
>>   #pragma GCC diagnostic push
>>   #pragma GCC diagnostic ignored "-Wpedantic" // include_next
>>   # include_next <stdint.h>
>>   #pragma GCC diagnostic pop
>>   #else
>>   # include "stdint-gcc.h"
>>   #endif
>>   #define _GCC_WRAP_STDINT_H
>>   #endif
>> 
>> We could switch to "wrap" to align with clang, but in that case it would
>> be up to the user to provide a "host" stdint.h that contains sensible
>> definitions for BPF.  The kernel selftests, for example, would need to
>> do so to avoid including /usr/include/stdint.h that more likely than not
>> will provide incorrect definitions for int64_t and friends...
>
> Would it be possible to push a branch that uses '=wrap' thing
> somewhere?  So that it could be further tested to see if there are
> more issues with selftests.

No need.  After reflecting a bit I can't see why the requirements on the
"host" stdint.h must be different for BPF than for any other target: its
contents must match the expectations of the compiler for the arch.  If
it doesn't... well, it is not the responsibility of the compiler to
assure that.  I will install a patch to switch to the wrapper stdint.h.

  reply	other threads:[~2025-01-03 10:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-30 20:08 Errors compiling BPF programs from Linux selftests/bpf with GCC Ihor Solodrai
2024-12-30 20:24 ` Andrew Pinski
2024-12-30 20:36   ` Sam James
2024-12-30 20:59     ` Ihor Solodrai
2024-12-30 21:08       ` Sam James
2024-12-31  0:42       ` Alexei Starovoitov
2024-12-31  1:26         ` Ihor Solodrai
2024-12-31  4:09           ` Alexei Starovoitov
2025-01-02  9:47 ` Jose E. Marchesi
2025-01-02 17:35   ` Ihor Solodrai
2025-01-02 18:24     ` Jose E. Marchesi
2025-01-03  0:42       ` Eduard Zingerman
2025-01-03 13:23         ` Jose E. Marchesi
2025-01-02 23:04   ` Eduard Zingerman
2025-01-03  0:16     ` Jose E. Marchesi
2025-01-03  0:46       ` Eduard Zingerman
2025-01-03 10:17         ` Jose E. Marchesi [this message]
2025-01-03 12:52           ` Jose E. Marchesi
2025-01-03 23:48 ` Ihor Solodrai
2025-01-03 23:56   ` Andrew Pinski
2025-01-04  8:05   ` Jose E. Marchesi

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=87pll4xkuu.fsf@oracle.com \
    --to=jose.marchesi@oracle.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=chantra@meta.com \
    --cc=cupertino.miranda@oracle.com \
    --cc=david.faust@oracle.com \
    --cc=eddyz87@gmail.com \
    --cc=elena.zannoni@oracle.com \
    --cc=gcc@gcc.gnu.org \
    --cc=ihor.solodrai@pm.me \
    --cc=mykolal@meta.com \
    --cc=yonghong.song@linux.dev \
    /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