From 40ba838fe25b09f1153b91c7426bb4ccc4817c22 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Fri, 20 Dec 2024 13:39:22 -0800 Subject: [PATCH] Add dynamic-stdc++ (#400) Depending on your project statically linking libstdc++ from your sysroot might not be viable. For example if you rely on other shared libraries that link the shared version, linking the static version to a binary might result in ODR violations. This new `dynamic-stdc++` sets the compile flags correctly but doesn't force the static version, so the sysroot's shared version will be preferred. --- toolchain/cc_toolchain_config.bzl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/toolchain/cc_toolchain_config.bzl b/toolchain/cc_toolchain_config.bzl index 7bb55f35..013a59d1 100644 --- a/toolchain/cc_toolchain_config.bzl +++ b/toolchain/cc_toolchain_config.bzl @@ -268,6 +268,15 @@ def cc_toolchain_config( "-l:c++.a", "-l:c++abi.a", ]) + elif stdlib == "dynamic-stdc++": + cxx_flags = [ + "-std=" + cxx_standard, + "-stdlib=libstdc++", + ] + + link_flags.extend([ + "-lstdc++", + ]) elif stdlib == "stdc++": cxx_flags = [ "-std=" + cxx_standard,