-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
linuxManualConfig: install GDB scripts #221707
Conversation
77e993f
to
57ea2c5
Compare
Looks like we're still missing the GDB entry point (vmlinux-gdb.py). All the rest of the scripts are installed into the build directory in the modules path, but not that one. |
e5d7a8c
to
ca48963
Compare
We can avoid the need to explicitly exclude it later if we just put it somewhere else to begin with.
linux is unusual in that we include its sources in an output. There's no point unpacking into /build when we're going to copy the sources into $dev later. Let's unpack directly into the final destination of the code, and save copying a whole kernel source tree (often across filesystems!). This also means that Kbuild knows the location of the sources, which will allow us to install the GDB scripts — some scripts are generated, and some are not, so the generated ones end up in the build directory, accompanied by symlinks to the non-generated ones in the source directory.
We've basically been reimplementing this — by default it contains vmlinux, dtbs (on applicable architectures), modules, and architecture specific stuff like $(KBUILD_IMAGE) and a couple of other miscellaneous files.
These are required to debug kernel modules. Since we're now able to do that, there's another reason besides BTF to enable DEBUG_INFO, so I've done that for pre-BTF kernel modules as well here. For GDB to get configured correctly, vmlinux-gdb.py has to be two directories up from scripts/gdb, and vmlinux has to be next to vmlinux-gdb.py. The least invasive way to satisfy these constraints is to make vmlinux a symlink, which GDB will resolve before looking for vmlinux-gdb.py. Tested both ways of getting the scripts into GDB that I know of: gdb /nix/store/7n77ijlxkxr6d613h02lr707kvjx6j1k-linux-6.1.19-dev/vmlinux \ -iex 'add-auto-load-safe-path /nix/store/7n77ijlxkxr6d613h02lr707kvjx6j1k-linux-6.1.19-dev/lib/modules/6.1.19/build/vmlinux-gdb.py' \ -ex 'lx-version' \ -ex 'q' gdb /nix/store/7n77ijlxkxr6d613h02lr707kvjx6j1k-linux-6.1.19-dev/vmlinux \ -ex 'source /nix/store/7n77ijlxkxr6d613h02lr707kvjx6j1k-linux-6.1.19-dev/lib/modules/6.1.19/build/vmlinux-gdb.py' \ -ex 'lx-version' \ -ex 'q' Also tested that the strip changes don't result in meaningful output size changes (there's some small variation due to BTF data not always coming out the same size, which is unrelated), and built every kernel I can on x86_64 to make sure I'm not relying on build system behaviour specific to newer kernels.
ca48963
to
d57568f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's pretty nice, thank you :)
Might have been worth waiting to merge at the same time as some kernel updates to minimise rebuilds, but maybe it doesn't matter. |
I believe this broke
|
Also noticed: https://hydra.nixos.org/build/213443349
(edited the above references to point to a "more common" variant) |
There is a point. The point is not to have circular references in the outpaths, since Nix forbids that. This PR broke both powerpc and mips, and was incredibly frustrating to deal with because trying each fix requires a ~1hour build, and the end of which you get an unhelpful message from Nix about cycles so you need to inspect the failed build... but A much better strategy would have been to put the sources in their own separate output (either " |
"vmlinux" # for "perf" and things like that | ||
] ++ optional isModular "modules" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR inadvertently destroyed the ability to build a kernel without the modules, which is a much faster build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kernelConf.target | ||
"vmlinux" # for "perf" and things like that | ||
] ++ optional isModular "modules" | ||
++ optionals buildDTBs ["dtbs" "DTC_FLAGS=-@"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likewise with buildDTBs
…iple-outputs linuxManualConfig: revert #221707
Description of changes
linux is unusual in that we include its sources in an output. There's no point unpacking into /build when we're going to copy the sources into $dev later. Let's unpack directly into the final destination of the code, and save copying a whole kernel source tree (often across filesystems!).
This also means that Kbuild knows the location of the sources, which will allow us to install the GDB scripts — some scripts are generated, and some are not, so the generated ones end up in the build directory, accompanied by symlinks to the non-generated ones in the source directory.
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)