amoeba commented on code in PR #49585:
URL: https://github.com/apache/arrow/pull/49585#discussion_r3133425157


##########
cpp/src/arrow/flight/CMakeLists.txt:
##########
@@ -371,6 +380,43 @@ if(ARROW_BUILD_BENCHMARKS)
 
 endif(ARROW_BUILD_BENCHMARKS)
 
+# NOTE-49585: Workaround for issue found in GH-49585. When building Flight
+# targets with the combination of:
+#
+# - WIN32
+# - Debug
+# - /MD linkage
+#
+# You get linker errors like this:
+#
+# absl_synchronization.lib(mutex.cc.obj) : error LNK2005: "private: void 
__cdecl absl::lts_20250814::Mutex::Dtor(void)" (?Dtor
+# @Mutex@lts_20250814@absl@@AEAAXXZ) already defined in 
arrow_flight_static.lib(grpc_client.obj) 
[C:\path\to\arrow\cpp\static-debug-build\src\arrow\flight\sql\arrow-flight-sql-test.vcxproj]
+# 
C:\path\to\arrow\cpp\static-debug-build\debug\Debug\arrow-flight-sql-test.exe :
+# fatal error LNK1169: one or more multiply defined symbols found 
[C:\path\to\arrow\cpp\static-debug-build\src\arrow\flight\sql\arrow-flight-sql-test.vcxproj]
+#   Building Custom Rule C:/path/to/arrow/cpp/src/arrow/flight/CMakeLists.txt
+#   test_server.cc
+# absl_synchronization.lib(mutex.cc.obj) : error LNK2005: "private: void 
__cdecl absl::lts_20250814::Mutex::Dtor(void)" (?Dtor
+# @Mutex@lts_20250814@absl@@AEAAXXZ) already defined in 
arrow_flight_static.lib(protocol_grpc_internal.obj) 
[C:\path\to\arrow\cpp\static-debug-build\src\arrow\flight\flight-test-server.vcxproj]
+# C:\path\to\arrow\cpp\static-debug-build\debug\Debug\flight-test-server.exe : 
fatal error
+# LNK1169: one or more multiply defined symbols found 
[C:\path\to\arrow\cpp\static-debug-build\src\arrow\flight\flight-test-server.vcxproj]
+#
+# If you build in Release mode w/ /MD linkage you don't get these errors.
+if(WIN32
+   AND CMAKE_BUILD_TYPE STREQUAL "Debug"
+   AND ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static")
+  set(FLIGHT_TEST_EXES
+      arrow-flight-internals-test
+      arrow-flight-test
+      flight-test-server
+      arrow-flight-perf-server
+      arrow-flight-benchmark)
+  foreach(test_exe ${FLIGHT_TEST_EXES})
+    if(TARGET ${test_exe})
+      target_link_options(${test_exe} PRIVATE "/FORCE:MULTIPLE")
+    endif()
+  endforeach()
+endif()
+

Review Comment:
   @lidavidm @raulcd @kou do any of you have any thoughts on this workaround I 
came up with using Claude? I can dig in more if any of you want.
   
   It makes sense that the duplicate symbol could show up twice with how the 
build is set up and I can see why this only shows up in Debug builds: 
https://github.com/abseil/abseil-cpp/blob/master/absl/synchronization/mutex.h#L1197.
   
   The `/FORCE:MULTIPLE` workaround seems like a heavy fix.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to