fixLibtool(): replace /usr/bin/file in ./configure, add file to common-path.nix#168413
Conversation
Thank you thank you thank you!!!! We should have a bootstrap for mips64el very soon now. Thank you again! |
As requested here: #168413 (review)
|
Shit is it writing `FILECMD=/definitely/evil/bin/file` as a hard coded path
into people's source tarballs?
If it is let me know so I can patch.
Or is the issue that `libtoolize` now requires the runtime `coreutils`
store path to match the one used to build `libtool`?
…On Sun, May 29, 2022, 2:34 PM Adam Joseph ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pkgs/stdenv/common-path.nix
<#168413 (comment)>:
> @@ -12,4 +12,12 @@
pkgs.bash
pkgs.patch
pkgs.xz.bin
+
+ # The `file` command is added here because an enormous number of
+ # packages have a vendored dependency upon `file` in their
+ # `./configure` script, due to libtool<=2.4.6, or due to
+ # libtool>=2.4.7 in which the package author decided to set FILECMD
+ # when running libtoolize. In fact, file-5.4.6 *depends on itself*
+ # and tries to invoke `file` from its own ./configure script.
+ pkgs.file
a comment like
https://github.com/NixOS/nixpkgs/blob/89a3d054790bbcf6c9d73394cd1c541466c5a7c8/pkgs/tools/compression/gzip/default.nix#L7-L10
should be added to file.
#175343 <#175343>
—
Reply to this email directly, view it on GitHub
<#168413 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA3ORYTVY5MMOEL35YENJOLVMPBFPANCNFSM5TIUO2GQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Oh jesus, the bootstrap paradox of `file` needing `file` is fun.
We'll resolve this, but honestly I might rewrite `magiccmd` ( the reason
`file` is needed ) to use `read` to check file magic to avoid this whole
mess:
```
# Test if a file is an AR archive.
function isAR() {
local fn="$1"
local fd
local magic
exec {fd}<"$fn"
# In Zsh `read -k NUM' behaves like Bash's `read -n NUM'.
if test "${ZSH_VERSION+set}" = set; then
read -r -k 7 -u "$fd" magic
else
read -r -n 7 -u "$fd" magic
fi
read -r -n 7 -u "$fd" magic
exec {fd}<&-
# First seven characters should be "!<arch>"
if test "$magic" = $'\041\074arch\076'; then return 0; else return 1; fi
}
```
|
AIUI it is already patched, but we need a workaround for tarballs generated with older libtool versions. |
|
@aakropotkin, thank you again so much for fixing the upstream issue in libtool. Let's be honest, this PR (#168413) is basically a hack. Thanks to your work on libtool we will be able to revert this hack ~3-4 years from now instead of infinitely-many years from now.
I believe you are referring to my comment upthread about other failure modes, where I wrote:
I swear that I experienced However there are still some hardcoded Perhaps those don't matter.
:)
That would be wonderful. You'll need a bit more than the four "magic" bytes, but not much. Reading the first nine bytes will give you the CPU, endianness, and ABI, which should be enough: |
|
If file is now in stdenv does this mean that it can be removed from mingw stdenv/cross? |
|
Worth a try |
Yes. Thanks for noticing this. I will take the blame if removing it breaks the world: #176597 Side question: are there any tools to make it easier to trace the provenance of a line of code using |
|
i have this alias |
|
Bisect claims that 97c4382 |
I am investigating. Don't hesitate to revert this if it's blocking other people's progress. You can expect a more detailed response from me within the next 12 hours (likely much sooner than that). |
|
Bisect claims |
Ugh, this is another case of a package fooling Notice the special requirement on the number of |
|
This thread has grown quite a bit, and I'll admit I've fallen behind on reading it. If there's any issues that could or should be resolved upstream in I'm sure there's a mix of "old builds broke because of issues in their usage" vs "the |
You can unsubscribe if you want. I will ping @aakropotkin if anything comes up that needs upstream action, but I doubt that it will. Thank you again very much for adding |
|
I wrote it so that you can either autoreconf or `export FILECMD="$( command
command -v file:)"` IIRC. Let me know if that's not the case.
…On Thu, May 26, 2022, 1:37 AM Rick van Schijndel ***@***.***> wrote:
I'm okay with the workaround for now, autoreconf-ing is probably a pain to
do for all packages.
In general it's good to have this to improve exotic platform support and
to have better cross-compilation support from more rare platforms.
—
Reply to this email directly, view it on GitHub
<#168413 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA3ORYQ3UMM2UNKVBL3QS5DVL4L2VANCNFSM5TIUO2GQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
This is a much cleaner replacement for #166879, but it will cause everything to rebuild.
Description of changes
libtool's
libtool.m4script assumes thatfileis available, and can be found at/usr/bin/file(this path is hardwired). Furthermore, this script is vendored into the./configurescripts of an enormous number of packages. Without this PR, you will frequently see errors like this during theconfigurePhasewhen the sandbox is enabled:Due mostly to luck, this error does not affect native compiles on nixpkgs' two most popular platforms,
x86_64-linuxandaarch64-linux. However it will cause incorrect linker flag detection and a failure to generate shared libraries for sandboxed cross-builds to ax86_64-linuxhost as well as any sandboxed build (cross or native) for the following hosts:x86_64-freebsd,*-hpux,*-irix,mips64*-linux,powerpc*-linux,s390x-linux,s390x-tpf,sparc-linux, and*-solaris.This PR fixes the problem by adding an extra line to the
if-block which callsfixLibtool()inpkgs/stdenv/generic/setup.sh. This extra line will scan the unpacked source code for executable files namedconfigurewhich contain the following text:This text is taken to be an indicator of a vendored
libtool.m4. When it is found, the configure script containing it is subjected tosed -i s_/usr/bin/file_file_which replaces all occurrences of/usr/bin/filewithfile, and the mtime of the file is preserved across this replacement.Additionally, the
filepackage is now considered to be part ofstdenv. It has been added tocommon-path.nixso that thefilebinary will be found in the$PATHof every build, except for the bootstrap-tools and the first few stages of stdenv boostrapping.Verified no regressions under:
This commit allows the following commands to complete, which should enable Hydra to produce bootstrap-files for mips64el:
CC: @sternenseemann, @SuperSandro2000
Things done
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)