-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
proc_macro::__internal::with_parse_sess() called before set_parse_sess() #39870
Comments
Something changed since I touched this file. I added a message to that |
Your message is in 1.16.0-beta. The panic is from 1.15.1. Any idea how this assert could be failing? |
I'd have to look at the sources that Homebrew Rust used, apparently. |
This doesn't sound like a bug with either serde or the compiler but rather an error in some form of a binary artifact. At first blush this looks like the compiler is running with one I'm installing Homebrew rust to investigate what's going on. |
Ah yes, that is indeed the bug. Here's what's happening. So when you install Rust you actually get two copies of libraries. For example you'll have both:
Both of these should be byte-for-byte identical, we actually copy them in the build system! When you link against a dynamic library on OSX the library itself encodes a name of how to find it in the future by default. We can inspect this for rustup via the
What this says is basically "in the future, find my by looking at
Aha, a difference! I believe this is something that homebrew does by default, changing the value of This change in
whereas for Homebrew we'll see:
So I think there's two bugs here:
|
cc #28640, more info about the internals here |
Would this setup without rpath would work correctly if the homebrew build maintained the property that the two libs directories are identical? (It doesn't seem proper to require rpath for rust to work correctly). |
Excellent investigation @alexcrichton. Thanks. |
cc @ilovezfs and @alex, I've seen you two updating the Rust formula over at Homebrew/homebrew-core so I was hoping you'd be able to help me with a question. In my comment above I've noticed that a Homebrew-installed version of Rust (specifically installed from a bottle) has a different Do you know if it's correct if Homebrew uses I'm currently installing from source to verify it's not a bottle problem, but that may take a few minutes! |
Unfortunately I can't really help. I'm an unsophisticated person who just increments version numbers and computes hashes. |
@alexcrichton it's actually ruby-macho not install_name_tool, but yes you have the right idea about what's happening. Some manual interventions are also possible (see Homebrew/homebrew-core#8049 for examples). The main reason the paths get changed is so that they use the It might be possible to fix the breakage in CC @woodruffw who knows the most about our use of ruby-macho for thoughts here. |
Ok cool, thanks for the info @ilovezfs! I think here what should happen is that libraries the If I can finagle that locally does that sounds like a reasonable patch? |
Whatever actually works should be fine at least temporarily, but it would be good to get the fixes into rust or https://github.com/Homebrew/brew or some combination both if possible since manual uses of ruby-macho in homebrew/core are pretty yuck. |
BTW the magic mostly happens here: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/extend/os/mac/keg_relocate.rb |
Fantastic work figuring this out @alexcrichton, and thanks @dtolnay for posting the issue. |
Thanks for pinging me in @ilovezfs. I think the bug is in our (i.e., Homebrew's) handing of dylib IDs - we're careful not to clobber metavariables like |
Patching Homebrew with this fixed the rewriting of diff --git a/Library/Homebrew/extend/os/mac/keg_relocate.rb b/Library/Homebrew/extend/os/mac/keg_relocate.rb
index f44a97b31..476e5da4a 100644
--- a/Library/Homebrew/extend/os/mac/keg_relocate.rb
+++ b/Library/Homebrew/extend/os/mac/keg_relocate.rb
@@ -78,13 +78,19 @@ class Keg
end
end
+ def filename_contains_metavariable?(fn)
+ fn =~ /^@(loader_|executable_|r)path/
+ end
+
def each_install_name_for(file, &block)
dylibs = file.dynamically_linked_libraries
- dylibs.reject! { |fn| fn =~ /^@(loader_|executable_|r)path/ }
+ dylibs.reject! { |fn| filename_contains_metavariable?(fn) }
dylibs.each(&block)
end
def dylib_id_for(file)
+ return file.dylib_id if filename_contains_metavariable?(file.dylib_id)
+
# The new dylib ID should have the same basename as the old dylib ID, not
# the basename of the file itself.
basename = File.basename(file.dylib_id) |
The patch above looks correct to me, but I'm not sure why we (again, Homebrew) weren't skipping dylib ID rewriting under those cases before. cc @UniqMartin for an opinion (sorry for bringing you out of retirement) |
Oh wow thanks for the quick patch @woodruffw! I'm testing that out locally. If you've got a compiler on hand though an easy way to test is to clone https://github.com/alexcrichton/toml-rs and run |
Thanks @alexcrichton, I'll test that out! |
Seems to have worked!
|
Excellent! Sorry I've been slow at verifying this morning, had a few false starts for various reasons building rustc. Would the next steps here be a PR to Homebrew? @woodruffw would you be willing to do so? |
Yep, and yep. I'm going to do some more local testing to ensure that this doesn't cause breakage in other packages, but I'll create a brew PR soon. As you mentioned in #39870 (comment), it'd be good to have this fixed upstream as well 😄 |
Opened as Homebrew/brew#2036. |
Awesome, thanks @woodruffw! |
Homebrew/brew now has the fix, and Homebrew/homebrew-core#10198 will bump rust to apply it to the bottles. |
Those reasons make sense; I'm surprised we didn't have more troubles when we merged Homebrew/brew#2036 😄 |
So @alexreg and I are looking to add Homebrew support to Tectonic, but we've run into this issue. Does anyone know if there are ways to work around this (or plans to re-patch "Homebrew Rust")? |
@ilovezfs Since the rust formula is essentially broken, wouldn't be better to either temporarily remove it or add a huge warning to the caveats section? |
As an outsider who doesn't know why rust ships two identical dylibs or why brew has to fiddle with dylib references it seems to me that both upstream (rust) and downstream (brew) are doing something wrong, to varying degrees. But... I don't understand Homebrew's insistence in shipping a clearly broken formula/bottle without printing a huge warning that it's broken. This led me to waste a couple of hours trying to figure out what was wrong with the compiler. Judging from comments elsewhere this seems to be impacting other people. My humble suggestion is to either:
Let me know how you wish to proceed, I'd like to spare other people the frustration caused by this particular issue. |
Neither of those is going to happen. |
Just to explain this: Since brew installs software in its own prefix, we need to rewrite binaries to find their libraries, dependencies, and resources correctly. The details aren't all that important, but it's an essential part of the installation process. |
Hey @alexcrichton, Homebrew/brew#2764 has the changes to temporarily work around this problem in Homebrew. It's based on your observation in #39870 (comment) that only the binaries We'd still like to get this fixed more permanently by de-duplicating these libraries, but could you give this a look over/some testing? @ilovezfs and I have tested 1.17.0 and 1.18.0 (I ran |
Thanks for working on this @woodruffw! I was about to submit a simple test case and a patch to add a "caveats" section to the formula but I'm glad they won't be necessary anymore. 🎉 |
Sounds good! If we can get this accepted to Homebrew, it will really make things a lot easier for creators of Rust-based formulas like @iKevinY and me. |
@alexcrichton A new workaround for this issue and #39875 is now in Homebrew: Homebrew/homebrew-core#14490 thanks to @woodruffw.
|
Thanks for the updates here @ilovezfs and @woodruffw! Sorry I was on vacation this past weekend but both those fixes look good to me! Thanks so much for getting Rust on Homebrew working! |
@alexcrichton Thanks for the kind words! Our fix is a temporary measure though and not one we want to maintain long-term. Would an upstream fix on your end be possible? If so, what might the (extremely, extremely) vague timescale be? Thanks! |
Unfortunately I wouldn't have a great estimate of that. I've opened #42645 to track work on that specifically but it's likely to remain open until someone motivated comes along to fix it. To that end I've tagged it as a help wanted issue! It looks though like this issue is itself fixed due to the hack now present in Homebrew. In light of that the more relevant issue now is #42645 so I'm going to close this in favor of that one. Fixing #42645 would solve this issue as well and also allow the Homebrew hack to be removed. |
serde-rs/serde#764 and alacritty/alacritty#413 both have this assertion failing. Is this a bug in rustc or in our use of libproc_macro?
cc @abonander and @alexcrichton who own most of that file
cc @jwilm who is debugging alacritty/alacritty#413
The text was updated successfully, but these errors were encountered: