| 20 Feb 2025 |
John Ericson | (the /nix in the pkg-config is definitely bad) | 00:35:04 |
John Ericson | * (the /nix in the *.pc is definitely bad) | 00:35:14 |
emily | I'm honestly surprised if #include "b.h" works to find y/include/foo/b.h from x/include/foo/a.h even if both are on the include path | 00:36:45 |
emily | but if it does then I guess it's fine | 00:36:48 |
John Ericson | I am not sure that works | 00:43:18 |
John Ericson | there is just the sibling even if not in same path rule | 00:43:34 |
John Ericson | * there is just the sibling even if on directly on the path rule | 00:43:44 |
emily | then I'm not sure how ^ ever works | 00:47:10 |
John Ericson | emily: that's because -I.../nix in the pkg-config` | 01:38:14 |
John Ericson | and also the meson build time C flags | 01:38:24 |
John Ericson | * and also the meson when building Nix itself C flags | 01:38:37 |
Mic92 | In reply to @Ericson2314:matrix.org emily: that's because -I.../nix in the pkg-config` Could we not extend cflags in our pc files to include those conf headers? | 02:39:13 |
Mic92 | Than other projects don't need to do the same | 02:39:54 |
Mic92 | * Than other projects don't need anything except for using pc files | 02:41:00 |
Mic92 | I remember having subtle runtime crashes rather than build errors when I did forget one of the includes | 02:42:01 |
flokli | Lovely | 03:23:19 |
John Ericson | Mic92: yeah we can do that | 03:28:00 |
John Ericson | that is definitely better than the status quo | 03:28:06 |
John Ericson | even if it is less than the ideal thing | 03:28:14 |
John Ericson | Eelco: Can you review https://github.com/NixOS/nix/pull/12531 ? | 18:30:20 |
John Ericson | The most interesting part is IMO the symlink resolution bits | 18:31:57 |
emily | Robert Hensing (roberth): John Ericson: after further experimentation I continue to believe that the Nix 2.26 componentized build is broken as a library:
yuyuko:/v/f/y/m/T/tmp.IYaTKFuZIs
❭ mkdir -p {a,b}/nix
yuyuko:/v/f/y/m/T/tmp.IYaTKFuZIs
❭ echo '#include "y.h"' >a/nix/x.h
yuyuko:/v/f/y/m/T/tmp.IYaTKFuZIs
❭ echo '#error worked' >b/nix/y.h
yuyuko:/v/f/y/m/T/tmp.IYaTKFuZIs
❭ echo '#include <nix/x.h>' >test.c
yuyuko:/v/f/y/m/T/tmp.IYaTKFuZIs
❭ clang -Ia -Ib test.c
In file included from test.c:1:
a/nix/x.h:1:10: fatal error: 'y.h' file not found
1 | #include "y.h"
| ^~~~~
1 error generated.
nix/shared.hh in nix-main has #include "path.hh", which is nix/path.hh in nix-store. I'm using inputs.nix.packages.${final.stdenv.hostPlatform.system}.default direct from the flake so there's nothing from the Nixpkgs packaging or the split library packages interfering here.
the .pc files specify -I…/nix as a compiler flag directly, which does make it work:
yuyuko:/v/f/y/m/T/tmp.IYaTKFuZIs
❭ echo '#include "x.h"' >test.c
yuyuko:/v/f/y/m/T/tmp.IYaTKFuZIs
❭ clang -Ia/nix -Ib/nix test.c
In file included from test.c:1:
In file included from a/nix/x.h:1:
b/nix/y.h:1:2: error: worked
1 | #error worked
| ^
1 error generated.
but this implies that (a) all code that previously used #include <nix/foo.hh> is broken, and (b) you can't use Nix as a library without it polluting your include namespace with names as generic as "hash.hh", "path.hh", and "shared.hh". AFAICT Hydra just lives with that. that seems like it's both bad and a substantial regression? I think that the -I…/nix thing should not be part of the upstream .pc files but in any case I don't think the headers should depend on that out-of-band configuration to have correct interdependent #includes at all
| 18:36:06 |
John Ericson | emily: I agree that nix/ should work downstream | 18:37:07 |
John Ericson | here is what I am thinking we should do | 18:37:14 |
John Ericson | src/lib<blah>/nix -> .. symlink | 18:37:30 |
John Ericson | and then make all our headers do #include "nix/*" | 18:37:53 |
John Ericson | and make the PC files not have the /nix | 18:38:14 |
John Ericson | that solution avoids moving source files around, which will make Eelco happy. (More seriously, it will keep the headers next to their corresponding sources, which he said he likes) | 18:38:44 |
emily | why can't you just do #include <nix/…> in the headers, have src/lib<blah>/include/nix be where the headers are, and add the built lib<blah>s as normal Meson dependencies? | 18:39:02 |
emily | I don't think you need any symlink hacks to make that work | 18:39:07 |