Обсуждение: BUG #17681: Building the REL_12_13 source in Visual Studio 2013 fails.
BUG #17681: Building the REL_12_13 source in Visual Studio 2013 fails.
От
PG Bug reporting form
Дата:
The following bug has been logged on the website: Bug reference: 17681 Logged by: daisuke higuchi Email address: higuchi.daisuke@fujitsu.com PostgreSQL version: Unsupported/Unknown Operating system: Windows 10 Description: Hi, I tried to build using the codes of REL_12_13 in the following environment, but it failed. In the same environment, building with code with REL_12_12 succeeds. - Windows 10 - Visual Studio 2013 I know I'm using an older version of Visual Studio, but according to the manual, I believe it supports building with Visual Studio 2013, so I think this is bug. https://www.postgresql.org/docs/12/install-windows-full.html ----------------------------------- 17.1. Building with Visual C++ or the Microsoft Windows SDK 64-bit PostgreSQL builds are supported with Microsoft Windows SDK version 8.1a to 10 or Visual Studio 2013 and above. ----------------------------------- The main messages when it fails are following: ----------------------------------- "Z:\postgres\pgsql.sln" (default target) (1) -> "Z:\postgres\postgres.vcxproj" (default target) (2) -> (ClCompile target) -> src/port/snprintf.c(1006): warning C4013: 'snprintf' undefined; assuming extern returning int [Z:\postgres\postgres.vcxproj] "Z:\postgres\pgsql.sln" (default target) (1) -> "Z:\postgres\libpqwalreceiver.vcxproj" (default target) (4) -> "Z:\postgres\libpq.vcxproj" (default target) (5) -> "Z:\postgres\libpgport.vcxproj" (default target) (7) -> src/port/snprintf.c(1006): warning C4013: 'snprintf' undefined; assuming extern returning int [Z:\postgres\libpgport.vcxproj] "Z:\postgres\pgsql.sln" (default target) (1) -> "Z:\postgres\postgres.vcxproj" (default target) (2) -> (Link target) -> snprintf.obj : error LNK2019: unresolved external symbol snprintf referenced in function pg_strfromd [Z:\postgres\postgres.vcxproj] .\Release\postgres\postgres.exe : fatal error LNK1120: 1 unresolved externals [Z:\postgres\postgres.vcxproj] "Z:\postgres\pgsql.sln" (default target) (1) -> "Z:\postgres\libpqwalreceiver.vcxproj" (default target) (4) -> "Z:\postgres\libpq.vcxproj" (default target) (5) -> libpgport.lib(snprintf.obj) : error LNK2019: unresolved external symbol snprintf referenced in function pg_strfromd [Z:\postgres\libpq.vcxproj] .\Release\libpq\libpq.dll : fatal error LNK1120: 1 unresolved externals [Z:\postgres\libpq.vcxproj] ----------------------------------- I think the cause of this error is the following commit regarding snprintf. As a test, I reverted this commit and built again, and the build succeeded. d33ac1ec2af5297b2ac8fbf89464f0c7f90a7955 Regards, Higuchi
PG Bug reporting form <noreply@postgresql.org> writes: > I tried to build using the codes of REL_12_13 in the following environment, > but it failed. > The main messages when it fails are following: > ----------------------------------- > "Z:\postgres\postgres.vcxproj" (default target) (2) -> > (Link target) -> > snprintf.obj : error LNK2019: unresolved external symbol snprintf > referenced in function pg_strfromd [Z:\postgres\postgres.vcxproj] Ugh. > I think the cause of this error is the following commit regarding > snprintf. > As a test, I reverted this commit and built again, and the build > succeeded. > d33ac1ec2af5297b2ac8fbf89464f0c7f90a7955 Thanks for checking that. However, as that commit message says, we require C99 support in v12 and up, and snprintf is definitely required by C99. So I'm disinclined to revert that. If VS2013 can't supply snprintf, it's not meeting our minimum platform standards, so we should remove it from the list of supported platforms. Having said that, Microsoft had had well over a dozen years by that point to get off their duffs and build a C99-compliant library. So I have to suspect that there is a snprintf lurking somewhere --- maybe there is some build option you need to enable to get it? regards, tom lane
I wrote: > Thanks for checking that. However, as that commit message says, > we require C99 support in v12 and up, and snprintf is definitely > required by C99. So I'm disinclined to revert that. If VS2013 > can't supply snprintf, it's not meeting our minimum platform > standards, so we should remove it from the list of supported > platforms. > Having said that, Microsoft had had well over a dozen years by > that point to get off their duffs and build a C99-compliant > library. After googling the question, I find that indeed Microsoft couldn't be bothered to support snprintf until VS2015. Bozos. Still, I suppose it'd be better to not move this portability goalpost in released branches. We could do something like #if defined(_MSC_VER) && _MSC_VER < 1900 /* pre-VS2015 */ #define snprintf(str,size,...) sprintf(str,__VA_ARGS__) #endif in snprintf.c below where it #undef's snprintf. Could you try that and verify it works for you? Also, the reason we didn't notice this problem is the lack of any VS2013 animal in the buildfarm. While we've dropped support for that as of HEAD (v16), it seems like somebody had better run such an animal on the back branches if they want the platform to keep working. regards, tom lane
RE: BUG #17681: Building the REL_12_13 source in Visual Studio 2013 fails.
От
"Daisuke Higuchi (Fujitsu)"
Дата:
>#if defined(_MSC_VER) && _MSC_VER < 1900 /* pre-VS2015 */ >#define snprintf(str,size,...) sprintf(str,__VA_ARGS__) >#endif > >in snprintf.c below where it #undef's snprintf. Could you try that and verify it works for you? Thank you! I verified this fix works correctly. I confirmed that it succeeded to build the source of REL_12_13 + this fix in Visual Studio 2013. Regards, Higuchi
"Daisuke Higuchi (Fujitsu)" <higuchi.daisuke@fujitsu.com> writes: >> #if defined(_MSC_VER) && _MSC_VER < 1900 /* pre-VS2015 */ >> #define snprintf(str,size,...) sprintf(str,__VA_ARGS__) >> #endif >> in snprintf.c below where it #undef's snprintf. Could you try that and verify it works for you? > Thank you! I verified this fix works correctly. > I confirmed that it succeeded to build the source of REL_12_13 + this fix in Visual Studio 2013. Excellent. Fix pushed. regards, tom lane