-
-
Notifications
You must be signed in to change notification settings - Fork 668
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
Let go_binary's executable bit depend on linkmode
#3143
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fmeum
force-pushed
the
non-executable-linkmodes
branch
from
May 9, 2022 10:01
d7c2284
to
7a8805d
Compare
achew22
reviewed
May 9, 2022
If a go_binary's `linkmode` is neither `normal` nor `pie`, the resulting file can't be executed. In this case, `executable` should be set to `False` on the go_binary rule so that Bazel doesn't create a runfiles tree for the targets and does not include e.g. a resulting static library in the runfiles of dependants.
fmeum
force-pushed
the
non-executable-linkmodes
branch
from
May 9, 2022 18:43
7a8805d
to
cb27b32
Compare
@achew22 Thanks for the review, addressed your comments. |
Thanks for your contribution! |
fmeum
added a commit
to CodeIntelligenceTesting/rules_go
that referenced
this pull request
May 12, 2022
If a go_binary is built with a non-executable link mode such as `c-archive`, its dependents currently pick up a runfile dependency on it since its DefaultInfo specifies the resulting archive as an executable. This is unnecessary as the dependent should be able to decide whether to include the file (e.g. dynamic linking) or not (e.g. static linking). With this commit, the executable field of the DefaultInfo is only populated if the go_binary is built with an executable link mode. Follow-up to bazel-contrib#3143
fmeum
added a commit
to CodeIntelligenceTesting/rules_go
that referenced
this pull request
May 12, 2022
If a go_binary is built with a non-executable link mode such as `c-archive`, its dependents currently pick up a runfile dependency on it since its DefaultInfo specifies the resulting archive as an executable. This is unnecessary as the dependent should be able to decide whether to include the file (e.g. dynamic linking) or not (e.g. static linking). With this commit, the executable field of the DefaultInfo is only populated if the go_binary is built with an executable link mode. Follow-up to bazel-contrib#3143
fmeum
added a commit
to CodeIntelligenceTesting/rules_go
that referenced
this pull request
May 12, 2022
If a go_binary is built with a non-executable link mode such as `c-archive`, its dependents currently pick up a runfile dependency on it since its DefaultInfo specifies the resulting archive as an executable. This is unnecessary as the dependent should be able to decide whether to include the file (e.g. dynamic linking) or not (e.g. static linking). With this commit, the executable field of the DefaultInfo is only populated if the go_binary is built with an executable link mode. Follow-up to bazel-contrib#3143
fmeum
added a commit
to CodeIntelligenceTesting/rules_go
that referenced
this pull request
May 12, 2022
If a go_binary is built with a non-executable link mode such as `c-archive`, its dependents currently pick up a runfile dependency on it since its DefaultInfo specifies the resulting archive as an executable. This is unnecessary as the dependent should be able to decide whether to include the file (e.g. dynamic linking) or not (e.g. static linking). With this commit, the executable field of the DefaultInfo is only populated if the go_binary is built with an executable link mode. Follow-up to bazel-contrib#3143
fmeum
added a commit
to CodeIntelligenceTesting/rules_go
that referenced
this pull request
May 12, 2022
If a go_binary is built with a non-executable link mode such as `c-archive`, its dependents currently pick up a runfile dependency on it since its DefaultInfo specifies the resulting archive as an executable. This is unnecessary as the dependent should be able to decide whether to include the file (e.g. dynamic linking) or not (e.g. static linking). With this commit, the executable field of the DefaultInfo is only populated if the go_binary is built with an executable link mode. Follow-up to bazel-contrib#3143
fmeum
added a commit
to CodeIntelligenceTesting/rules_go
that referenced
this pull request
May 12, 2022
If a go_binary is built with a non-executable link mode such as `c-archive`, its dependents currently pick up a runfile dependency on it since its DefaultInfo specifies the resulting archive as an executable. This is unnecessary as the dependent should be able to decide whether to include the file (e.g. dynamic linking) or not (e.g. static linking). With this commit, the executable field of the DefaultInfo is only populated if the go_binary is built with an executable link mode. Follow-up to bazel-contrib#3143
fmeum
added a commit
to CodeIntelligenceTesting/rules_go
that referenced
this pull request
May 12, 2022
If a go_binary is built with a non-executable link mode such as `c-archive`, its dependents currently pick up a runfile dependency on it since its DefaultInfo specifies the resulting archive as an executable. This is unnecessary as the dependent should be able to decide whether to include the file (e.g. dynamic linking) or not (e.g. static linking). With this commit, the executable field of the DefaultInfo is only populated if the go_binary is built with an executable link mode. Follow-up to bazel-contrib#3143
fmeum
added a commit
to CodeIntelligenceTesting/rules_go
that referenced
this pull request
May 12, 2022
If a go_binary is built with a non-executable link mode such as `c-archive`, its dependents currently pick up a runfile dependency on it since its DefaultInfo specifies the resulting archive as an executable. This is unnecessary as the dependent should be able to decide whether to include the file (e.g. dynamic linking) or not (e.g. static linking). With this commit, the executable field of the DefaultInfo is only populated if the go_binary is built with an executable link mode. Follow-up to bazel-contrib#3143
fmeum
added a commit
to CodeIntelligenceTesting/rules_go
that referenced
this pull request
May 12, 2022
If a go_binary is built with a non-executable link mode such as `c-archive`, its dependents currently pick up a runfile dependency on it since its DefaultInfo specifies the resulting archive as an executable. This is unnecessary as the dependent should be able to decide whether to include the file (e.g. dynamic linking) or not (e.g. static linking). With this commit, the executable field of the DefaultInfo is only populated if the go_binary is built with an executable link mode. Follow-up to bazel-contrib#3143
linzhp
pushed a commit
that referenced
this pull request
Jun 10, 2022
* Remove unnecessary rpath special handling on macOS Based on bazelbuild/bazel#10254 (comment) and bazelbuild/bazel#12304 being fixed, this special handling of rpaths on macOS appears to be unnecessary. This cleanup ensures that Bazel sets the correct metadata for the exec location of Go libraries linked in c-shared mode, which in turn allows to not include them in the runfiles of all dependents - cc_* targets depending on them will now generate the correct rpath entries to find the libraries at runtime at the usual position. * Don't include non-executable go_binary in dependent's runfiles If a go_binary is built with a non-executable link mode such as `c-archive`, its dependents currently pick up a runfile dependency on it since its DefaultInfo specifies the resulting archive as an executable. This is unnecessary as the dependent should be able to decide whether to include the file (e.g. dynamic linking) or not (e.g. static linking). With this commit, the executable field of the DefaultInfo is only populated if the go_binary is built with an executable link mode. Follow-up to #3143
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Bug fix
What does this PR do? Why is it needed?
If a go_binary's
linkmode
is neithernormal
norpie
, the resultingfile can't be executed. In this case,
executable
should be set toFalse
on the go_binary rule so that Bazel doesn't create a runfilestree for the targets and does not include e.g. a resulting static
library in the runfiles of dependants.