BUG #17967: [msvc-x86] Failed to build with error LNK2019: unresolved external symbol __BitScanReverse64 referen
The Post Office <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: moyoumiu@outlook.com
Date: 2023-06-07T09:57:49Z
Lists: pgsql-bugs
The following bug has been logged on the website: Bug reference: 17967 Logged by: Youmiu Mo Email address: moyoumiu@outlook.com PostgreSQL version: 15.3 Operating system: Windows Description: The file `src/bin/pg_verifybackup/pg_verifybackup.c` fails to compile using msvc under x86, there is no `_BitScanForward64` and `_BitScanReverse64` under **x86** for head `src/include/port/pg_bitutils.h`. ### output ```log F:\repo\postgresql\src\include\port\pg_bitutils.h(88,13): warning C4013: '_BitScanReverse64' undefined; assuming extern returning int (compiling source file src/bin/pg_verifybackup/pg_verifybackup.c) [F:\repo\postgresql\pg_verifybackup.vcxproj] pg_verifybackup.obj : error LNK2019: unresolved external symbol __BitScanReverse64 referenced in function _manifest_files_compute_parameters [F:\repo\postgresql\pg_verifybackup.vcxproj] ``` ### related lines https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/port/pg_bitutils.h;hb=83a611a259d41e305364b8de58f6b33a63cbda66#l88 https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/port/pg_bitutils.h;hb=83a611a259d41e305364b8de58f6b33a63cbda66#l159 ### references https://learn.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64?view=msvc-170#requirements https://learn.microsoft.com/en-us/cpp/intrinsics/bitscanreverse-bitscanreverse64?view=msvc-170#requirements ### steps to reproduce ```cmd "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -host_arch=x86 -arch=x86 cd F:\repo\postgresql\src\tools\msvc set PATH=F:\repo\tools;F:\tools\gnuwin32\bin;%PATH% build RELEASE cd F:\repo\postgresql msbuild /m /p:Platform=Win32 /p:Configuration=Release /p:PlatformToolset=v143 /p:WindowsTargetPlatformVersion=10.0.22621.0 pgsql.sln /verbosity:normal /t:Rebuild 2>&1 ```
Commits
-
Don't use _BitScanForward64/_BitScanReverse64 on 32-bit MSVC builds
- 53ea2b7ad050 16.0 landed
-
Remove newly added asserts from pg_bitutils.h
- 83a611a259d4 16.0 cited
-
Add MSVC support for pg_leftmost_one_pos32() and friends
- 67731974644c 16.0 cited