-
Notifications
You must be signed in to change notification settings - Fork 4.2k
$(location) should use runtime path when used in jvm_flags attribute #2475
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
Comments
@damienmg Do you think it's reasonable to support this feature? Or is there a better way to find the runtime path of javac.jar? |
//cc @kchodorow |
FWIW we cannot make $(location ) returns an absolute path but it should be able to return a path relative to the runfile tree. @kchodorow should definitely knows how / when it will be possible to do so. |
It's an awfully big hammer, but Skylark's |
Hey, I have this exact same need but I can't use |
ping. I need this to be able to work with sandboxing/remote execution... |
Adding a link to a corresponding StackOverflow question. |
It seems reasonable to change |
Another function would be great! |
Do you think that there are a lot of cases where it's unclear? |
Not at all. I have two use cases which both boil down to jvm_flags (one BUILD file and one in a macro). I'm just afraid a bit that changing the semantics would take longer than adding a new function. |
I can think of use cases that require making this configurable by the user (genrule.cmd), but maybe we should also disallow $(location) for jvm_flags, where it's basically never correct (I think). |
Why is this never correct? Or do you mean given a new runtime_location
function then this is never correct?
…On Wed, 24 May 2017 at 19:59 Ulf Adams ***@***.***> wrote:
I can think of use cases that require making this configurable by the user
(genrule.cmd), but maybe we should also disallow $(location) for jvm_flags,
where it's basically never correct (I think).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2475 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIFynqkF_gmCNXMkm5-oucWEK0ck85ks5r9GHUgaJpZM4L1oIQ>
.
|
Banning |
jvm_flags are only applied at runtime, so a function that expands to the compile-time path is 'never' correct, except it happens to be ok for source files. |
@shahms - the proposal is to add |
That makes more sense, thanks :-) |
See b1b02d7 for prior art. |
Our documentation seems to suggest that file paths returned by $(location ...) are runtime paths
https://bazel.build/versions/master/docs/be/make-variables.html#location |
That's untrue at least for genrules. A quick glance at the code says that we get execpaths, which makes sense because otherwise the |
LocationExpander takes options, and can be configured to return runtime
paths. :-/
…On Wed, Jun 14, 2017 at 1:57 PM, lberki ***@***.***> wrote:
That's untrue at least for genrules. A quick glance at the code says that
we get execpaths, which makes sense because otherwise the $(location)
support in java_toolchain wouldn't make sense.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2475 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHA9YUQbQxQNFLAQ0_gRmFBVbq7d6TUbks5sD8qcgaJpZM4L1oIQ>
.
|
Yeah. Not from the BUILD file, though. |
@buchgr just found out that this bug report is a bit vague in that it doesn't mention which rule you're using. java_binary actually expands the runtime location, not the compile-time location in jvm_flags, but scala_binary doesn't. The ctx.expand_location Skylark method calls into the code path that expands the compile-time location, and is not configurable. Unfortunately, if we need a Skylark API change, then this becomes more complex to implement. :-/ |
I think I understand.
It sounds like from skylark (due to the lack of knob) $(location) always
works like $(rootpath)
…On Wed, 25 Oct 2017 at 15:46 Ulf Adams ***@***.***> wrote:
For example, say you have expansion/BUILD:
genrule(name = "foo", outs = ["foo.txt"], srcs = ["bar.txt"], cmd = "cp $< $@")
foo.txt:
execpath = bazel-out/darwin-fastbuild/bin/expansion/foo.txt
rootpath = expansion/foo.txt
bar.txt:
execpath = expansion/bar.txt
rootpath = expansion/bar.txt
The current $(location) function sometimes returns the exec path, and
sometimes returns the root-relative path, depending on how the expander is
configured (except you can't configure it through the skylark API, which
has no knob for that).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2475 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIF7pfPXr9UhTCqaIwzdZW6Sd-IfPiks5svy2QgaJpZM4L1oIQ>
.
|
Unfortunately there have been some delays due to travel and public holidays in Germany, as well as a commit gone wrong, which I had to revert. I'm currently rolling it forward again, and I have a few more changes on top of that, but they're not under review yet. It looks like we'll miss the 0.8.0 window, unfortunately. |
In addition to the $(location) function, we now also support $(rootpath) and $(execpath) functions. Unfortunately, we have to do this in two places since the Skylark API for expand_location has to continue calling into LocationExpander in order to preserve its semantic contract. Progress on #2475. RELNOTES[NEW]: In addition to $(location), Bazel now also supports $(rootpath) to obtain the root-relative path (i.e., for runfiles locations), and $(execpath) to obtain the exec path (i.e., for build-time locations) PiperOrigin-RevId: 174454119
When this does land - please also add testing for cross-workspace paths. If I use |
I'm seeing a similar failure when running Bazel |
Quick note that cross-workspace path tests were added in 702429b. |
`location` and `locations` are legacy functions. See bazelbuild/bazel#2475 (comment). Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> GitOrigin-RevId: 7daf8fdfd8e463652940dc2a3f3863f70aeebe09
`location` and `locations` are legacy functions. See bazelbuild/bazel#2475 (comment). Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> GitOrigin-RevId: 7daf8fdfd8e463652940dc2a3f3863f70aeebe09
`location` and `locations` are legacy functions. See bazelbuild/bazel#2475 (comment). Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> GitOrigin-RevId: 7daf8fdfd8e463652940dc2a3f3863f70aeebe09
`location` and `locations` are legacy functions. See bazelbuild/bazel#2475 (comment). Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> GitOrigin-RevId: 7daf8fdfd8e463652940dc2a3f3863f70aeebe09
`location` and `locations` are legacy functions. See bazelbuild/bazel#2475 (comment). Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> GitOrigin-RevId: 7daf8fdfd8e463652940dc2a3f3863f70aeebe09
A common point of confusion I see around `run_binary` is that it's hard coded to only expand `$(location` values which in codebases I work in are otherwise completely eliminated due to it being described as "legacy" > location: A synonym for either execpath or rootpath, depending on the attribute being expanded. This is legacy pre-Starlark behavior and not recommended unless you really know what it does for a particular rule. See [#2475](bazelbuild/bazel#2475 (comment)) for details. If `execpath` is used instead as the appropriate alternative, the rule does no do any expansion and fails the action. This change adds support for expanding all available patterns whenever they're provided.
We have a binary which requires the javac.jar be present in its bootclasspath. Prior to bazel 0.4.4, the following invocation worked (but was obviously less than ideal):
With bazel 0.4.4 the file name specific path has broken, as the actual file name of the target is now
javac-9-dev-r3297-1.jar
.Ideally, we'd be able to use
$(location @bazel_tools//third_party/java/jdk/langtools:javac_jar)
, however that expands toexternal/bazel_tools/third_party/java/jdk/langtools/javac-9-dev-r3297-1.jar
which is the build path and not the runtime path for that file. Needless to say, I'd like to avoid hard-coding another path which will break or fragile inline path-munging hacks. It seems like the correct answer is for$(location)
to use the runtime path when specified injvm_flags
.The text was updated successfully, but these errors were encountered: