nix develop, but not nix-shell, breaks cc-wrapper's handling of spaces in file paths #311

Open
opened 2024-05-13 04:20:54 +00:00 by qyriad · 1 comment
Owner

Yes really.

$ git clone https://github.com/Qyriad/Xil '/tmp/Xil Project' && cd '/tmp/Xil Project'
$ nix develop
[nix-shell] $ NIX_DEBUG=1 mesonConfigurePhase
mesonConfigurePhase flags: --prefix=/tmp/Xil\ Project/outputs/out --libdir=/tmp/Xil\ Project/outputs/out/lib --libexecdir=/tmp/Xil\ Project/outputs/out/libexec --bindir=/tmp/Xil\ Project/outputs/out/bin --sbindir=/tmp/Xil\ Project/outputs/out/sbin --includedir=/tmp/Xil\ Project/outputs/out/include --mandir=/tmp/Xil\ Project/outputs/out/share/man --infodir=/tmp/Xil\ Project/outputs/out/share/info --localedir=/tmp/Xil\ Project/outputs/out/share/locale -Dauto_features=enabled -Dwrap_mode=nodownload --buildtype=plain
The Meson build system
Version: 1.3.2
Source dir: /tmp/Xil Project
Build dir: /tmp/Xil Project/build
Build type: native build
Project name: xil
Project version: 0.0.1

meson.build:1:0: ERROR: Compiler g++ cannot compile programs.

A full log can be found at /tmp/Xil Project/build/meson-logs/meson-log.txt

In Meson's log, looking for ld's invocation we get:

HARDENING: disabled flags: pie
HARDENING: Is active (not completely disabled with "all" flag)
HARDENING: enabling relro
HARDENING: enabling bindnow
extra flags before to /nix/store/bczmlm8brs93gp4lscwvc1dnn2ipymnc-binutils-2.41/bin/ld:
  -z
  relro
  -z
  now
  -dynamic-linker
  /nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib/ld-linux-x86-64.so.2
original flags to /nix/store/bczmlm8brs93gp4lscwvc1dnn2ipymnc-binutils-2.41/bin/ld:
  -plugin
  /nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/libexec/gcc/x86_64-unknown-linux-gnu/13.2.0/liblto_plugin.so
  -plugin-opt=/nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/libexec/gcc/x86_64-unknown-linux-gnu/13.2.0/lto-wrapper
  -plugin-opt=-fresolution=/tmp/nix-shell.FTsYpA/ccER8Itu.res
  -plugin-opt=-pass-through=-lgcc_s
  -plugin-opt=-pass-through=-lgcc
  -plugin-opt=-pass-through=-lc
  -plugin-opt=-pass-through=-lgcc_s
  -plugin-opt=-pass-through=-lgcc
  --eh-frame-hdr
  -m
  elf_x86_64
  -dynamic-linker
  /nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib64/ld-linux-x86-64.so.2
  /nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib/crt1.o
  /nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib/crti.o
  /nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/crtbegin.o
  -L/nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib
  -L/nix/store/pp0jsd045xvfsz60kpbkfxbs9pbpk8z5-gcc-13.2.0-lib/lib
  -L/nix/store/qhpw32pz39y6i30b3vrbw5fw6zv5549f-gcc-wrapper-13.2.0/bin
  -L/nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0
  -L/nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../../lib64
  -L/nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../..
  --version
  -lstdc++
  -lm
  -lgcc_s
  -lgcc
  -lc
  -lgcc_s
  -lgcc
  /nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/crtend.o
  /nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib/crtn.o
extra flags after to /nix/store/bczmlm8brs93gp4lscwvc1dnn2ipymnc-binutils-2.41/bin/ld:
  -rpath
  /tmp/Xil
  Project/outputs/out/lib
  -L/nix/store/5ihiijqihp3v2a2swbjjq09agaiv9dfa-boehm-gc-8.2.4/lib
  -L/nix/store/cs41wvvf98zsgw7vbpfabj5f8d2y0ihz-nix-2.18.2/lib
  -L/nix/store/c63xr9j66kihn2k6s8l1495zg4pb4i5v-fmt-10.2.1/lib
  -L/nix/store/0h6f13q3fnzmkv3iwgajm8x6r1rjijnv-boost-1.81.0/lib
  -L/nix/store/5ihiijqihp3v2a2swbjjq09agaiv9dfa-boehm-gc-8.2.4/lib
  -L/nix/store/cs41wvvf98zsgw7vbpfabj5f8d2y0ihz-nix-2.18.2/lib
  -L/nix/store/c63xr9j66kihn2k6s8l1495zg4pb4i5v-fmt-10.2.1/lib
  -L/nix/store/0h6f13q3fnzmkv3iwgajm8x6r1rjijnv-boost-1.81.0/lib
  -L/nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib
  -L/nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0
  -L/nix/store/pp0jsd045xvfsz60kpbkfxbs9pbpk8z5-gcc-13.2.0-lib/lib
  -L/nix/store/pp0jsd045xvfsz60kpbkfxbs9pbpk8z5-gcc-13.2.0-lib/lib
  -rpath
  /nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib
  -rpath
  /nix/store/pp0jsd045xvfsz60kpbkfxbs9pbpk8z5-gcc-13.2.0-lib/lib

-rpath
/tmp/Xil
Project/outputs/out/lib

fuck me.

The g++ invocation has something similar, of course:

  -isystem
  /nix/store/1snh9vfafl7dgryqnaqyy6s1g5sqgal4-argparse-3.0/include
  -Wl\,-rpath
  -Wl\,/tmp/Xil
  -Wl\,Project/outputs/out/lib
  -L/nix/store/5ihiijqihp3v2a2swbjjq09agaiv9dfa-boehm-gc-8.2.4/lib
  -L/nix/store/cs41wvvf98zsgw7vbpfabj5f8d2y0ihz-nix-2.18.2/lib

But in nix-shell, everything works just fine.

And contrary to what we::Qyriad thought, this isn't a generic bug in Nixpkgs' cc-wrapper that nix-shell is unbreaking:

$ nix build --option build-sandbox-dir '/build space/' 'github:Qyriad/Xil'

works just fine.


See also: https://github.com/NixOS/nixpkgs/issues/177952

Yes really. ```bash $ git clone https://github.com/Qyriad/Xil '/tmp/Xil Project' && cd '/tmp/Xil Project' $ nix develop [nix-shell] $ NIX_DEBUG=1 mesonConfigurePhase mesonConfigurePhase flags: --prefix=/tmp/Xil\ Project/outputs/out --libdir=/tmp/Xil\ Project/outputs/out/lib --libexecdir=/tmp/Xil\ Project/outputs/out/libexec --bindir=/tmp/Xil\ Project/outputs/out/bin --sbindir=/tmp/Xil\ Project/outputs/out/sbin --includedir=/tmp/Xil\ Project/outputs/out/include --mandir=/tmp/Xil\ Project/outputs/out/share/man --infodir=/tmp/Xil\ Project/outputs/out/share/info --localedir=/tmp/Xil\ Project/outputs/out/share/locale -Dauto_features=enabled -Dwrap_mode=nodownload --buildtype=plain The Meson build system Version: 1.3.2 Source dir: /tmp/Xil Project Build dir: /tmp/Xil Project/build Build type: native build Project name: xil Project version: 0.0.1 meson.build:1:0: ERROR: Compiler g++ cannot compile programs. A full log can be found at /tmp/Xil Project/build/meson-logs/meson-log.txt ``` In Meson's log, looking for ld's invocation we get: ``` HARDENING: disabled flags: pie HARDENING: Is active (not completely disabled with "all" flag) HARDENING: enabling relro HARDENING: enabling bindnow extra flags before to /nix/store/bczmlm8brs93gp4lscwvc1dnn2ipymnc-binutils-2.41/bin/ld: -z relro -z now -dynamic-linker /nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib/ld-linux-x86-64.so.2 original flags to /nix/store/bczmlm8brs93gp4lscwvc1dnn2ipymnc-binutils-2.41/bin/ld: -plugin /nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/libexec/gcc/x86_64-unknown-linux-gnu/13.2.0/liblto_plugin.so -plugin-opt=/nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/libexec/gcc/x86_64-unknown-linux-gnu/13.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/nix-shell.FTsYpA/ccER8Itu.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --eh-frame-hdr -m elf_x86_64 -dynamic-linker /nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib64/ld-linux-x86-64.so.2 /nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib/crt1.o /nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib/crti.o /nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/crtbegin.o -L/nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib -L/nix/store/pp0jsd045xvfsz60kpbkfxbs9pbpk8z5-gcc-13.2.0-lib/lib -L/nix/store/qhpw32pz39y6i30b3vrbw5fw6zv5549f-gcc-wrapper-13.2.0/bin -L/nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0 -L/nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../../lib64 -L/nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../.. --version -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/crtend.o /nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib/crtn.o extra flags after to /nix/store/bczmlm8brs93gp4lscwvc1dnn2ipymnc-binutils-2.41/bin/ld: -rpath /tmp/Xil Project/outputs/out/lib -L/nix/store/5ihiijqihp3v2a2swbjjq09agaiv9dfa-boehm-gc-8.2.4/lib -L/nix/store/cs41wvvf98zsgw7vbpfabj5f8d2y0ihz-nix-2.18.2/lib -L/nix/store/c63xr9j66kihn2k6s8l1495zg4pb4i5v-fmt-10.2.1/lib -L/nix/store/0h6f13q3fnzmkv3iwgajm8x6r1rjijnv-boost-1.81.0/lib -L/nix/store/5ihiijqihp3v2a2swbjjq09agaiv9dfa-boehm-gc-8.2.4/lib -L/nix/store/cs41wvvf98zsgw7vbpfabj5f8d2y0ihz-nix-2.18.2/lib -L/nix/store/c63xr9j66kihn2k6s8l1495zg4pb4i5v-fmt-10.2.1/lib -L/nix/store/0h6f13q3fnzmkv3iwgajm8x6r1rjijnv-boost-1.81.0/lib -L/nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib -L/nix/store/7vc88ixc6yca2hwgszjk51dh23j3g2nr-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0 -L/nix/store/pp0jsd045xvfsz60kpbkfxbs9pbpk8z5-gcc-13.2.0-lib/lib -L/nix/store/pp0jsd045xvfsz60kpbkfxbs9pbpk8z5-gcc-13.2.0-lib/lib -rpath /nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib -rpath /nix/store/pp0jsd045xvfsz60kpbkfxbs9pbpk8z5-gcc-13.2.0-lib/lib ``` > -rpath > /tmp/Xil > Project/outputs/out/lib fuck me. The g++ invocation has something similar, of course: ``` -isystem /nix/store/1snh9vfafl7dgryqnaqyy6s1g5sqgal4-argparse-3.0/include -Wl\,-rpath -Wl\,/tmp/Xil -Wl\,Project/outputs/out/lib -L/nix/store/5ihiijqihp3v2a2swbjjq09agaiv9dfa-boehm-gc-8.2.4/lib -L/nix/store/cs41wvvf98zsgw7vbpfabj5f8d2y0ihz-nix-2.18.2/lib ``` But in `nix-shell`, everything works just fine. And contrary to what we::Qyriad thought, this isn't a generic bug in Nixpkgs' cc-wrapper that `nix-shell` is *un*breaking: ```bash $ nix build --option build-sandbox-dir '/build space/' 'github:Qyriad/Xil' ``` works just fine. --- See also: https://github.com/NixOS/nixpkgs/issues/177952
qyriad added the
stability
bug
labels 2024-05-13 04:20:54 +00:00
Owner

Fixing this is (imo) likely to be impossible, without rethinking massively how nix develop works.

The bug here is: Each output of the derivation used as baseline for develop is replaced, from /nix/store/eeeeeeeeee[..]eeee-xil to /tmp/Xil Project/outputs/out, etc. However, it's not possible for Nix itself to know whether the output was already quoted, if it should be quoted, or if something else is going on with it.

Fixing this is (imo) likely to be impossible, without rethinking massively how `nix develop` works. The bug here is: Each output of the derivation used as baseline for `develop` is replaced, from `/nix/store/eeeeeeeeee[..]eeee-xil` to `/tmp/Xil Project/outputs/out`, etc. However, it's not possible for Nix itself to know whether the output was already quoted, if it should be quoted, or if something else is going on with it.
qyriad added the
E/hard
label 2024-05-15 18:24:24 +00:00
raito pinned this 2024-05-19 18:20:48 +00:00
raito unpinned this 2024-05-19 18:20:51 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#311
No description provided.