diff --git a/meson.build b/meson.build index 0cd09ba430..c32cd792db 100644 --- a/meson.build +++ b/meson.build @@ -279,6 +279,8 @@ elif host_system == 'windows' ldflags += '-Wl,--stack,@0@'.format(cdata.get('WIN32_STACK_RLIMIT')) # Need to allow multiple definitions, we e.g. want to override getopt. ldflags += '-Wl,--allow-multiple-definition' + # Ensure we get MSVC-like linking behavior. + ldflags += '-Wl,--disable-auto-import' endif os_deps += cc.find_library('ws2_32', required: true) @@ -1080,6 +1082,13 @@ Use -Dreadline=false to disable readline support.'''.format(readline_dep)) readline = declare_dependency(dependencies: readline, include_directories: postgres_inc) endif + + # On windows with mingw readline requires auto-import to successfully + # link, as the headers don't use declspec(dllimport) + if host_system == 'windows' and cc.get_id() != 'msvc' + readline = declare_dependency(dependencies: readline, + link_args: '-Wl,--enable-auto-import') + endif endif # XXX: Figure out whether to implement mingw warning equivalent