Subject: Re: win32ver data in meson-built postgres.exe

From: Andres Freund <[email-masked]>
Date: Wed, 7 Jun 2023 16:47:26 -0700

Hi,

On 2023-06-07 16:14:07 -0700, Noah Misch wrote:
> A postgres.exe built with meson, ninja, and MSVC lacks the version metadata
> that postgres.exe gets under non-meson build systems.  Patch attached.

I dimly recall that we discussed that and basically decided that it doesn't
really make sense to attach this information to postgres.exe.

>     This preserves two quirks of the older build systems.  First,
>     postgres.exe is icon-free.

We could also just change that.

>     Second, the resources object is not an input
>     to postgres.def.

I don't see what negative effects that could have: postgres.def is used to
provide symbol "thunks" to extension libraries, which don't need to access
this information.  If we used the rc compiler to inject binary data (say
bootstrap.bki) into binaries, it'd possibly be a different story (although I
think it might work anyway) - but if we wanted to do something like that, we'd
build portable infrastructure anyway.

> -  rcgen_bin_args = rcgen_base_args + [
> +  rcgen_server_args = rcgen_base_args + [
>      '--VFT_TYPE', 'VFT_APP',
> -    '--FILEENDING', 'exe',
> +    '--FILEENDING', 'exe'
> +  ]
> +
> +  rcgen_bin_args = rcgen_server_args + [
>      '--ICO', pg_ico
>    ]

Somehow it seems a bit wrong to derive non-server from server, but ... ;)

Greetings,

Andres Freund

---

From: Noah Misch <[email-masked]>
Date: Wed, 7 Jun 2023 18:45:07 -0700

> really make sense to attach this information to postgres.exe.

I looked for a discussion behind that, but I didn't find it.  A key
user-visible consequence is whether the task manager "Name" column shows (1)
"PostgreSQL Server" (version data present) vs. (2) "postgres.exe" (no version
data).  While (2) is not terrible, (1) is more typical on Windows.  I don't
see cause to migrate to (2) after N years of sending (1).  Certainly this part
of the user experience should not depend on one's choice of build system.

> We could also just change that.

I would be +1 for that (only if done for all build systems).  Showing the
elephant in task manager feels better than showing the generic-exe icon.

> I don't see what negative effects that could have:

Agreed.  I wrote that sentence for archaeologists of the future who might
wonder why this change didn't use generated_backend_sources.

---

From: Magnus Hagander <[email-masked]>
Date: Thu, 8 Jun 2023 13:10:00 +0200

> of the user experience should not depend on one's choice of build system.

+1, both on that it should be the same across build systems, and that
the variant that we have in the msvc build system is the best one.

And if we don't have the version structure in it, it will cause issues
for installers (I think) and software inventory processes (definitely)
that also use that.

I don't recall a discussion about removing it, but it's not unlikely I
missed it if it did take place...

> elephant in task manager feels better than showing the generic-exe icon.

I think this decision goes back all the way to the ancient times, and
the argument was then "user should not use the postgres.exe file when
clicking around" sort of. Back then, task manager didn't show the icon
at all, regardless. It does now, so I'm +1 to add the icon (in all the
build systems).

-- 
 Magnus Hagander
 Me: https://www.hagander.net/
 Work: https://www.redpill-linpro.com/

---

From: Andres Freund <[email-masked]>
Date: Fri, 9 Jun 2023 10:45:27 -0700

Hi,

> of the user experience should not depend on one's choice of build system.

I think I misremembered some details... I guess I was remembering the icon for
dlls, in
https://postgr.es/m/20220829221314.pepagj3i5mj43niy%40awork3.anarazel.de

Touching the rc stuff always makes me feel dirty enough that I want to swap it
out of my brain, if not run some deep erase tool :)

> elephant in task manager feels better than showing the generic-exe icon.

Let's do that then.

Greetings,

Andres Freund

---

From: Noah Misch <[email-masked]>
Date: Fri, 9 Jun 2023 13:14:55 -0700

> at all, regardless. It does now, so I'm +1 to add the icon (in all the

That sounds good, and it's the attached one-byte change.  That also simplifies
the Meson fix; new version attached.
Author:     Noah Misch <[email-masked]>
Commit:     Noah Misch <[email-masked]>

    Give postgres.exe the icon of other executables.
    
    We had left it icon-free since users won't achieve much by opening it
    from Windows Explorer.  Subsequent to that decision, Task Manager
    started to show the icon.  That shifts the balance in favor of attaching
    the icon, so do so.  No back-patch, but make this late addition to v16.
    
    Reviewed by FIXME.
    
    Discussion: https://postgr.es/m/FIXME

diff --git a/src/backend/Makefile b/src/backend/Makefile
index e4bf0fe..3c42003 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -10,8 +10,7 @@
 #-------------------------------------------------------------------------
 
 PGFILEDESC = "PostgreSQL Server"
-# This is a daemon process, which is why it is not labeled as an executable
-#PGAPPICON=win32
+PGAPPICON=win32
 
 subdir = src/backend
 top_builddir = ../..
Author:     Noah Misch <[email-masked]>
Commit:     Noah Misch <[email-masked]>

    Add win32ver data to meson-built postgres.exe.
    
    As in the older build systems, the resources object is not an input to
    postgres.def.
    
    Reviewed by FIXME.
    
    Discussion: https://postgr.es/m/FIXME

diff --git a/src/backend/meson.build b/src/backend/meson.build
index ccfc382..88a35e9 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -5,6 +5,7 @@ backend_sources = []
 backend_link_with = [pgport_srv, common_srv]
 
 generated_backend_sources = []
+post_export_backend_sources = []
 
 subdir('access')
 subdir('archive')
@@ -133,8 +134,15 @@ if dtrace.found() and host_system != 'darwin'
   )
 endif
 
+if host_system == 'windows'
+  post_export_backend_sources += rc_bin_gen.process(win32ver_rc, extra_args: [
+    '--NAME', 'postgres',
+    '--FILEDESC', 'PostgreSQL Server',])
+endif
+
 postgres = executable('postgres',
   backend_input,
+  sources: post_export_backend_sources,
   objects: backend_objs,
   link_args: backend_link_args,
   link_with: backend_link_with,