dicksites / KUtrace

Low-overhead tracing of all Linux kernel-user transitions, for serious performance analysis. Includes kernel patches, loadable module, and post-processing software. Output is HTML/SVG per-CPU-core timeline that you can pan/zoom down to the nanosecond.
Other
633 stars 60 forks source link

Replace $PWD with shell pwd #1

Open joerowell opened 2 years ago

joerowell commented 2 years ago

I recently tried to build KUTrace on a system and ran into a problem where $PWD was not defined inside the Makefile. This stops kutrace_mod from being built properly.

It turns out that when using sudo only certain parts of the environment are actually passed to the command, and $PWD is a variable that gets cut out. This is described in some detail here.

Since Github can't do diffs over tar files, I've summarised the differences below: I've replaced

make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

with

make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) modules
0mp commented 1 year ago

You may want to use $(CURDIR) instead to avoid shelling out to call pwd. CURDIR is GNU make's builtin variable storing the current working directory.

zed commented 2 months ago

Note: $(shell pwd), $(CURDIR), $$PWD may be different from $(PWD) e.g., if make -C dir form is used (the former points to dir while the latter points to its parent).