Skip to content

Commit 20d3960

Browse files
committed
fix(smol): change abseil Windows patch to use linker flag
Change Windows duplicate symbol fix from disabling abseil.lib build to using /FORCE:MULTIPLE linker flag. This is a more robust solution that allows both libraries to be built properly. Previous approach: Disabled abseil.lib build on Windows (type: 'none') New approach: Add /FORCE:MULTIPLE to all Windows link operations Rationale: - /FORCE:MULTIPLE is the standard MSVC solution for duplicate symbols - Allows abseil.lib to be built properly for all targets - Linker picks one definition when symbols are identical - Safer than preventing library build entirely The duplicate symbols occur because v8_libbase includes abseil implementations while abseil.lib also provides them. Both provide identical implementations, so /FORCE:MULTIPLE is safe.
1 parent aebf103 commit 20d3960

File tree

1 file changed

+26
-31
lines changed

1 file changed

+26
-31
lines changed
Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,38 @@
11
# @node-versions: v24.10.0+
22
# @description: Fix abseil duplicate symbol errors on Windows
33
#
4-
# Disables standalone abseil.lib build on Windows by changing the abseil
5-
# target type from 'static_library' to 'none'. This prevents LNK2005
6-
# linker errors where absl::Mutex::Dtor and other symbols are defined
7-
# in both abseil.lib and v8_libbase.lib.
4+
# Adds /FORCE:MULTIPLE linker flag globally for Windows builds to allow
5+
# duplicate symbol definitions between abseil.lib and v8_libbase.lib.
86
#
97
# Root cause: Node.js v24 extracted abseil to a separate build target
108
# (tools/v8_gypfiles/abseil.gyp) to share code between V8 and perfetto.
11-
# On Windows with MSVC, this creates duplicate symbol errors because
12-
# V8's libbase already includes the necessary abseil implementations.
9+
# v8_libbase depends on and links against abseil.lib, but some abseil
10+
# symbols end up defined in both libraries, causing LNK2005 errors when
11+
# linking executables that use both (like torque.exe).
1312
#
14-
# Solution: On Windows only, configure abseil as type 'none' so headers
15-
# are available but no separate static library is built. V8's libbase
16-
# continues to provide the abseil implementations it needs.
13+
# Solution: Add /FORCE:MULTIPLE to all Windows link operations via the
14+
# toolchain configuration. The linker will pick one definition of each
15+
# duplicate symbol. This is safe because the implementations are identical.
1716
#
18-
# Error: abseil.lib(abseil.mutex.obj) : error LNK2005: absl::Mutex::Dtor
19-
# already defined in v8_libbase.lib(v8_libbase.mutex.obj)
17+
# Original errors:
18+
# LNK2005: absl::Mutex::Dtor already defined in v8_libbase.lib
19+
# LNK1169: one or more multiply defined symbols found
2020
#
2121
# References:
2222
# - https://github.com/nodejs/node/pull/57289 (abseil extraction)
23-
# - https://github.com/nodejs/node/pull/57582 (abseil deadlock detection)
23+
# - https://learn.microsoft.com/en-us/cpp/build/reference/force-force-file-output
2424

25-
--- a/tools/v8_gypfiles/abseil.gyp
26-
+++ b/tools/v8_gypfiles/abseil.gyp
27-
@@ -3,7 +3,15 @@
28-
'targets': [
29-
{
30-
'target_name': 'abseil',
31-
- 'type': 'static_library',
32-
+ 'conditions': [
33-
+ ['OS=="win"', {
34-
+ # On Windows, abseil symbols are already included in v8_libbase.
35-
+ # Building a separate abseil.lib causes LNK2005 duplicate symbol errors.
36-
+ 'type': 'none',
37-
+ }, {
38-
+ 'type': 'static_library',
39-
+ }],
40-
+ ],
41-
'toolsets': ['host', 'target'],
42-
'variables': {
43-
'ABSEIL_ROOT': '../../deps/v8/third_party/abseil-cpp',
25+
--- a/tools/v8_gypfiles/toolchain.gypi
26+
+++ b/tools/v8_gypfiles/toolchain.gypi
27+
@@ -525,6 +525,11 @@
28+
'/bigobj', # Prevent C1128: number of sections exceeded object file format limit.
29+
],
30+
},
31+
+ 'VCLinkerTool': {
32+
+ 'AdditionalOptions': [
33+
+ '/FORCE:MULTIPLE', # Allow duplicate symbol definitions (abseil.lib vs v8_libbase.lib).
34+
+ ],
35+
+ },
36+
},
37+
}],
38+
['v8_target_arch=="ia32"', {

0 commit comments

Comments
 (0)