Skip to content

Commit 24ef127

Browse files
committed
meson: mingw: Add -Wl,--disable-auto-import, enable when linking with readline
I hadn't ported -Wl,--disable-auto-import over from the win32 template as I had focused on msvc for windows. The flag is desirable as it makes it easier to find problems one would have with msvc, particularly useful during cross compilation. This turned out to be a somewhat happy accident, as it allowed me to realize that readline actually works on windows these days, as long as auto imports to enable. Therefore enable auto-import again as part of linking to readline. We perhaps can come up with a better solution for the readline issue, but this seems good enough for now. Discussion: http://postgr.es/m/[email protected]
1 parent 2dc2e4e commit 24ef127

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

meson.build

+9
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ elif host_system == 'windows'
279279
ldflags += '-Wl,--stack,@0@'.format(cdata.get('WIN32_STACK_RLIMIT'))
280280
# Need to allow multiple definitions, we e.g. want to override getopt.
281281
ldflags += '-Wl,--allow-multiple-definition'
282+
# Ensure we get MSVC-like linking behavior.
283+
ldflags += '-Wl,--disable-auto-import'
282284
endif
283285

284286
os_deps += cc.find_library('ws2_32', required: true)
@@ -1080,6 +1082,13 @@ Use -Dreadline=false to disable readline support.'''.format(readline_dep))
10801082
readline = declare_dependency(dependencies: readline,
10811083
include_directories: postgres_inc)
10821084
endif
1085+
1086+
# On windows with mingw readline requires auto-import to successfully
1087+
# link, as the headers don't use declspec(dllimport)
1088+
if host_system == 'windows' and cc.get_id() != 'msvc'
1089+
readline = declare_dependency(dependencies: readline,
1090+
link_args: '-Wl,--enable-auto-import')
1091+
endif
10831092
endif
10841093

10851094
# XXX: Figure out whether to implement mingw warning equivalent

0 commit comments

Comments
 (0)