Naveen M K
unread,Nov 30, 2021, 6:24:37 AM11/30/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gn-...@chromium.org
Hi,
While building gn on mingw+clang (using clang64 environment from MSYS2),
I get an error while linking
[199/282] LINK gn.exe
FAILED: gn.exe
g++ -O3 -fdata-sections -ffunction-sections -Wl,--gc-sections
-Wl,-strip-all -Wl,--as-needed -static-libstdc++ -o gn.exe
-Wl,--start-group src/gn/gn_main.obj base.lib gn_lib.lib -Wl,--end-group
-ladvapi32 -ldbghelp -lkernel32 -lole32 -lshell32 -luser32 -luserenv
-lversion -lwinmm -lws2_32 -lshlwapi
lld: error: unknown argument: --as-needed
g++: error: linker command failed with exit code 1 (use -v to see
invocation)
I generated the ninja file with
python build/gen.py --out-path=out/${CARCH} --platform=mingw
I don't think `-Wl,--as-needed` argument is meaningful is for windows
binaries and lld doesn't support it. Note: in above log `g++` is aliased
to `clang++`.
It would be better if something like this was changed in `build/gen.py`,
diff --git a/build/gen.py b/build/gen.py
index 922bf46f..edcc0353 100755
--- a/build/gen.py
+++ b/build/gen.py
@@ -375,7 +375,8 @@ def WriteGNNinja(path, platform, host, options):
])
if platform.is_linux() or platform.is_mingw() or platform.is_msys():
- ldflags.append('-Wl,--as-needed')
+ if not platform.is_mingw():
+ ldflags.append('-Wl,--as-needed')
if not options.no_static_libstdcpp:
ldflags.append('-static-libstdc++')
Thanks,
Naveen M K