gen.py: Allow linking libstdc++ dynamically
Many distros don't ship static libraries of libstdc++ by default. Therefore,
it can make bootstrapping a bit more difficult, especially for packaging apps
that use GN.
Change-Id: Ie38cf97fe7454065becabe1789ea384efc3bf93f
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/5900
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
diff --git a/build/gen.py b/build/gen.py
index 99de57e..38085b4 100755
--- a/build/gen.py
+++ b/build/gen.py
@@ -95,6 +95,9 @@
help='The path to generate the build files in.')
parser.add_option('--no-strip', action='store_true',
help='Don\'t strip release build. Useful for profiling.')
+ parser.add_option('--no-static-libstdc++', action='store_true',
+ default=False, dest='no_static_libstdcpp',
+ help='Don\'t link libstdc++ statically')
options, args = parser.parse_args(argv)
if args:
@@ -324,10 +327,11 @@
cflags_cc.extend(['-std=c++14', '-Wno-c++11-narrowing'])
if platform.is_linux():
- ldflags.extend([
- '-static-libstdc++',
- '-Wl,--as-needed',
- ])
+ ldflags.append('-Wl,--as-needed')
+
+ if not options.no_static_libstdcpp:
+ ldflags.append('-static-libstdc++')
+
# This is needed by libc++.
libs.append('-ldl')
elif platform.is_darwin():