-
-
Notifications
You must be signed in to change notification settings - Fork 669
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
go_binary
and go_test
rules do not take --@io_bazel_rules_go//go/config:linkmode=pie
into account
#3614
Comments
--@io_bazel_rules_go//go/config:linkmode=pie
into accountgo_binary
and go_test
rules do not take --@io_bazel_rules_go//go/config:linkmode=pie
into account
After applying the following patch to debug what's going on in diff --git a/go/private/rules/transition.bzl b/go/private/rules/transition.bzl
index 4e87e30..521b07c 100644
--- a/go/private/rules/transition.bzl
+++ b/go/private/rules/transition.bzl
@@ -68,6 +68,9 @@ def _go_transition_impl(settings, attr):
# In any case, get_mode should mainly be responsible for reporting
# invalid modes, since it also takes --features flags into account.
+ print("In _go_transition_impl")
+ print("Linkmode (//go/config:linkmode) in transition input settings is '%s'" % settings['//go/config:linkmode'])
+ print("Linkmode in transition input attr is '%s'" % attr.linkmode)
original_settings = settings
settings = dict(settings)
@@ -111,11 +114,15 @@ def _go_transition_impl(settings, attr):
if tags:
settings["//go/config:tags"] = _deduped_and_sorted(tags)
+ # Settings is never inspected while deciding on the final linkmode.
+ # The only way to use what is in settings (config flag) is to explicitly
+ # set "linkmode" to "" or "auto".
linkmode = getattr(attr, "linkmode", "auto")
if linkmode != "auto":
if linkmode not in LINKMODES:
fail("linkmode: invalid mode {}; want one of {}".format(linkmode, ", ".join(LINKMODES)))
settings["//go/config:linkmode"] = linkmode
+ print("Linkmode from settings[//go/config:linkmode] is never processed")
for key, original_key in _SETTING_KEY_TO_ORIGINAL_SETTING_KEY.items():
old_value = original_settings[key]
@@ -136,6 +143,7 @@ def _go_transition_impl(settings, attr):
else:
settings[original_key] = ""
+ print("Transition returning settings['//go/config:linkmode']='%s'" % settings["//go/config:linkmode"])
return settings
def _request_nogo_transition(settings, _attr): I get the following output when running the build command with
I feel like the default values of |
The value of the flag was always overriden by the `linkmode` `go_binary` attribute, even if that attribute was at its default (`normal`) value. Instead, use a default of `auto` to distinguish this case from the case where no attribute value has been set explicitly. Fixes #3614 Closes #3615 Co-authored-by: Hakan Halil <[email protected]>
The value of the flag was always overriden by the `linkmode` `go_binary` attribute, even if that attribute was at its default (`normal`) value. Instead, use a default of `auto` to distinguish this case from the case where no attribute value has been set explicitly. Fixes #3614 Closes #3615 Co-authored-by: Hakan Halil <[email protected]>
The value of the flag was always overriden by the `linkmode` `go_binary` attribute, even if that attribute was at its default (`normal`) value. Instead, use a default of `auto` to distinguish this case from the case where no attribute value has been set explicitly. Fixes #3614 Closes #3615 Co-authored-by: Hakan Halil <[email protected]>
What version of rules_go are you using?
v0.40.1
What version of gazelle are you using?
v0.31.1
What version of Bazel are you using?
Does this issue reproduce with the latest releases of all the above?
Yes.
What operating system and processor architecture are you using?
CentOS 7.9.2009 on x86_64
Any other potentially useful information about your toolchain?
No, this is a plain environment.
What did you do?
I built a plain hello world binary using the
--@io_bazel_rules_go//go/config:linkmode=pie
flag.Afterward, I ran checksec to inspect its PIE-ness.
(the script was downloaded from https://www.trapkit.de/tools/checksec/checksec.sh)
Environment
What did you expect to see?
I expected to see positive information as an output of checksec for the PIE field.
What did you see instead?
Extras
When I set the
linkmode
attribute ofgo_binary
to"pie"
, the same command (checksec) gives a positive result for PIE-ness.The text was updated successfully, but these errors were encountered: