Skip to content

Command line tips and tricks

Nick Desaulniers edited this page Jul 20, 2020 · 29 revisions

Linux

Given sha of commit, we want to know the first tag that contains the fix.

tag=$1
git describe --match 'v*' --contains "$tag" | sed 's/[~^].*//'

Clang

eh, depends on the r123456 svn-revision, which is not easy to map to a release version, and if it got cherry picked back to a bugfix release. WIP.

For finding which commit may have removed a string, try:

$ git log -S <string> <file>

(via Saravana Kannan)

For fetching a patch series from the mailing list

Recommend installing b4.

$ b4 am <lore thread url> -o - | git am
# example
$ b4 am \
  https://lore.kernel.org/lkml/CAKwvOdmsap8iB+H5JXiHYwSJFrtQ_krjNH7eQCGe7p-LjK7ftA@mail.gmail.com/T/\#t \
  -o - | git am

Installing a built kernel

$ sudo make LLVM=1 -j install_modules install

If you see an error:

make: clang: Command not found

this is because super user doesn't share the same $PATH as the current user. A possible fix is to add the path to clang (via which clang) to /etc/sudoers via the sudo visudo command. Example:

$ which clang
/home/nick/llvm-project/llvm/build/bin/clang
--- /etc/sudoers	2020-07-19 17:57:11.170893459 -0700
+++ /etc/sudoers	2020-07-19 17:56:35.255107049 -0700
@@ -8,7 +8,7 @@
 #
 Defaults	env_reset
 Defaults	mail_badpass
-Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
+Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/nick/llvm-project/llvm/build/bin"
 
 # Host alias specification
Clone this wiki locally