-
Notifications
You must be signed in to change notification settings - Fork 80
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
Do not use File objects in dictionary keys #1545
Conversation
Tested with Bazel@HEAD: https://buildkite.com/bazel/rules-haskell-haskell/builds/725 |
@@ -241,13 +241,17 @@ def create_link_config(hs, posix, cc_libraries_info, libraries_to_link, binary, | |||
|
|||
return (cache_file, static_libs, dynamic_libs) | |||
|
|||
def _path_or_none(f): | |||
if f != None: | |||
return f.path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could go as a local definition inside of cc_library_key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, this is not allowed in Bazel 4.0.0:
ERROR: /home/runner/.cache/bazel/_bazel_runner/3e6d0af2c61b2bb9852d7167e763fc51/external/rules_haskell/haskell/private/cc_libraries.bzl:247:5: nested functions are not allowed. Move the function to the top level.
ERROR: error loading package '': in /home/runner/.cache/bazel/_bazel_runner/3e6d0af2c61b2bb9852d7167e763fc51/external/rules_haskell/haskell/cabal.bzl: Extension 'haskell/private/cc_libraries.bzl' has errors
It seems to be allowed in Bazel HEAD though, the change worked when tested with USE_BAZEL_VERSION="last_green"
.
b198412
to
6fbb1a7
Compare
Encountered an issue with BES on Windows:
Possibly related to bazelbuild/bazel#12575. Retrying... |
The function `cc_library_key` generates the dictionary keys by which `LibLibraryToLink` are mapped to their corresponding `HaskellCcLibraryInfo`. Before this used a `struct` over `None` or `File` objects. This changes uses `None` or `string` instead, where `string` is the `.path` attribute of the `File` object. Using a `File` object in a dictionary key fails if the `File` object used at lookup time is semantically the same, but has a different identity due to implementation details in Bazel. Closes #1536
6fbb1a7
to
facef80
Compare
The function
cc_library_key
generates the dictionary keys by whichLibLibraryToLink
are mapped to their correspondingHaskellCcLibraryInfo
. Before this used astruct
overNone
orFile
objects. This changes usesNone
orstring
instead, wherestring
is the.path
attribute of theFile
object.Using a
File
object in a dictionary key fails if theFile
object used at lookup time is semantically the same, but has a different identity due to implementation details in Bazel.Closes #1536