BUG #17967: [msvc-x86] Failed to build with error LNK2019: unresolved external symbol __BitScanReverse64 referen

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: moyoumiu(at)outlook(dot)com
Subject: BUG #17967: [msvc-x86] Failed to build with error LNK2019: unresolved external symbol __BitScanReverse64 referen
Date: 2023-06-07 09:57:49
Message-ID: 17967-cd21e34a314141b2@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17967
Logged by: Youmiu Mo
Email address: moyoumiu(at)outlook(dot)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
```

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Mathias Kunter 2023-06-07 11:47:59 Re: BUG #17964: Missed query planner optimization
Previous Message PG Bug reporting form 2023-06-07 07:46:20 BUG #17965: SIGSEGV from LLVM13 JIT when executing SQL.