From: Michael Jeanson Date: Fri, 11 Dec 2015 21:33:09 +0000 (-0500) Subject: Add support for built-in kernel build X-Git-Tag: v2.8.0-rc1~49 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f59ec0bee6032a26808d4bddaafb1d6f3e081725;p=lttng-modules.git Add support for built-in kernel build To build the LTTng modules as builtins in a kernel image, simply run the "built-in.sh" script with the path to you kernel source directory as an argument. Then configure your kernel build and add the "CONFIG_LTTNG" option. Build as usual and voila! This is an early implementation with a single configuration option that enables or disables everything, We could add fine grained config options for each modules or group of modules. Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- diff --git a/Kconfig b/Kconfig new file mode 100644 index 00000000..9ed539eb --- /dev/null +++ b/Kconfig @@ -0,0 +1,11 @@ +config LTTNG + tristate "LTTng support" + depends on TRACEPOINTS + help + LTTng is an open source tracing framework for Linux. + + See https://lttng.org/ + + To compile as a module, choose M here. + + If unsure, say N. diff --git a/README.md b/README.md index 9934d2ef..e3842d59 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,16 @@ kernel, do: sudo depmod -a kernel_version +### Kernel built-in support + +It is also possible to build these modules as part of a kernel image. Simply +run the [`built-in.sh`](built-in.sh) script with the path to your kernel +source directory as an argument. It will symlink the lttng-modules directory +in the kernel sources and add an include in the kernel Makefile. + +Then configure your kernel as usual and enable the `CONFIG_LTTNG` option. + + ### Required kernel config options Make sure your target kernel has the following config options enabled: @@ -83,7 +93,7 @@ available from LTTng: number and name -Using +Usage ----- Use [LTTng-tools](https://lttng.org/download) to control the tracer. diff --git a/built-in.sh b/built-in.sh new file mode 100755 index 00000000..782985f9 --- /dev/null +++ b/built-in.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +usage() { + echo "usage: $0 " >&2 + exit 1 +} + +[ "$#" -eq 1 ] || usage +KERNEL_DIR="$(readlink --canonicalize-existing "$1")" + +# Symlink the lttng-modules directory in the kernel source +ln -sf "$(pwd)" "${KERNEL_DIR}/lttng" + +# Graft ourself to the kernel build system +echo 'source "lttng/Kconfig"' >> "${KERNEL_DIR}/Kconfig" +sed -i 's#+= kernel/#+= kernel/ lttng/#' "${KERNEL_DIR}/Makefile" + +echo >&2 +echo " $0: done." >&2 +echo " $0: now you can build the kernel with LTTng support." >&2 +echo " $0: make sure you enable it (CONFIG_LTTNG) before building." >&2 +echo >&2