[jira] [Comment Edited] (ARROW-16778) [C++] 32 bit MSVC doesn't build

2022-06-13 Thread Kouhei Sutou (Jira)


[ 
https://issues.apache.org/jira/browse/ARROW-16778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17553746#comment-17553746
 ] 

Kouhei Sutou edited comment on ARROW-16778 at 6/14/22 12:13 AM:


[~willjones127] [~kou]
The next problem I am having is:

{noformat}
Run-Time Check Failure #0 - The value of ESP was not properly saved across a 
function call.  This is usually a result of calling a function declared with 
one calling convention with a function pointer declared with a different 
calling convention.
{noformat}

On this line in io_util.cc:

{noformat}
if (!entries.empty() &&
!prefetch_virtual_memory(GetCurrentProcess(),
 {noformat}


was (Author: JIRAUSER290619):
[~willjones127] [~kou]
The next problem I am having is:

Run-Time Check Failure #0 - The value of ESP was not properly saved across a 
function call.  This is usually a result of calling a function declared with 
one calling convention with a function pointer declared with a different 
calling convention.

On this line in io_util.cc:

{noformat}
if (!entries.empty() &&
!prefetch_virtual_memory(GetCurrentProcess(),
 {noformat}

> [C++] 32 bit MSVC doesn't build
> ---
>
> Key: ARROW-16778
> URL: https://issues.apache.org/jira/browse/ARROW-16778
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: C++
> Environment: Win32, MSVC
>Reporter: Arkadiy Vertleyb
>Assignee: Arkadiy Vertleyb
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> When specifying Win32 as a platform, and building with MSVC, the build fails 
> with the following compile errors :
> {noformat}
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(70,59): error 
> C3861: '__popcnt64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(204,7): error 
> C3861: '_BitScanReverse64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(250,7): error 
> C3861: '_BitScanForward64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj] 
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Comment Edited] (ARROW-16778) [C++] 32 bit MSVC doesn't build

2022-06-13 Thread Kouhei Sutou (Jira)


[ 
https://issues.apache.org/jira/browse/ARROW-16778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17553764#comment-17553764
 ] 

Kouhei Sutou edited comment on ARROW-16778 at 6/14/22 12:12 AM:


And this is fixed by the following:

{noformat}
@@ -1280,7 +1280,7 @@ Status MemoryAdviseWillNeed(const 
std::vector& regions) {
 PrefetchEntry(const MemoryRegion& region)  // NOLINT runtime/explicit
 : VirtualAddress(region.addr), NumberOfBytes(region.size) {}
   };
-  using PrefetchVirtualMemoryFunc = BOOL (*)(HANDLE, ULONG_PTR, 
PrefetchEntry*, ULONG);
+  using PrefetchVirtualMemoryFunc = BOOL (__stdcall *)(HANDLE, ULONG_PTR, 
PrefetchEntry*, ULONG);
 {noformat}


was (Author: JIRAUSER290619):
And this is fixed by the following:

@@ -1280,7 +1280,7 @@ Status MemoryAdviseWillNeed(const 
std::vector& regions) {
 PrefetchEntry(const MemoryRegion& region)  // NOLINT runtime/explicit
 : VirtualAddress(region.addr), NumberOfBytes(region.size) {}
   };
-  using PrefetchVirtualMemoryFunc = BOOL (*)(HANDLE, ULONG_PTR, 
PrefetchEntry*, ULONG);
+  using PrefetchVirtualMemoryFunc = BOOL (__stdcall *)(HANDLE, ULONG_PTR, 
PrefetchEntry*, ULONG);
 

> [C++] 32 bit MSVC doesn't build
> ---
>
> Key: ARROW-16778
> URL: https://issues.apache.org/jira/browse/ARROW-16778
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: C++
> Environment: Win32, MSVC
>Reporter: Arkadiy Vertleyb
>Assignee: Arkadiy Vertleyb
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> When specifying Win32 as a platform, and building with MSVC, the build fails 
> with the following compile errors :
> {noformat}
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(70,59): error 
> C3861: '__popcnt64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(204,7): error 
> C3861: '_BitScanReverse64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(250,7): error 
> C3861: '_BitScanForward64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj] 
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Comment Edited] (ARROW-16778) [C++] 32 bit MSVC doesn't build

2022-06-13 Thread Kouhei Sutou (Jira)


[ 
https://issues.apache.org/jira/browse/ARROW-16778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17553746#comment-17553746
 ] 

Kouhei Sutou edited comment on ARROW-16778 at 6/14/22 12:12 AM:


[~willjones127] [~kou]
The next problem I am having is:

Run-Time Check Failure #0 - The value of ESP was not properly saved across a 
function call.  This is usually a result of calling a function declared with 
one calling convention with a function pointer declared with a different 
calling convention.

On this line in io_util.cc:

{noformat}
if (!entries.empty() &&
!prefetch_virtual_memory(GetCurrentProcess(),
 {noformat}


was (Author: JIRAUSER290619):
[~willjones127] [~kou]
The next problem I am having is:

Run-Time Check Failure #0 - The value of ESP was not properly saved across a 
function call.  This is usually a result of calling a function declared with 
one calling convention with a function pointer declared with a different 
calling convention.

On this line in io_util.cc:

if (!entries.empty() &&
!prefetch_virtual_memory(GetCurrentProcess(),
 

> [C++] 32 bit MSVC doesn't build
> ---
>
> Key: ARROW-16778
> URL: https://issues.apache.org/jira/browse/ARROW-16778
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: C++
> Environment: Win32, MSVC
>Reporter: Arkadiy Vertleyb
>Assignee: Arkadiy Vertleyb
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> When specifying Win32 as a platform, and building with MSVC, the build fails 
> with the following compile errors :
> {noformat}
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(70,59): error 
> C3861: '__popcnt64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(204,7): error 
> C3861: '_BitScanReverse64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(250,7): error 
> C3861: '_BitScanForward64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj] 
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Comment Edited] (ARROW-16778) [C++] 32 bit MSVC doesn't build

2022-06-13 Thread Kouhei Sutou (Jira)


[ 
https://issues.apache.org/jira/browse/ARROW-16778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17553743#comment-17553743
 ] 

Kouhei Sutou edited comment on ARROW-16778 at 6/14/22 12:12 AM:


[~willjones127][~kou] The following patch fixes the issue (this is in the code 
I was advised to use as a fallback:

{noformat}
@@ -255,7 +262,7 @@ static inline int CountTrailingZeros(uint64_t value) {
 #else
   int bitpos = 0;
   if (value) {
-while (value & 1 == 0) {
+while ((value & 1) == 0) {
   value >>= 1;
   ++bitpos;
 }
{noformat}


was (Author: JIRAUSER290619):
[~willjones127][~kou] The following patch fixes the issue (this is in the code 
I was advised to use as a fallback:

@@ -255,7 +262,7 @@ static inline int CountTrailingZeros(uint64_t value) {
 #else
   int bitpos = 0;
   if (value) {
-while (value & 1 == 0) {
+while ((value & 1) == 0) {
   value >>= 1;
   ++bitpos;
 }


> [C++] 32 bit MSVC doesn't build
> ---
>
> Key: ARROW-16778
> URL: https://issues.apache.org/jira/browse/ARROW-16778
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: C++
> Environment: Win32, MSVC
>Reporter: Arkadiy Vertleyb
>Assignee: Arkadiy Vertleyb
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> When specifying Win32 as a platform, and building with MSVC, the build fails 
> with the following compile errors :
> {noformat}
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(70,59): error 
> C3861: '__popcnt64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(204,7): error 
> C3861: '_BitScanReverse64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(250,7): error 
> C3861: '_BitScanForward64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj] 
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Comment Edited] (ARROW-16778) [C++] 32 bit MSVC doesn't build

2022-06-10 Thread Arkadiy Vertleyb (Jira)


[ 
https://issues.apache.org/jira/browse/ARROW-16778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17552918#comment-17552918
 ] 

Arkadiy Vertleyb edited comment on ARROW-16778 at 6/10/22 6:41 PM:
---

[~willjones127] Depends.
Besides crash, multiple tests fail.
Let me ask you - in your best estimate, when was the last time someone ran 32 
bit tests?  It could be badly broken by now...
I am afraid fixing that might be a major task, even for someone closely 
familiar with the system, let alone a new library user like myself.
For your reference:
  Start  1: arrow-array-test
 1/26 Test  #1: arrow-array-test .***Failed0.24 sec
  Start  2: arrow-buffer-test
 2/26 Test  #2: arrow-buffer-test    Passed0.03 sec
  Start  3: arrow-extension-type-test
 3/26 Test  #3: arrow-extension-type-test ***Failed0.02 sec
  Start  4: arrow-misc-test
 4/26 Test  #4: arrow-misc-test ..   Passed0.05 sec
  Start  5: arrow-public-api-test
 5/26 Test  #5: arrow-public-api-test    Passed0.02 sec
  Start  6: arrow-scalar-test
 6/26 Test  #6: arrow-scalar-test ***Failed0.06 sec
  Start  7: arrow-type-test
 7/26 Test  #7: arrow-type-test ..   Passed0.15 sec
  Start  8: arrow-table-test
 8/26 Test  #8: arrow-table-test .***Failed0.05 sec
  Start  9: arrow-tensor-test
 9/26 Test  #9: arrow-tensor-test    Passed0.02 sec
  Start 10: arrow-sparse-tensor-test
10/26 Test #10: arrow-sparse-tensor-test .   Passed0.07 sec
  Start 11: arrow-stl-test
11/26 Test #11: arrow-stl-test ...   Passed0.03 sec
  Start 12: arrow-random-test
12/26 Test #12: arrow-random-test    Passed0.20 sec
  Start 13: arrow-json-integration-test
13/26 Test #13: arrow-json-integration-test ..***Failed0.15 sec
  Start 14: arrow-concatenate-test
14/26 Test #14: arrow-concatenate-test ...***Failed0.02 sec
  Start 15: arrow-c-bridge-test
15/26 Test #15: arrow-c-bridge-test ..***Failed0.06 sec
  Start 16: arrow-io-buffered-test
16/26 Test #16: arrow-io-buffered-test ...   Passed0.08 sec
  Start 17: arrow-io-compressed-test
17/26 Test #17: arrow-io-compressed-test .   Passed0.02 sec
  Start 18: arrow-io-file-test
18/26 Test #18: arrow-io-file-test ...***Failed   10.61 sec
  Start 19: arrow-io-memory-test
19/26 Test #19: arrow-io-memory-test .***Failed1.62 sec
  Start 20: arrow-utility-test
20/26 Test #20: arrow-utility-test ...***Failed3.00 sec
  Start 21: arrow-threading-utility-test
21/26 Test #21: arrow-threading-utility-test .   Passed   39.77 sec
  Start 22: arrow-feather-test
22/26 Test #22: arrow-feather-test ...***Failed0.04 sec
  Start 23: arrow-ipc-json-simple-test
23/26 Test #23: arrow-ipc-json-simple-test ...***Failed0.06 sec
  Start 24: arrow-ipc-read-write-test
24/26 Test #24: arrow-ipc-read-write-test ***Failed8.17 sec
  Start 25: arrow-ipc-tensor-test
25/26 Test #25: arrow-ipc-tensor-test ***Failed1.16 sec
  Start 26: arrow-json-test
26/26 Test #26: arrow-json-test ..***Failed0.03 sec

42% tests passed, 15 tests failed out of 26 


was (Author: JIRAUSER290619):
[~willjones127] Depends.
Besides crash, multiple tests fail.
Let me ask you - in your best estimate, when was the last time someone ran 32 
bit tests?  It could be badly broken by now...
I am afraid fixing that might be a major task, even for someone closely 
familiar with the system, let alone a library user like myself.
For your reference:
  Start  1: arrow-array-test
 1/26 Test  #1: arrow-array-test .***Failed0.24 sec
  Start  2: arrow-buffer-test
 2/26 Test  #2: arrow-buffer-test    Passed0.03 sec
  Start  3: arrow-extension-type-test
 3/26 Test  #3: arrow-extension-type-test ***Failed0.02 sec
  Start  4: arrow-misc-test
 4/26 Test  #4: arrow-misc-test ..   Passed0.05 sec
  Start  5: arrow-public-api-test
 5/26 Test  #5: arrow-public-api-test    Passed0.02 sec
  Start  6: arrow-scalar-test
 6/26 Test  #6: arrow-scalar-test ***Failed0.06 sec
  Start  7: arrow-type-test
 7/26 Test  #7: arrow-type-test ..   Passed0.15 sec
  Start  8: arrow-table-test
 8/26 Test  #8: arrow-table-test .***Failed0.05 sec
  Start  9: arrow-tensor-test
 9/26 Test  #9: arrow-tensor-test    Passed0.02 sec
  Start 10: arrow-sparse-tensor-test
10/26 Test #10: arrow-sparse-tensor-test .   Passed0.07 sec
  Start 11: 

[jira] [Comment Edited] (ARROW-16778) [C++] 32 bit MSVC doesn't build

2022-06-10 Thread Arkadiy Vertleyb (Jira)


[ 
https://issues.apache.org/jira/browse/ARROW-16778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17552895#comment-17552895
 ] 

Arkadiy Vertleyb edited comment on ARROW-16778 at 6/10/22 6:02 PM:
---

[~willjones127] This builds with three path parameters removed to use defaults 
and with my patch applied.

But then ctest crashes running arrow-io-file-test. 


was (Author: JIRAUSER290619):
[~willjones127] This builds with three path parameters removed to use defaults 
and with my patch applied.

But ctest crashes running arrow-io-file-test. 

> [C++] 32 bit MSVC doesn't build
> ---
>
> Key: ARROW-16778
> URL: https://issues.apache.org/jira/browse/ARROW-16778
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: C++
> Environment: Win32, MSVC
>Reporter: Arkadiy Vertleyb
>Priority: Major
>
> When specifying Win32 as a platform, and building with MSVC, the build fails 
> with the following compile errors :
> {noformat}
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(70,59): error 
> C3861: '__popcnt64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(204,7): error 
> C3861: '_BitScanReverse64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(250,7): error 
> C3861: '_BitScanForward64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj] 
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Comment Edited] (ARROW-16778) [C++] 32 bit MSVC doesn't build

2022-06-09 Thread Arkadiy Vertleyb (Jira)


[ 
https://issues.apache.org/jira/browse/ARROW-16778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17552403#comment-17552403
 ] 

Arkadiy Vertleyb edited comment on ARROW-16778 at 6/9/22 7:48 PM:
--

Thanks Will.
Saw you latest comment at Bloomberg. 
Please also keep in mind that using -DCMAKE_BUILD_TYPE=Debug somehow ends up 
with treating warnings as errors, which doesn't work well in a 32 bit system 
because of conflicts between int64_t and size_t.  As I understand this comes 
from Google guidelines conflicting with C++ standard.  Not sure how to avoid 
this.
As you probably guessed by now, I am no cmake expert :-( 


was (Author: JIRAUSER290619):
Thanks Will.
Saw you latest comment at Bloomberg. 
Please also keep in mind that using -DCMAKE_BUILD_TYPE=Debug somehow ends up 
with treating warnings as errors, which doesn't work well in a 32 bit system 
because of conflicts between int64_t and size_t.  As I understand this comes 
from Google guidelines conflicting with C++ standard.  Not sure how to avoid 
this. 

> [C++] 32 bit MSVC doesn't build
> ---
>
> Key: ARROW-16778
> URL: https://issues.apache.org/jira/browse/ARROW-16778
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: C++
> Environment: Win32, MSVC
>Reporter: Arkadiy Vertleyb
>Priority: Major
>
> When specifying Win32 as a platform, and building with MSVC, the build fails 
> with the following compile errors :
> {noformat}
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(70,59): error 
> C3861: '__popcnt64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(204,7): error 
> C3861: '_BitScanReverse64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(250,7): error 
> C3861: '_BitScanForward64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj] 
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Comment Edited] (ARROW-16778) [C++] 32 bit MSVC doesn't build

2022-06-09 Thread Arkadiy Vertleyb (Jira)


[ 
https://issues.apache.org/jira/browse/ARROW-16778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17552314#comment-17552314
 ] 

Arkadiy Vertleyb edited comment on ARROW-16778 at 6/9/22 4:51 PM:
--

I was going to, but after I got the build fixed the arrow-utility-test hangs.  
Not sure if it is related to my fix, haven't figured out yet how debug it 
properly.

This was my patch:

index 8583e10b2..5122cb3d5 100644
--- a/cpp/src/arrow/util/bit_util.h
+++ b/cpp/src/arrow/util/bit_util.h
@@ -67,7 +67,14 @@ static constexpr uint8_t kBytePopcount[] = {
 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 
4, 5, 5, 6,
 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};

-static inline uint64_t PopCount(uint64_t bitmap) { return 
ARROW_POPCOUNT64(bitmap); }
+static inline uint64_t PopCount(uint64_t bitmap) {
+#if defined(_MSC_VER) && !defined(_M_AMD64) && !defined(_M_X64)
+  const uint32_t* p = reinterpret_cast();
+  return ARROW_POPCOUNT32(*p) + ARROW_POPCOUNT32(*(p + 1));
+#else
+  return ARROW_POPCOUNT64(bitmap);
+#endif
+}
 static inline uint32_t PopCount(uint32_t bitmap) { return 
ARROW_POPCOUNT32(bitmap); }

 //
@@ -199,7 +206,7 @@ static inline int CountLeadingZeros(uint64_t value) {
 #if defined(__clang__) || defined(__GNUC__)
   if (value == 0) return 64;
   return static_cast(__builtin_clzll(value));
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64))
   unsigned long index; // NOLINT
   if (_BitScanReverse64(, value)) {  // NOLINT
 return 63 - static_cast(index);
@@ -245,7 +252,7 @@ static inline int CountTrailingZeros(uint64_t value) {
 #if defined(__clang__) || defined(__GNUC__)
   if (value == 0) return 64;
   return static_cast(__builtin_ctzll(value));
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64))
   unsigned long index;  // NOLINT
   if (_BitScanForward64(, value)) {
 return static_cast(index);
  


was (Author: JIRAUSER290619):
I was going to, but after I got the build fixed the arrow-utility-test hangs.  
Not sure if it is related to my fix, haven't figured out yet how debug it 
properly.

This was my patch:

index 8583e10b2..5122cb3d5 100644
--- a/cpp/src/arrow/util/bit_util.h
+++ b/cpp/src/arrow/util/bit_util.h
@@ -67,7 +67,14 @@ static constexpr uint8_t kBytePopcount[] = {
 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 
4, 5, 5, 6,
 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};

-static inline uint64_t PopCount(uint64_t bitmap) { return 
ARROW_POPCOUNT64(bitmap); }
+static inline uint64_t PopCount(uint64_t bitmap) {
+#if defined(_MSC_VER) && !defined(_M_AMD64) && !defined(_M_X64)
+  const uint32_t* p = reinterpret_cast();
+  return ARROW_POPCOUNT32(*p) + ARROW_POPCOUNT32(*(p + 1));
+#else
+  return ARROW_POPCOUNT64(bitmap);
+#endif
+}
 static inline uint32_t PopCount(uint32_t bitmap) { return 
ARROW_POPCOUNT32(bitmap); }

 //
@@ -199,7 +206,7 @@ static inline int CountLeadingZeros(uint64_t value) {
 #if defined(__clang__) || defined(__GNUC__)
   if (value == 0) return 64;
   return static_cast(__builtin_clzll(value));
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64))
   unsigned long index; // NOLINT
   if (_BitScanReverse64(, value)) {  // NOLINT
 return 63 - static_cast(index);
@@ -245,7 +252,7 @@ static inline int CountTrailingZeros(uint64_t value) {
 #if defined(__clang__) || defined(__GNUC__)
   if (value == 0) return 64;
   return static_cast(__builtin_ctzll(value));
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64))
   unsigned long index;  // NOLINT
   if (_BitScanForward64(, value)) {
 return static_cast(index);
  

> [C++] 32 bit MSVC doesn't build
> ---
>
> Key: ARROW-16778
> URL: https://issues.apache.org/jira/browse/ARROW-16778
> Project: Apache Arrow
>  Issue Type: Bug
>  Components: C++
> Environment: Win32, MSVC
>Reporter: Arkadiy Vertleyb
>Priority: Major
>
> When specifying Win32 as a platform, and building with MSVC, the build fails 
> with the following compile errors :
> {noformat}
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(70,59): error 
> C3861: '__popcnt64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(204,7): error 
> C3861: '_BitScanReverse64': identifier not found 
> [C:\Users\avertleyb\git\arrow\cpp\build32\src\arrow\arrow_shared.vcxproj]
> C:\Users\avertleyb\git\arrow\cpp\src\arrow/util/bit_util.h(250,7): error 
> C3861: '_BitScanForward64': identifier not found 
>