mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
kernel_module, sample_package: correctly forward Buildroot -O and -g flags
readme: improve optimization documentation
This commit is contained in:
36
README.adoc
36
README.adoc
@@ -425,6 +425,18 @@ Not all packages have an alias, when they don't, just use the form:
|
||||
./build -- <pkg>-reconfigure
|
||||
....
|
||||
|
||||
==== Rebuild a package with different build options
|
||||
|
||||
For example, if you decide to <<enable-compiler-optimizations>> after an initial build is finished, you must first clean the build before rebuilding:
|
||||
|
||||
....
|
||||
./build -B 'BR2_OPTIMIZE_3=y' kernel_module-dirclean kernel_module-reconfigure
|
||||
....
|
||||
|
||||
as explained at: https://buildroot.org/downloads/manual/manual.html#rebuild-pkg
|
||||
|
||||
The clean is necessary because the source files didn't change, so `make` would just check the timestamps and not build anything.
|
||||
|
||||
[[retype]]
|
||||
=== Don't retype arguments all the time
|
||||
|
||||
@@ -4538,9 +4550,29 @@ You will likely want to change that to:
|
||||
BR2_OPTIMIZE_3=y
|
||||
....
|
||||
|
||||
and do a full rebuild.
|
||||
Our link:kernel_module/user[] package correctly forwards the Buildroot options to the build with `$(TARGET_CONFIGURE_OPTS)`, so you don't have to do any extra work.
|
||||
|
||||
TODO is it possible to compile a single package with optimizations enabled? In any case, this wouldn't be very representative, since calls to an unoptimized libc will also have an impact on performance. Kernel-wise it should be fine though due to: <<kernel-o0>>
|
||||
Don't forget to do that if you are <<add-new-buildroot-packages,adding a new package>> with your own build system.
|
||||
|
||||
Then, you have two choices:
|
||||
|
||||
* if you already have a full `-O0` build, you can choose to rebuild just your package of interest to save some time as described at: <<rebuild-a-package-with-different-build-options>>
|
||||
+
|
||||
....
|
||||
./build -B 'BR2_OPTIMIZE_3=y' kernel_module-dirclean kernel_module-reconfigure
|
||||
....
|
||||
+
|
||||
However, this approach might not be representative since calls to an unoptimized libc and other libraries will have a negative performance impact.
|
||||
+
|
||||
Maybe you can get away with rebuilding libc, but I'm not sure that it will work properly.
|
||||
+
|
||||
Kernel-wise it should be fine though due to: <<kernel-o0>>
|
||||
* <<clean-the-build,clean the build>> and rebuild from scratch:
|
||||
+
|
||||
....
|
||||
mv out out~
|
||||
./build -B 'BR2_OPTIMIZE_3=y'
|
||||
....
|
||||
|
||||
=== Find Buildroot options with make menuconfig
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ ifeq ($(BR2_PACKAGE_OPENBLAS),y)
|
||||
endif
|
||||
|
||||
define KERNEL_MODULE_BUILD_CMDS
|
||||
$(MAKE) -C '$(@D)/user' BR2_PACKAGE_OPENBLAS="$(BR2_PACKAGE_OPENBLAS)" CC="$(TARGET_CC)" LD="$(TARGET_LD)"
|
||||
$(MAKE) -C '$(@D)/user' $(TARGET_CONFIGURE_OPTS) BR2_PACKAGE_OPENBLAS="$(BR2_PACKAGE_OPENBLAS)"
|
||||
endef
|
||||
|
||||
define KERNEL_MODULE_INSTALL_TARGET_CMDS
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.PHONY: all clean
|
||||
|
||||
CFLAGS_EXTRA ?= -ggdb3 -fopenmp -O0 -std=c99 -Wall -Werror -Wextra
|
||||
CFLAGS_EXTRA ?= -fopenmp -std=c99 -Wall -Werror -Wextra
|
||||
IN_EXT ?= .c
|
||||
LIBS :=
|
||||
OUT_EXT ?= .out
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.PHONY: all clean
|
||||
|
||||
CFLAGS_EXTRA ?= -ggdb3 -fopenmp -O0 -std=c99 -Wall -Werror -Wextra
|
||||
CFLAGS_EXTRA ?= -fopenmp -std=c99 -Wall -Werror -Wextra
|
||||
IN_EXT ?= .c
|
||||
LIBS :=
|
||||
OUT_EXT ?= .out
|
||||
|
||||
@@ -10,7 +10,8 @@ SAMPLE_PACKAGE_SITE_METHOD = local
|
||||
|
||||
define SAMPLE_PACKAGE_BUILD_CMDS
|
||||
# D contains the source code of this package.
|
||||
$(MAKE) -C '$(@D)' CC="$(TARGET_CC)" LD="$(TARGET_LD)"
|
||||
# TARGET_CONFIGURE_OPTS contains several common options such as CFLAGS and LDFLAGS.
|
||||
$(MAKE) -C '$(@D)' $(TARGET_CONFIGURE_OPTS)
|
||||
endef
|
||||
|
||||
define SAMPLE_PACKAGE_INSTALL_TARGET_CMDS
|
||||
|
||||
Reference in New Issue
Block a user