Thread: Meson and Numa: C header not found

Meson and Numa: C header not found

From
"Daniel Westermann (DWE)"
Date:
Hi,

I wanted to play a bit with the Numa stuff recently committed but Meson fails to find numa.h:

Found pkg-config: YES (/usr/bin/pkg-config) 2.3.0
Run-time dependency numa found: YES 2.0.19

../postgresql/meson.build:957:12: ERROR: C header 'numa.h' not found

Is this expected? The header file is there:

postgres@pgbox:/home/postgres/ [DEV] sudo find / -name numa.h
/usr/include/numa.h

This is a Fedora 41 system.

Regards
Daniel


Re: Meson and Numa: C header not found

From
Tomas Vondra
Date:
On 4/10/25 08:00, Daniel Westermann (DWE) wrote:
> Hi,
> 
> I wanted to play a bit with the Numa stuff recently committed but Meson fails to find numa.h:
> 
> Found pkg-config: YES (/usr/bin/pkg-config) 2.3.0
> Run-time dependency numa found: YES 2.0.19
> 
> ../postgresql/meson.build:957:12: ERROR: C header 'numa.h' not found
> 
> Is this expected? The header file is there:
> 
> postgres@pgbox:/home/postgres/ [DEV] sudo find / -name numa.h
> /usr/include/numa.h
> 
> This is a Fedora 41 system.
> 

That's weird. I'm on Fedora 41 too, and I don't have this issue. If I do

    $ meson setup build

I get

    libnuma : YES 2.0.19

and then

    ninja -C build

completes just fine. What exactly are the commands you're executing?


FWIW I guess -hackers would be a better place for this question.


regards

-- 
Tomas Vondra




Re: Meson and Numa: C header not found

From
"Daniel Westermann (DWE)"
Date:
>
>   ninja -C build
>
>completes just fine. What exactly are the commands you're executing?
>
>
>FWIW I guess -hackers would be a better place for this question.

Nothing special, just this:

meson configure -Dprefix=${PGHOME} \
                -Dbindir=${PGHOME}/bin \
                -Ddatadir=${PGHOME}/share \
                -Dincludedir=${PGHOME}/include \
                -Dlibdir=${PGHOME}/lib \
                -Dsysconfdir=${PGHOME}/etc \
                -Dpgport=5432 \
                -Dplperl=enabled \
                -Dplpython=enabled \
                -Dssl=openssl \
                -Dpam=enabled \
                -Dldap=enabled \
                -Dlibxml=enabled \
                -Dlibxslt=enabled \
                -Dsegsize=${SEGSIZE} \
                -Dblocksize=${BLOCKSIZE} \
                -Dllvm=enabled \
                -Duuid=ossp \
                -Dzstd=enabled \
                -Dlz4=enabled \
                -Dzstd=enabled \
                -Dgssapi=enabled \
                -Dsystemd=enabled \
                -Dicu=enabled \
                -Dlibcurl=enabled \
                -Dliburing=enabled \
                -Dlibnuma=disabled \
                -Dsystem_tzdata=/usr/share/zoneinfo
ninja
ninja install

Regards
Daniel




Re: Meson and Numa: C header not found

From
Tomas Vondra
Date:

On 4/10/25 11:53, Daniel Westermann (DWE) wrote:
>>
>>    ninja -C build
>>
>> completes just fine. What exactly are the commands you're executing?
>>
>>
>> FWIW I guess -hackers would be a better place for this question.
> 
> Nothing special, just this:
> 
> meson configure -Dprefix=${PGHOME} \
>                 -Dbindir=${PGHOME}/bin \
>                 -Ddatadir=${PGHOME}/share \
>                 -Dincludedir=${PGHOME}/include \
>                 -Dlibdir=${PGHOME}/lib \
>                 -Dsysconfdir=${PGHOME}/etc \
>                 -Dpgport=5432 \
>                 -Dplperl=enabled \
>                 -Dplpython=enabled \
>                 -Dssl=openssl \
>                 -Dpam=enabled \
>                 -Dldap=enabled \
>                 -Dlibxml=enabled \
>                 -Dlibxslt=enabled \
>                 -Dsegsize=${SEGSIZE} \
>                 -Dblocksize=${BLOCKSIZE} \
>                 -Dllvm=enabled \
>                 -Duuid=ossp \
>                 -Dzstd=enabled \
>                 -Dlz4=enabled \
>                 -Dzstd=enabled \
>                 -Dgssapi=enabled \
>                 -Dsystemd=enabled \
>                 -Dicu=enabled \
>                 -Dlibcurl=enabled \
>                 -Dliburing=enabled \
>                 -Dlibnuma=disabled \
>                 -Dsystem_tzdata=/usr/share/zoneinfo
> ninja 
> ninja install
> 

Are you sure this is the sequence that fails? Because this has

 -Dlibnuma=disabled

so that shouldn't build the NUMA stuff at all.

regards

-- 
Tomas Vondra




Re: Meson and Numa: C header not found

From
Tom Lane
Date:
Tomas Vondra <tomas@vondra.me> writes:
> On 4/10/25 08:00, Daniel Westermann (DWE) wrote:
>> I wanted to play a bit with the Numa stuff recently committed but Meson fails to find numa.h:
>> Found pkg-config: YES (/usr/bin/pkg-config) 2.3.0
>> Run-time dependency numa found: YES 2.0.19
>>
>> ../postgresql/meson.build:957:12: ERROR: C header 'numa.h' not found

> That's weird. I'm on Fedora 41 too, and I don't have this issue. If I do

I couldn't reproduce it on F41 either.  Note that you need to
have numactl-devel installed else /usr/include/numa.h isn't
there; but meson seems to fail as-expected without that,
or silently fall back to libnuma=disabled if you don't try to
force it.

            regards, tom lane



Re: Meson and Numa: C header not found

From
"Daniel Westermann (DWE)"
Date:
>Tomas Vondra <tomas@vondra.me> writes:
>> On 4/10/25 08:00, Daniel Westermann (DWE) wrote:
>>> I wanted to play a bit with the Numa stuff recently committed but Meson fails to find numa.h:
>>> Found pkg-config: YES (/usr/bin/pkg-config) 2.3.0
>>> Run-time dependency numa found: YES 2.0.19
>>>
>>> ../postgresql/meson.build:957:12: ERROR: C header 'numa.h' not found

>> That's weird. I'm on Fedora 41 too, and I don't have this issue. If I do

>I couldn't reproduce it on F41 either.  Note that you need to
>have numactl-devel installed else /usr/include/numa.h isn't
>there; but meson seems to fail as-expected without that,
>or silently fall back to libnuma=disabled if you don't try to
force it.
>
  
It is there:

postgres@pgbox:/home/postgres/ [DEV] ls /usr/include/numa.h
/usr/include/numa.h

Regards
Daniel



Re: Meson and Numa: C header not found

From
Tom Lane
Date:
"Daniel Westermann (DWE)" <daniel.westermann@dbi-services.com> writes:
> Tomas Vondra <tomas@vondra.me> writes:
>> On 4/10/25 08:00, Daniel Westermann (DWE) wrote:
>>> ../postgresql/meson.build:957:12: ERROR: C header 'numa.h' not found

> It is there:

> postgres@pgbox:/home/postgres/ [DEV] ls /usr/include/numa.h
> /usr/include/numa.h

Just to confirm, do you have all of these in /usr/lib64?

$ ls -l /usr/lib64/libnuma*
lrwxrwxrwx. 1 root root    16 Nov  4 19:00 /usr/lib64/libnuma.so -> libnuma.so.1.0.0
lrwxrwxrwx. 1 root root    16 Nov  4 19:00 /usr/lib64/libnuma.so.1 -> libnuma.so.1.0.0
-rwxr-xr-x. 1 root root 62424 Nov  4 19:00 /usr/lib64/libnuma.so.1.0.0

As of HEAD, line 957 of meson.build is

  if not cc.has_header('numa.h', dependencies: libnuma, required: libnumaopt)

I'm not familiar at all with meson, but I wonder exactly what the
dependencies: bit does.  That kind of looks like it might cause the
check to fail if the libnuma library isn't there, which is something
we do need to check, but doing it this way seems like it'd produce
a pretty misleading failure message if numa.h exists but the library
doesn't.

            regards, tom lane



Re: Meson and Numa: C header not found

From
"Daniel Westermann (DWE)"
Date:
>Just to confirm, do you have all of these in /usr/lib64?

>$ ls -l /usr/lib64/libnuma*
>lrwxrwxrwx. 1 root root    16 Nov  4 19:00 /usr/lib64/libnuma.so -> libnuma.so.1.0.0
>lrwxrwxrwx. 1 root root    16 Nov  4 19:00 /usr/lib64/libnuma.so.1 -> libnuma.so.1.0.0
>-rwxr-xr-x. 1 root root 62424 Nov  4 19:00 /usr/lib64/libnuma.so.1.0.0

>As of HEAD, line 957 of meson.build is

>  if not cc.has_header('numa.h', dependencies: libnuma, required: libnumaopt)

postgres@pgbox:/home/postgres/ [DEV] ls -l /usr/lib64/libnuma*
lrwxrwxrwx. 1 root root    16 Nov  5 01:00 /usr/lib64/libnuma.so -> libnuma.so.1.0.0
lrwxrwxrwx. 1 root root    16 Nov  5 01:00 /usr/lib64/libnuma.so.1 -> libnuma.so.1.0.0
-rwxr-xr-x. 1 root root 62424 Nov  5 01:00 /usr/lib64/libnuma.so.1.0.0
18:25:38 postgres@pgbox:/home/postgres/ [DEV] 

Yes, it it there

Regards
Daniel

Re: Meson and Numa: C header not found

From
Tom Lane
Date:
"Daniel Westermann (DWE)" <daniel.westermann@dbi-services.com> writes:
>> Just to confirm, do you have all of these in /usr/lib64?

> Yes, it it there

That's just weird then.  The only other theory that comes to mind
is that there's something wrong with the SELinux attributes on these
files.  restorecon might help if so.

            regards, tom lane



Re: Meson and Numa: C header not found

From
"Daniel Westermann (DWE)"
Date:
>That's just weird then.  The only other theory that comes to mind
>is that there's something wrong with the SELinux attributes on these
>fles.  restorecon might help if so.

If that would be the case, then it is a packaging issue on Fedora, I guess.

Even after restorecon I get this:

Found pkg-config: YES (/usr/bin/pkg-config) 2.3.0
Run-time dependency numa found: YES 2.0.19

../postgresql/meson.build:957:12: ERROR: C header 'numa.h' not found

... which gives this in the log:

Run-time dependency numa found: YES 2.0.19
Using cached compile:
Cached command line:  cc /home/postgres/build/meson-private/tmpjon5_bg2/testfile.c -E -P -D_FILE_OFFSET_BITS=64 -P -O0

Code:

        #ifdef __has_include
         #if !__has_include("numa.h")
          #error "Header 'numa.h' could not be found"
         #endif
        #else
         #include <numa.h>
        #endif
Cached compiler stdout:

Cached compiler stderr:
 /home/postgres/build/meson-private/tmpjon5_bg2/testfile.c:4:12: error: #error "Header 'numa.h' could not be found"
    4 |           #error "Header 'numa.h' could not be found"
      |            ^~~~~


../postgresql/meson.build:957:12: ERROR: C header 'numa.h' not found


Regards
Daniel


Re: Meson and Numa: C header not found

From
Tom Lane
Date:
"Daniel Westermann (DWE)" <daniel.westermann@dbi-services.com> writes:
> Even after restorecon I get this:

> Found pkg-config: YES (/usr/bin/pkg-config) 2.3.0
> Run-time dependency numa found: YES 2.0.19

> ../postgresql/meson.build:957:12: ERROR: C header 'numa.h' not found

> ... which gives this in the log:

> Run-time dependency numa found: YES 2.0.19
> Using cached compile:
> Cached command line:  cc /home/postgres/build/meson-private/tmpjon5_bg2/testfile.c -E -P -D_FILE_OFFSET_BITS=64 -P
-O0 

Ah-hah: the "cached" bit gave me the clue I needed.  I think
you ran "meson setup" without numactl-devel installed, and it
cached the fact that numa.h wasn't there.  I can reproduce
this error with

$ sudo dnf remove numactl-devel
$ git clean -dfxq
$ meson setup build
$ sudo dnf install numactl-devel
$ meson setup build --reconfigure

... which ends with

Run-time dependency numa found: YES 2.0.19

meson.build:957:12: ERROR: C header 'numa.h' not found

It's okay again after blowing away the build subdirectory
(e.g. via "git clean -dfxq") and trying again.

This implies that it caches info about header presence but
not library presence (else it wouldn't have thought that
the library was there either, I guess).  Kind of weird,
but I'm still learning about meson.

            regards, tom lane



Re: Meson and Numa: C header not found

From
"Daniel Westermann (DWE)"
Date:
>This implies that it caches info about header presence but
>not library presence (else it wouldn't have thought that
>the library was there either, I guess).  Kind of weird,
>but I'm still learning about meson.

Thanks, Tom, Confirmed, starting from scratch does not show the issue anymore.

Regards
Daniel