write_env_script / env_script_all_files wrappers don't pass argv[0]
#7086
Replies: 2 comments 1 reply
|
Hello there! Really impressive investigation into how the wrapper scripts ended up breaking Firefox's build! Tracing that through moz.configure down to argv[0] handling is awesome work. I was testing the proposed Whenever the OS kernel executes a file with a shebang ( Because of that:
The only reason it worked in 1.28.2 was because the tools were direct symlinks to a compiled Mach-O binary ( Since any shell script wrapper will hit this same kernel limitation, the cleanest way forward for
Hope this helps save some back-and-forth debugging time! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Output of
brew configOutput of
brew doctorDescription of issue
While this issue affects the
rustupformula, I think the cause of the issue is Homebrew itself, and may be affecting other formulae. Fixing it in Homebrew will require a rebuild of every formula that callsenv_script_all_filesorwrite_env_script.rustupprovides a set of "proxy binaries", which allow it to select between (potentially multiple) Rust toolchains. Using the upstream builds ofrustup, there are symlinks from Rust tools (eg:cargo,rustc,rustdoc) torustup, which it then dispatches to the actual binaries.Homebrew/homebrew-core#281103 changed
rustup's wrapper scripts from being ordinary symlinks towrite_env_scriptwrappers (viaenv_script_all_files), in order to set an additional environment variable:Unfortunately, these wrappers are not entirely equivalent, because they don't propagate
argv[0]:The error messages above are the same as you'd get calling
rustc which rustc, rather thanrustup which rustc.That change broke building Firefox from source, as if its build system detects
cargoand/orrustcarerustupwrappers, it tries to resolve the actual binaries (to fix other build problems triggered byrustup's wrappers) by calling them withargv[0] = "rustup".When
rustup's wrappers are ordinary symlinks (as is the case with upstreamrustup), this works fine. But it doesn't work withwrite_env_scriptwrappers.I've already written a workaround for Firefox to look for an adjacent
rustupbinary tocargoandrustcbinaries if calling them asrustupfails, but this isn't ideal. Firefox's build system doesn't need to know where "actualrustup" is, unlesscargoand/orrustcarerustupwrappers, and those wrappers can't be called withargv[0] = 'rustup'.(broken) fix
This is broken, because
$0isn't actuallyargv[0], so it doesn't pass it properly.write_env_fileneeds to also add-a "$0"to itsexeccall, in order to be fully equivalent with calling the binary directly.For example, a fixed wrapper for
/bin/catwould look like:With
-a "$0", calling./fake-cat --helpreturns:Without
-a "$0"(as is current behaviour), calling./fake-cat --helpreturns:This will require rebuilding every formula that calls
env_script_all_filesorwrite_env_script.All reactions