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

Fix handling of packages with clashing names #403

Merged
merged 1 commit into from
Aug 19, 2018
Merged

Conversation

mboes
Copy link
Member

@mboes mboes commented Aug 17, 2018

In #396, @guibou proposes to resolve #395 by making not just package
id's unique but also package names. That's a really big hammer, indeed
one that would cause collateral damage. Hazel would need to be
modified, because CPP macros generated by GHC would no longer be using
the names that upstream code pulled from Hackage expects. Also, the
names in Haddock would look worse.

Package names should not need to be unique. After all, that's the very
reason for the package-name / package-id distinction. It turns out
that the root cause for the original problem was very subtle, but very
simple to fix. The problem was that while we were passing
-hide-all-packages to GHC during compilation, we were not doing so
during linking. This flag makes sense, and indeed not passing it
causes bizarre module not found errors on import. It turns out that
not passing it at link time also causes the bizarre link errors we
were seeing (which only show up when two packages share the same
name).

I can't explain why -hide-all-packages, or lack thereof, has this
effect. But I do know that using the same flags during linking as
during compilation is the right thing to do. With this one line change
to the source code, we can continue to have arbitrary non-unique
package names, relying on package id's generated by rules_haskell
internally to be unique.

cc @guibou @Profpatsch @judah @lunaris

Closes #395.

Closes #396.

@mboes mboes requested a review from guibou August 17, 2018 14:12
@mboes mboes force-pushed the package-name-clash branch from 4ec0a25 to b01583f Compare August 17, 2018 14:23
@mboes
Copy link
Member Author

mboes commented Aug 17, 2018

Incidentally, this bug could have been avoided had we factored things out a bit more. Currently, compile.bzl computes its own set of package flags to pass to GHC, and then we do that twice more in link.bzl. This PR is a quick fix, but ultimately we should factor the flag computation to avoid a repeat of this kind of problem in the future.

@@ -124,6 +124,13 @@ def link_binary(

args.add(["-o", compile_output.path, dummy_static_lib.path])

# In compile.bzl, we pass this just before all -package-id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be copy pasted in front of all similar lines. This will motivate us to factorise and document more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a reference. Duplication in comments is worse than in code, because comments are not checked.

Package names should not need to be unique. After all, that's the very
reason for the package-name / package-id distinction. It turns out
that the root cause for the original problem was very subtle, but very
simple to fix. The problem was that while we were passing
`-hide-all-packages` to GHC during compilation, we were not doing so
during linking. This flag makes sense, and indeed not passing it
causes bizarre `module not found` errors on import. It turns out that
not passing it at link time also causes the bizarre link errors we
were seeing (which only show up when two packages share the same
name).

I can't explain why `-hide-all-packages`, or lack thereof, has this
effect. But I do know that using the same flags during linking as
during compilation is the right thing to do. With this one line change
to the source code, we can continue to have arbitrary non-unique
package names, relying on package id's generated by rules_haskell
internally to be unique.

Closes #395.

Closes #396.
@mboes mboes force-pushed the package-name-clash branch from b01583f to 44eab16 Compare August 19, 2018 09:51
@mboes mboes merged commit 9dc9593 into master Aug 19, 2018
@mboes mboes deleted the package-name-clash branch August 19, 2018 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Link issue when deps contains two rules with the same prefix
2 participants