Re: [RFC PATCH 3/3] tools/nolibc: add a new "install_all_archs" target
From: Willy Tarreau
Date: Fri Jun 27 2025 - 02:07:37 EST
On Fri, Jun 27, 2025 at 07:58:58AM +0200, Arnd Bergmann wrote:
> On Fri, Jun 27, 2025, at 05:25, Willy Tarreau wrote:
> > On Thu, Jun 26, 2025 at 11:15:07PM +0200, Arnd Bergmann wrote:
> >> On Thu, Jun 26, 2025, at 22:18, Thomas Weißschuh wrote:
>
> >> If it's indeed possible to concatenate the path name (I couldn't
> >> figure that out either), that could also be done in place of the
> >> symlink but simpler than the #if/#elif/#elif/... block, like
> >>
> >> #include <arch.h> // defines ARCH_PREFIX
> >> #include CONCAT(ARCH_PREFIX, ioctl.h)
> >
> > I have never found how it would be possible to do that, let alone in a
> > more or less portable way, because #include doesn't take a C-string in
> > argument but a special syntax which is specific to it ("x" or <x>). It
> > doesn't support concatenating strings for example:
> >
> > #include "stdio"".h"
> >
> > $ gcc -E inc.h
> > inc.h:1:17: warning: extra tokens at end of #include directive
> > 1 | #include "stdio"".h"
> > | ^~~~
> > inc.h:1:10: fatal error: stdio: No such file or directory
> > 1 | #include "stdio"".h"
> > | ^~~~~~~
>
> This variant does seem to work with gcc and clang:
>
> #define ARCH i386
> #define __ARCH_HEADER(a, b) <a ## _ ## b>
> #define _ARCH_HEADER(a, b) __ARCH_HEADER(a, b)
> #include _ARCH_HEADER(ARCH, stdio.h)
>
> Or even simpler
>
> #define _NOLIBC_ARCH_HEADER(file) <i386_ ## file>
>
> The ## concatenation is a bit limited here since cpp requires
> both sides to expand to an identifier, meaning you can have
> a '_' next to it, but not a '/' or '-'.
Thanks Arnd, will give it a try this week-end.
Willy