Commit graph

48 commits

Author SHA1 Message Date
Rashed Abdel-Tawab
c648519530 kernel: Add GCC toolchains to the path
Tools like `as` only exist in the GCC toolchain, so we need that

Change-Id: I025d0d9bdf6eda94a538d2d6ddafbecc8830f471
2019-09-13 08:27:49 +02:00
Rashed Abdel-Tawab
ba5ea35eb6
kernel: Use absolute path for kernel O= argument
The kernel make command is executed in the build root. Without absolute
out paths, kernel out start with "out/" meaning it would be created in
the kernel source. Add BUILD_ROOT to the argument to ensure it's always
made in the actual out/ dir.

Change-Id: I425134a893d4d5c9f31efccaf75e153b5462b76c
2019-09-09 12:21:35 -07:00
dianlujitao
295ddaa61d
Fix real file depends on PHONY target
Change-Id: Idd42f4575dfd9fbbff9ab15e20e65d932df0390c
2019-09-09 12:20:43 -07:00
Rashed Abdel-Tawab
dfc3d1830d
kernel: Use prebuilt binaries
perl, lz4c, and a bunch of other binaries are not allowed anymore.
So we need to provide our own.

Change-Id: Idbc88b76247b3dda7c5d52e5eed2d548c33f6f2d
2019-09-09 12:19:44 -07:00
Rashed Abdel-Tawab
fb35b9da61
kernel: Use full path to the make command
make is now a dissallowed command so just run the full command

Change-Id: I9390dc5a8bcd17f316354b88bdbc65ac8663b369
2019-09-08 13:41:35 -07:00
Rashed Abdel-Tawab
3254cafe49
kernel: Add TARGET_KERNEL_ADDITIONAL_FLAGS to allow setting extra cflags
Also fix KERNEL_MAKE_FLAGS not being used by the kernel make command

Change-Id: I8786d6c1de6652f87a02c990c4b56f62b0cc0203
2019-09-01 17:45:00 -07:00
LuK1337
6047f5a0c5 kernel: Consider depmod version when handling kernel modules
* This fixes dirty boot image rebuilding on devices
  with CONFIG_LOCALVERSION_AUTO=y and any driver
  set to =m.
* Basically appending `cat include/config/kernel.release`
  to modules path makes sure that our find does not
  return old modules which would make cp fail with
  'cp: will not overwrite just-created' message.

Change-Id: Ifb79d33b95d7671d8b2d6633644c8b8290d1f442
2019-07-19 21:49:04 +02:00
Rashed Abdel-Tawab
60fe93525a lineage: Rework DTBO image generation
Currently we handle the DTBO images from start to finish, including
AVB footers, and just drop them in $(PRODUCT_OUT)/dtbo.img when done.
While this works for the most part, we are limited in what we can do
with the DTBO images. For example non-A/B device recovery images must
have a copy of the DTBO image appended to recovery (see AOSP docs:
https://source.android.com/devices/bootloader/recovery-image ). This
means that we need to pass the pre-AVB dtbo image into
BOARD_PREBUILT_DTBOIMAGE in order to let the AOSP build system handle it.

This commit reworks the way the DTBO images are built, placing them at
$(PRODUCT_OUT)/dtbo-pre.img instead and setting BOARD_PREBUILT_DTBOIMAGE
to that path so the AOSP build system can pick the images up and sign
them and append to recovery (for applicable devices).

Change-Id: I8819d7cd92ba298de67dbc7f6b321917ba8524f1
2019-06-06 07:17:27 +02:00
Thor Lee
75975892b4 kernel: Fix modules path generated in modules.dep
This patch fixes the error generated path of modules in modules.dep.

Tested on Redmi Note 5(whyred).

Before:
/vendorlib/modules/test-iosched.ko:
/vendorlib/modules/mpq-adapter.ko:
/vendorlib/modules/ufs_test.ko: /vendorlib/modules/test-iosched.ko
/vendorlib/modules/rdbg.ko:
/vendorlib/modules/br_netfilter.ko:
/vendorlib/modules/gspca_main.ko:
/vendorlib/modules/mpq-dmx-hw-plugin.ko: /vendorlib/modules/mpq-adapter.ko

After:
/vendor/lib/modules/test-iosched.ko:
/vendor/lib/modules/mpq-adapter.ko:
/vendor/lib/modules/ufs_test.ko: /vendor/lib/modules/test-iosched.ko
/vendor/lib/modules/rdbg.ko:
/vendor/lib/modules/br_netfilter.ko:
/vendor/lib/modules/gspca_main.ko:
/vendor/lib/modules/mpq-dmx-hw-plugin.ko: /vendor/lib/modules/mpq-adapter.ko

Change-Id: I84d51f4c418fda0d99890db0fd5d976c42f54295
2019-05-02 10:00:49 +02:00
Ethan Chen
9985f596b3 kernel: Use build-image-kernel-modules instead of copying it
* Call the build system's build-image-kernel-modules function instead of
  redefining all of it inline ourselves.

Change-Id: Ifc4bd3c452393389a14174f4cc29a8f7ef064b93
2019-03-09 13:41:19 -08:00
Ethan Chen
a325446555 kernel: Use a macro for kernel build targets
Change-Id: Idb61ddbfd630401da09a0c3207aaab7e25bc4b14
2019-03-09 13:41:19 -08:00
Ethan Chen
0724f78af4 kernel: Detect kernel module usage better
* Check for any actual kernel modules, rather than just the presence of
  kernel modules being enabled as a kernel feature.

Change-Id: I6b7e82d5c59dd57621d9f9e2d1fd606997790d1c
2019-03-09 13:41:19 -08:00
Ethan Chen
a8750b4a6e kernel: Move kernel module dir cleanup/creation to module install target
* The directories used by the kernel module install rules are performed
  as part of the rules in the kernel build itself. This is likely a
  leftover from before kernel module install was separated.

Change-Id: Iee2f73a0f8e0f274b1c2931ba57277ff14d7f5cc
2019-03-09 13:41:19 -08:00
Ethan Chen
117a0fd3b2 kernel: Move full kernel build guard flag below all targets
* The Pixel DTBO generation step should also be guarded by the full
  kernel build flag.

Change-Id: I06d230b1b32ad9d974f90bfe6ae82008f4454d83
2019-03-09 13:41:19 -08:00
Nathan Chancellor
4d0d438095 kernel.mk: Support kernels that use LTO
Google added support for LTO + CFI in the Pixel 3 kernel, which requires
not only Clang but a couple of additional binaries, namely llvm-ar and
llvm-dis for IR generation. Google expects these binaries to be in PATH
according to their definitions and the build.config.common file:

https://android.googlesource.com/kernel/msm/+/android-9.0.0_r0.31/Makefile#637
https://android.googlesource.com/kernel/msm/+/android-9.0.0_r0.31/build.config.common

However, kernel.mk does not add the LLVM bin directory to PATH so the
build fails because the binaries can't be found. We could add LLVM_AR
and LLVM_DIS to the make commands like CC and CROSS_COMPILE; however,
adding the bin directory to PATH is a more sustainable solution as
Google might require new binaries in the future.

Additionally, LTO needs access to the LLVMgold library so it needs to be
available in LD_LIBRARY_PATH.

Add a PATH_OVERRIDE variable that will set up PATH and LD_LIBRARY_PATH
with the bin and lib64 folders from the requested LLVM toolchain
respectively when building with Clang. This won't affect kernels that
don't use LTO like Wahoo.

Change-Id: Ib16fa0d3180de2f96accb2f7648b07a017f8f98b
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2018-10-25 02:42:15 +02:00
Michael Bestas
b4c4aba96d kernel: Remove kernel{x}config
* They haven't been working since ninja build was introduced

Change-Id: Icb51412b7a70cdec7f077a6d3d56f7720188bcb0
2018-10-20 21:50:38 +02:00
Michael Bestas
2425d1ea38 kernel: Remove deprecated flag errors
* All devices should have migrated by now

Change-Id: Iecef58a1193b87ecb084eccda27a3b4e89f42219
2018-10-20 21:50:38 +02:00
Sam Mortimer
8e44326c2f vendor/lineage: Remove kernel.mk headers generation
*) This has been deprecated by the bp mobule
   generated_kernel_headers.

*) To build with kernel headers, do this:
   LOCAL_HEADER_LIBRARIES += generated_kernel_headers
   Or for soong targets:
   header_libs: [ "generated_kernel_headers" ],

Change-Id: Idad445709f0ee0ec11b41b40123b14976a0052ad
2018-10-20 21:50:38 +02:00
Rashed Abdel-Tawab
a836d79629 lineage: Move some kernel definitions to BoardConfigKernel
Kernel source settings should always come at BoardConfig population
time so things that use the variable later don't end up pointing to
an empty or wrong variable.

The following is also squashed in:

Author: Christopher N. Hesse <raymanfx@gmail.com>
Date:   Fri Aug 10 00:23:54 2018 +0200
    tasks: kernel: Honor prebuilt kernel flag
    For devices that want to use a prebuilt kernel, TARGET_KERNEL_SOURCE
    would still be set to TARGET_AUTO_KDIR, meaning the build system would
    still try to build the kernel if TARGET_AUTO_KDIR was present.
    Setting TARGET_PREBUILT_KERNEL indicates this is not wanted, so don't
    attempt to do it.
    Change-Id: Ic79b3ac1b9c946fd258ada43dce2b08bb74ea0d9

Change-Id: If046b86ff0d18c76898e90295be873a8379f678a
2018-10-20 21:50:38 +02:00
Michael Bestas
c77bb3a5ba kernel: Correct CROSS_COMPILE_ARM32 toolchain
* Missed in the original commit that switched to
  androidkernel toochain

Change-Id: I9b6d2e7216b48d22bcb7eec62c4fd9c05a895d18
2018-10-10 18:30:54 +02:00
Rashed Abdel-Tawab
8960e3dfd6 kernel: Set CROSS_COMPILE_ARM32 if using aarch64
Google added a 32-bit vDSO to the Wahoo and Marlin kernels on Android P,
requiring a 32-bit toolchain to compile/link, and the build fails when
it is not provided.

Change-Id: I700e66a417ed431c31d82fc950f5e5acd07ab281
2018-08-10 22:00:27 +02:00
Rashed Abdel-Tawab
3d29315c1e kernel: Remove ANDROID_BUILD_TOP
This is no longer used in Pie, so just get the top dir of the build system
and use that.

Change-Id: I4bc416e471ddeb9810960f4ddcd647b20aa531c2
2018-08-10 19:37:27 +01:00
Luca Stefani
a1ade7fb7c kernel: Allow installing modules on system
Change-Id: Id4386cd37645dc9e9253410e0b2093cd2e6b04dc
2018-07-19 23:14:32 +02:00
Nathan Chancellor
ca40331215 build: kernel: Use LLVM_PREBUILTS_VERSION if no version is specified
Some ROMs may want to track Google's master branch, which has Clang 6
and 7 toolchains available, as it gets rid of some hacks in the kernel
source. Unfortunately, with the current default choosing logic, the
latest one would be chosen, which it shouldn't be. Use the variable set
in build/make/core/clang/versions.mk, as that's what was intended.

Change-Id: I607c7f750f62caabee4cdccea67846feb7f632fa
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
2018-04-16 20:56:13 +02:00
Jaap Jan Meijer
1fdbf7ad8b Don't enable ANDROID_BINDER_IPC_32BIT for mixed userspace/kernel
TARGET_USES_64_BIT_BINDER should be used for the userspace binder now.

Change-Id: I5cede00e7667969e394d06169dff54659900d90f
2018-02-24 20:52:30 -06:00
Dan Pasanen
f65a6dfd63 kernel: fix ccache variable sanitation for clang builds
* When using "?=", expansion doesn't happen right away, so the ccache
  variable is sanitized before KERNEL_CC gets expanded and no ccache
  is ever used for clang builds.

* With ":=", expansion happens immediately. So let's manually check
  if KERNEL_CC is already set somewhere else to determine whether or
  not we should set it ourselves using ":=".

Change-Id: I8a61767606a4f3d4c6ba88c68b10fd2e11783406
2018-02-19 04:20:53 +00:00
Aaron Kling
a078a220bf Fix kernel build failure on some devices and build hosts
Change-Id: Ib6ba53994b4e04503ee4636a6aaab9c0bc3f676c
2018-01-12 18:19:27 -06:00
Tom Marshall
6b83d830df lineage: build: kernel: Rework kernel header logic
The existing kernel header logic has several issues:

 * It does not depend on the actual kernel headers, so it does not
   detect actual kernel header changes.

 * It does depend on the kernel config, which should not be used to
   generate (user space) kernel headers.

The end result is that kernel headers aren't properly regenerated when
needed, and spuriously regenerated when not needed.  Additionally, the
kernel header rebuild mucks around with the kernel config, which is
unneccesary and fraught with danger.

Rewrite the kernel header dependency and generation logic as follows:

 * Use the dependency file $(KERNEL_OUT)/.headers_install_deps to
   manage dependencies on the actual kernel header files which are
   exported to user space (and the top level kernel Makefile, which
   is used to generate version.h).  The dependency file is exactly
   the same as what GCC would output for a C/C++ dependency with the
   M/MM flags.

 * Conditionally include the dependency file to detect when headers
   should be (re)generated.

 * Introduce the phony target INSTALLED_KERNEL_HEADERS for modules to
   declare a dependency on kernel headers.

Additionally:

 * Get rid of TARGET_KERNEL_HEADER_ARCH and KERNEL_HEADER_DEFCONFIG.

 * Get rid of KERNEL_OUT_STAMP and move commands to the appropriate
   places in the rules.

 * Fail the build when $(KERNEL_OUT)/usr is mentioned in a dependency.
   Note a separate commit to build/core/binary.mk will provide a
   migration path and a suitable deprecation warning.

 * Declare the kernel*config targets phony.

Change-Id: I8b46f4ea1c622d8e73cca5157be96ec09d42ebb3
2018-01-09 03:09:57 +00:00
Christian Oder
8d5db3c24f kernel: Allow building dtbo.img
taimen uses the dtbo.img as an DTB Overlay in order to use the same defconfig for both, taimen and wahoo.
The dtbo.img is built with "make dtbo.img". Allow automatically building it when setting TARGET_NEEDS_DTBOIMAGE to true, or by manually calling make dtboimage.

Thanks to luca020400 for help with the kernel.mk logic

[raymanfx] Add AVB hash footer support

Change-Id: Iaddafaa98e3e84880462a2c35b899e3fea21e161
2018-01-08 07:04:05 +00:00
Dan Pasanen
8ee5d891b0 kernel: don't build for TARGET_NO_KERNEL targets
Change-Id: I14ad45c06922c0775e0574ddbcfcdc33353af465
2018-01-04 20:42:27 +00:00
Joe Maples
da32895b61 tasks: kernel: Add support for Clang kernel builds
Add support for compiling kernels with Clang as intoduced on android-4.4

In order to compile with clang, you must set TARGET_KERNEL_CLANG_COMPILE.
If you wish to specify a specific clang version, also set TARGET_KERNEL_CLANG_VERSION,
but if that is not set, the build system will default to the latest version of clang
available in prebuilts/clang

Change-Id: I79dc1dca9758a930f2f5ba1754b5d8de114af900
Signed-off-by: Joe Maples <joe@frap129.org>
2017-12-31 01:42:06 +00:00
Ethan Chen
bf38db2a5e kernel: Handle kernel modules correctly
Place kernel module output in the correct location.
Perform depmod steps (copied from build-image-kernel-modules function in
build/make/core/Makefile).
See: https://source.android.com/devices/architecture/kernel/modular-kernels

Change-Id: I6e70012a5c1acdb276f9bee0d57631d2805f71ea
2017-12-31 01:41:57 +00:00
Tom Marshall
f15c371403 lineage: build: kernel: Rework kernel module logic
The existing kernel module logic does not detect failed kernel module
builds.  This is because the module build logic is a long shell chain
that invokes make macros which are not intended to be used in this way.
The essense of the issue is that we get a shell chain that looks like:

	cmd && cmd && var=value; cmd && var=value; cmd;

The shell breaks this into three separate commands.  The first builds
the modules.  The other two are the macro invocations.  So the result
of the command is the result of the last macro invocation, which will
always succeed even if the modules fail to build.

The issue is made worse by the existing build rule conflating the built
kernel modules and the installed kernel modules.

Fix this by reducing the built kernel module command to a single shell
command and creating a separate target INSTALLED_KERNEL_MODULES.  Any
kernel module build failure will show up properly.  The commands for
INSTALLED_KERNEL_MODULES do not invoke any macros and should avoid the
issue described above.

Finally, this also removes the fake target no-external-modules and
unifies the install logic for in-tree and out-of-tree modules.

Change-Id: I3d13056e217e1e937c8c3a345032682ffc394bca
2017-11-15 23:57:39 +00:00
Dan Pasanen
edc1cebc2f kernel: clean up this madness
* WARNING: this intentionally breaks the build on devices who
  are not setting BOARD_KERNEL_IMAGE_NAME and are still setting
  TARGET_USES_UNCOMPRESSED_KERNEL or TARGET_KERNEL_APPEND_DTB

* The logic here is insanity and if all of this can be done
  by simply setting BOARD_KERNEL_IMAGE_NAME, why have all this
  extra cruft?

* Use cases:
  - Set a kernel image name without "-dtb" on the end, you get a kernel.
    Nothing more.
  - Set a kernel image name with "-dtb" on the end, you get an kernel
    with an appended dt.
  - Set a kernel image name without "-dtb" on the end, and set
    BOARD_KERNEL_SEPARATED_DT. You get a kernel and a separated dt.img.
  - Set a kernel image name with "-dtb" on the end, and set
    BOARD_KERNEL_SEPARATED_DT. You're crazy.

Change-Id: I5c3fc6eb727255684278ff562c0ee3faa7124b6b
2017-10-17 16:19:19 +00:00
Luca Stefani
d6e2fbcf8e tasks: kernel: Kill unexisting wiki reference
Change-Id: Ib43012206ba7028072d39495bda32d82dd72bdc6
2017-08-17 18:54:35 +00:00
Michael Bestas
296008cc79
kernel: Add savedefconfig target
* Add a build target to simply regenerate the kernel
  minimal defconfig and copy it to the kernel source

Change-Id: I04be945eb6dae3042c236785328c7c9995d42e49
2017-07-12 20:56:35 +03:00
Christopher N. Hesse
1e7c3f00c6 kernel: Fix broken C_INCLUDE_PATH for Darwin
Commit 7fb9251dfc modified
the expansion in an illegal way.

Fix the broken env variable.

Change-Id: Ib3029fa995d6a4b0416887a2ef2e4792c9e6bb27
(cherry picked from commit 90b437e784c19fc428c24891cc96705b89b786df)
2017-04-11 23:08:32 +00:00
Rashed Abdel-Tawab
7fb9251dfc kernel: Include openssl headers and dylibs on darwin
The easiest and best way to get openssl on darwin is using homebrew,
however homebrew refuses to link openssl (and for good reason) in
order to prevent conflicts with Apple's homegrown version. Include
the openssl headers and dylibs from the dir that homebrew installs
openssl to let 4.4 kernels compile.

Change-Id: I06b66768fbdd4855fd57b88100d646ed6e311a59
2017-04-09 00:44:05 -05:00
Rashed Abdel-Tawab
b48c27f04f
build: Append -dtb to kernel image name if TARGET_KERNEL_APPEND_DTB is set
Currently devices that have TARGET_KERNEL_APPEND_DTB set also have to set
BOARD_KERNEL_IMAGE_NAME to Image.gz-dtb (or zImage-dtb on arm32) in order
to properly build the image with an appended DT. Automatially append -dtb
if TARGET_KERNEL_APPEND_DTB is set so BOARD_KERNEL_IMAGE_NAME does not need
to be set.

Change-Id: I5464c67092a7b9f86669902e5c0e4a47836f7cbd
2017-01-19 15:57:13 -05:00
Zhao Wei Liew
e407ec7035 cm: build: kernel: Remove obsolete checks
* BOARD_USES_UBOOT is unused.
 * Same goes for BOARD_USES_UNCOMPRESSED_BOOT. Furthermore,
   it is superseded by TARGET_USES_UNCOMPRESSED_KERNEL.

Change-Id: I9f0e2848fcd0cd212bccacf14df55ad03f821051
2017-01-14 19:48:07 +08:00
Ziyan
54648c2a3b build: kernel: build arm kernel modules with -fno-pic
With androidkernel (androideabi) toolchains, -fpic is enabled by default.
At least on my 3.4 arm kernel, this causes an issue with kernel modules:
"Unknown symbol _GLOBAL_OFFSET_TABLE_".

On traditional armeabi toolchains, -fpic is not enabled, resulting in working
kernel modules; let's follow that here.

Change-Id: I3058b5213b34bdde9bb9d744563c7d55cd42d2a5
2017-01-12 18:28:12 +00:00
Dan Pasanen
0344771b53 vendor: we are now LineageOS
* Change necessary bits to support our project move

Change-Id: I085470d448a243cc9d60b4ce920dee52086f64cd
2016-12-28 19:44:28 +00:00
Luca Stefani
c66825b158 build: kernel: Remove duplicated targets
We call them already in TARGET_KERNEL_BINARIES

Change-Id: I1a9cf89d59416fdb6c9c570d17fb490440d44159
2016-11-24 15:54:11 +01:00
Zhao Wei Liew
9689bb9dba build: kernel: Set prefix based on KERNEL_ARCH
KERNEL_ARCH specifies the kernel architecture, not TARGET_ARCH.

Change-Id: I97407caa15cacf53489e8ebb31f5c059991a9493
2016-11-10 15:55:42 -08:00
Sam Mortimer
b0cecb7335 Always create a kernel defconfig build artifact
It's just easier having it always built for you
(and it really takes no time).

Change-Id: If183cef50b1de0bf228e27bab77607df71350345
2016-11-05 08:25:45 -07:00
Michael Bestas
1d55ece94a
kernel: Default to androidkernel toochains
* androidkernel is a set of toolchain symlinks for kernel builds that
point to the regular toolchain binaries, except with ld pointing to bfd
instead of gold.

Change-Id: Id1e2d3b1c50db581bff13cfa00b5b35d5badb8ed
2016-09-28 20:16:25 +03:00
Steve Kondik
6a3782824f cm: Add missing bits from system-ccache commit
Change-Id: I5936a9a3f3ded09aa7d3ec4f1061cbccf324c759
2016-09-25 22:37:01 -07:00
Michael Bestas
3952f6cb0d Import CM build additions
Change-Id: Id1eb902129754e61dfcc2b5d95c3a75172ff0c5e
2016-09-25 22:32:37 -07:00