# Linux Kernel Module Cheat

#### 26.2.1. Enable Buildroot compiler optimizations

If you are benchmarking compiled programs instead of hand written assembly, remember that we configure Buildroot to disable optimizations by default with:

    BR2_OPTIMIZE_0=y

to improve the debugging experience.

You will likely want to change that to:

    BR2_OPTIMIZE_3=y

Our buildroot_packages/sample_package package correctly forwards the Buildroot options to the build with `$(TARGET_CONFIGURE_OPTS)`, so you don’t have to do any extra work.

Don’t forget to do that if you are 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: Section 26.2, “Custom Buildroot configs”

      ./build-buildroot \
        --config 'BR2_OPTIMIZE_3=y' \
        --config 'BR2_PACKAGE_SAMPLE_PACKAGE=y' \
        -- \
        sample_package-dirclean \
        sample_package-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 as mentioned at: Section 3.1.2, “Disable kernel compiler optimizations”

- clean the build and rebuild from scratch:

      mv out out~
      ./build-buildroot --config 'BR2_OPTIMIZE_3=y'