Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

hlopko
Copy link
Member

@hlopko hlopko commented Jun 18, 2019

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 #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.

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:
@hlopko
Copy link
Member Author

hlopko commented Jun 18, 2019

CC @philwo
CC @htuch

@hlopko hlopko self-assigned this Jun 18, 2019
@@ -854,6 +854,9 @@ def _impl(ctx):
iterate_over = "user_link_flags",
expand_if_available = "user_link_flags",
),
flag_group(
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@bazel-io bazel-io closed this in ab9c1f5 Jun 19, 2019
siberex pushed a commit to siberex/bazel that referenced this pull request Jul 4, 2019
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
irengrig pushed a commit to irengrig/bazel that referenced this pull request Jul 15, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

-static-libstdc++ -static-libgcc does not work with MOSTLY STATIC linking
3 participants