Subject: Fix meson uuid header check so it works with MSVC in REL_16_STABLE

From: Marina Polyakova <[email-masked]>
Date: Tue, 26 Nov 2024 09:24:05 +0300

Hello! Could you backport the commit "Fix meson uuid header check so it 
works with MSVC" [1] to REL_16_STABLE please? Building with -Duuid=ossp 
fails without it:

Running compile:
Working directory:  
C:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\builddir\meson-private\tmpx088n_nb
Code:

         #include <uuid.h>
         int main(void) {
             /* If it's not defined as a macro, try to use as a symbol */
             #ifndef uuid_export
                 uuid_export;
             #endif
             return 0;
         }
-----------
Command line: `cl 
C:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\builddir\meson-private\tmpx088n_nb\testfile.c 
/FoC:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\builddir\meson-private\tmpx088n_nb\output.obj 
/nologo /showIncludes /utf-8 /c /nologo /showIncludes /utf-8 /c /Od 
/Oi-` -> 2
stdout:
testfile.c
C:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\builddir\meson-private\tmpx088n_nb\testfile.c(2): 
fatal error C1083: Cannot open include file: 'uuid.h': No such file or 
directory
-----------
Header "uuid.h" has symbol "uuid_export" with dependency -luuid: NO

meson.build:1467:4: ERROR: Problem encountered: uuid library ossp 
missing required function uuid_export

With this fix my build and tests with Meson were successful:

Running compile:
Working directory:  
C:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\builddir\meson-private\tmpam6tbfwl
Code:

         #include <uuid.h>
         int main(void) {
             /* If it's not defined as a macro, try to use as a symbol */
             #ifndef uuid_export
                 uuid_export;
             #endif
             return 0;
         }
-----------
Command line: `cl 
-IC:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\src/include 
-IC:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\builddir\src/include 
-IC:\gr-builds\6n4KsTYAF\0\pgpro-dev\deps\include 
-IC:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\src/include/port/win32 
-IC:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\builddir\src/include/port/win32 
-IC:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\src/include/port/win32_msvc 
-IC:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\builddir\src/include/port/win32_msvc 
C:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\builddir\meson-private\tmpam6tbfwl\testfile.c 
/FoC:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\builddir\meson-private\tmpam6tbfwl\output.obj 
/nologo /showIncludes /utf-8 /c /nologo /showIncludes /utf-8 /c /Od 
/Oi-` -> 0
stdout:
testfile.c
Note: including file: 
C:\gr-builds\6n4KsTYAF\0\pgpro-dev\deps\include\uuid.h
Note: including file:  C:\Program Files (x86)\Windows 
Kits\10\include\10.0.22621.0\ucrt\sys/types.h
Note: including file:   C:\Program Files (x86)\Windows 
Kits\10\include\10.0.22621.0\ucrt\corecrt.h
Note: including file:    C:\Program Files\Microsoft Visual 
Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\vcruntime.h
Note: including file:     C:\Program Files\Microsoft Visual 
Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\sal.h
Note: including file:      C:\Program Files\Microsoft Visual 
Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\concurrencysal.h
Note: including file:     C:\Program Files\Microsoft Visual 
Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\vadefs.h
Note: including file:  C:\Program Files (x86)\Windows 
Kits\10\include\10.0.22621.0\ucrt\string.h
Note: including file:   C:\Program Files (x86)\Windows 
Kits\10\include\10.0.22621.0\ucrt\corecrt_memory.h
Note: including file:    C:\Program Files (x86)\Windows 
Kits\10\include\10.0.22621.0\ucrt\corecrt_memcpy_s.h
Note: including file:     C:\Program Files (x86)\Windows 
Kits\10\include\10.0.22621.0\ucrt\errno.h
Note: including file:     C:\Program Files\Microsoft Visual 
Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\vcruntime_string.h
Note: including file:   C:\Program Files (x86)\Windows 
Kits\10\include\10.0.22621.0\ucrt\corecrt_wstring.h
C:\gr-builds\6n4KsTYAF\0\pgpro-dev\postgrespro\builddir\meson-private\tmpam6tbfwl\testfile.c(6): 
warning C4550: expression evaluates to a function which is missing an 
argument list
-----------
Header "uuid.h" has symbol "uuid_export" with dependency -luuid: YES

[1] 
https://github.com/postgres/postgres/commit/7c655a04a2dc84b59ed6dce97bd38b79e734ecca

-- 
Marina Polyakova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

---

From: Andrew Dunstan <[email-masked]>
Date: Tue, 26 Nov 2024 15:46:43 -0500

On 2024-11-26 Tu 1:24 AM, Marina Polyakova wrote:
> Hello! Could you backport the commit "Fix meson uuid header check so 
> it works with MSVC" [1] to REL_16_STABLE please? Building with 
> -Duuid=ossp fails without it:

yep, done.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com