-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Teach cc_configure about BAZEL_LINKLIBS env variable #8660
Conversation
Using this variable is will be possible to specify system libraries that should be added after default linker flags, after libraries to link, and after user link flags (i.e. --linkopt and `linkopts` rule attribute). Flag separator is `:`, similarly to BAZEL_LINKOPTS. Escaping is done by `%`. Default value is empty string. With this it's possible to force Bazel to statically link libstdc++ by using: BAZEL_LINKOPTS=-static-libstdc++ BAZEL_LINKLIBS=-l%:libstdc++.a bazel build //foo RELNOTES: Bazel's C++ autoconfiguration now understands BAZEL_LINKLIBS GOOGLE:
@@ -854,6 +854,9 @@ def _impl(ctx): | |||
iterate_over = "user_link_flags", | |||
expand_if_available = "user_link_flags", | |||
), | |||
flag_group( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flag_group must have one of flag_groups and flags nonempty, which will make Bazel complain in case ctx.attr.link_libs is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interview question :) Why was @hlopko never supposed to be hired? https://source.bazel.build/bazel/+/fa654b4878974e591d7e0bea3fa233c6b120395b:tools/cpp/lib_cc_configure.bzl;l=47
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, I'm not stupid, maybe. Ignore this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Using this variable is will be possible to specify system libraries that should be added after default linker flags, after libraries to link, and after user link flags (i.e. after --linkopt and `linkopts` rule attribute). Flag separator is `:`, similarly to `BAZEL_LINKOPTS`. Escaping is done by `%`. Default value is empty string. With this it's possible to force Bazel to statically link `libstdc++` by using: ``` BAZEL_LINKOPTS=-static-libstdc++ BAZEL_LINKLIBS=-l%:libstdc++.a bazel build //foo ``` Fixes bazelbuild#2840. Relevant for bazelbuild#8652. RELNOTES: Bazel's C++ autoconfiguration now understands `BAZEL_LINKLIBS` environment variable to specify system libraries that should be appended to the link command line. Closes bazelbuild#8660. PiperOrigin-RevId: 253946433
Using this variable is will be possible to specify system libraries that should be added after default linker flags, after libraries to link, and after user link flags (i.e. after --linkopt and `linkopts` rule attribute). Flag separator is `:`, similarly to `BAZEL_LINKOPTS`. Escaping is done by `%`. Default value is empty string. With this it's possible to force Bazel to statically link `libstdc++` by using: ``` BAZEL_LINKOPTS=-static-libstdc++ BAZEL_LINKLIBS=-l%:libstdc++.a bazel build //foo ``` Fixes bazelbuild#2840. Relevant for bazelbuild#8652. RELNOTES: Bazel's C++ autoconfiguration now understands `BAZEL_LINKLIBS` environment variable to specify system libraries that should be appended to the link command line. Closes bazelbuild#8660. PiperOrigin-RevId: 253946433
Using this variable is will be possible to specify system libraries that
should be added after default linker flags, after libraries to link, and
after user link flags (i.e. after --linkopt and
linkopts
rule attribute).Flag separator is
:
, similarly toBAZEL_LINKOPTS
. Escaping is done by%
.Default value is empty string.
With this it's possible to force Bazel to statically link
libstdc++
byusing:
Fixes #2840.
Relevant for #8652.
RELNOTES: Bazel's C++ autoconfiguration now understands
BAZEL_LINKLIBS
environment variable to specify system libraries that should be appended to the link command line.