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

cc_binary's linkopts should expand labels used with "-Wl," #4440

Closed
pmuetschard opened this issue Jan 11, 2018 · 1 comment
Closed

cc_binary's linkopts should expand labels used with "-Wl," #4440

pmuetschard opened this issue Jan 11, 2018 · 1 comment

Comments

@pmuetschard
Copy link
Contributor

Description of the problem / feature request:

Passing options to the linker requires -Wl,<option>. To pass an option with a value, one can do one of the following:

  • -Wl,<option> -Wl,<value>
  • -Wl,<option>=<value>
  • -Wl,<option>,<value>

Bazel's cc_binary rule, however, only expands labels in the linkopts field if the string "does not start with $ or -". This makes it impossible to pass a file that is a label as a value to a link option.

For example, to pass a linker version script, one would need to cause the following flag passed to gcc:
-Wl,--version-script,<script>
However this is impossible:
linkopts = ["-Wl,--version-script,", "script.ldscript"] although performing label expansion, passes the script.ldscript file as a separate argument, which gets ignored.
linkopts = ["-Wl,--version-script", "-Wl,script.ldscript"] doesn't do label expansion, nor does it if using any of the other formats, and $(location script.ldscript) is not allowed.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

cc_binary(
  ...
  deps = [..., "script.ldscript"],
  linkopts = ["-Wl,--version-script,script.ldscript"]
  ...
)

What operating system are you running Bazel on?

Linux, but this is likely present on all OSs.

What's the output of bazel info release?

0.9.0, but also TOTT

@pmuetschard
Copy link
Contributor Author

Oops, never mind ["-Wl,--version-script,", "script.ldscript"] actually works. Sorry about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants