whatawurst/android_kernel_sony_msm8998

Help building kernel

Closed this issue · 7 comments

Hello! I'm hoping to build linux and maybe attempt to build postmarketOS.

I'm using Arch Linux. I will adjust this later for building using pmbootstrap.

Here is my current progress

export ARCH=arm64
export KERNEL=kernel
export CROSS_COMPILE=aarch-linux-gnu-
export CROSS_COMPILE_ARM32=arm-none-eabi-

make lineage-msm8998-yoshino-lilac_defconfig

make

I did my own changes so that I could continue building, fixing errors along the way

diff --git a/drivers/bluetooth/btfm_slim.c b/drivers/bluetooth/btfm_slim.c
index 0a61186167ba..7cf59ccbe38c 100644
--- a/drivers/bluetooth/btfm_slim.c
+++ b/drivers/bluetooth/btfm_slim.c
@@ -23,8 +23,8 @@
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
 #include <sound/tlv.h>
-#include <btfm_slim.h>
-#include <btfm_slim_wcn3990.h>
+#include "btfm_slim.h"
+#include "btfm_slim_wcn3990.h"
 #include <linux/bluetooth-power.h>
 
 int btfm_slim_write(struct btfmslim *btfmslim,
diff --git a/drivers/bluetooth/btfm_slim_codec.c b/drivers/bluetooth/btfm_slim_codec.c
index 035e8d9fb5fd..5a1b1fef29fd 100644
--- a/drivers/bluetooth/btfm_slim_codec.c
+++ b/drivers/bluetooth/btfm_slim_codec.c
@@ -24,7 +24,7 @@
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
 #include <sound/tlv.h>
-#include <btfm_slim.h>
+#include "btfm_slim.h"
 
 static int bt_soc_enable_status;
diff --git a/drivers/bluetooth/btfm_slim_wcn3990.c b/drivers/bluetooth/btfm_slim_wcn3990.c
index 7abd5598c47b..7d611f803328 100644
--- a/drivers/bluetooth/btfm_slim_wcn3990.c
+++ b/drivers/bluetooth/btfm_slim_wcn3990.c
@@ -10,8 +10,8 @@
  * GNU General Public License for more details.
  */
 #include <linux/slimbus/slimbus.h>
-#include <btfm_slim.h>
-#include <btfm_slim_wcn3990.h>
+#include "btfm_slim.h"
+#include "btfm_slim_wcn3990.h"
 
 /* WCN3990 Port assignment */
 struct btfmslim_ch wcn3990_rxport[] = {
diff --git a/drivers/bluetooth/btfm_slim_wcn3990.h b/drivers/bluetooth/btfm_slim_wcn3990.h
index b637ac581201..5b75ed6e9cfe 100644
--- a/drivers/bluetooth/btfm_slim_wcn3990.h
+++ b/drivers/bluetooth/btfm_slim_wcn3990.h
@@ -12,7 +12,7 @@
 #ifndef BTFM_SLIM_WCN3990_H
 #define BTFM_SLIM_WCN3990_H
 #ifdef CONFIG_BTFM_SLIM_WCN3990
-#include <btfm_slim.h>
+#include "btfm_slim.h"
 
 /* Registers Address */
 #define CHRK_SB_COMP_TEST                      0x00000000
diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h
index 2d8639ea64d5..7580edf268d4 100644
--- a/include/trace/define_trace.h
+++ b/include/trace/define_trace.h
@@ -80,7 +80,10 @@
 /* Let the trace headers be reread */
 #define TRACE_HEADER_MULTI_READ
 
-#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+#define TRACE_INCLUDE_PATH ../../drivers/gpu/msm
+#include <trace/define_trace.h>
 
 /* Make all open coded DECLARE_TRACE nops */
 #undef DECLARE_TRACE
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index af0cb7907922..4196bcb29378 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -195,7 +195,10 @@ TRACE_MAKE_SYSTEM_STR();
 #undef TRACE_EVENT_PERF_PERM
 #define TRACE_EVENT_PERF_PERM(event, expr...)
 
-#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+#define TRACE_INCLUDE_PATH ../../drivers/gpu/msm
+#include <trace/define_trace.h>
 
 /*
  * Stage 3 of the trace events.

I have also moved these files to drivers/gpu/msm/

drivers/gpu/msm/binder_trace.h
drivers/gpu/msm/perf_trace_counters.c
drivers/gpu/msm/perf_trace_counters.h
drivers/gpu/msm/perf_trace_user.c
drivers/gpu/msm/perf_trace_user.h
drivers/gpu/msm/trace-events-emulation.h
drivers/gpu/msm/trace.h

I'm now stuck here and I don't know what to do

In file included from include/trace/events/syscalls.h:72,                                                                                                                                              
                 from arch/arm64/kernel/ptrace.c:50:                                                                                                                                                   
include/trace/define_trace.h:85: warning: "TRACE_INCLUDE_PATH" redefined                                                                                                                               
   85 | #define TRACE_INCLUDE_PATH ../../drivers/gpu/msm                                                                                                                                               
      |                                                                                                                                                                                                
include/trace/define_trace.h:84: note: this is the location of the previous definition                                                                                                                 
   84 | #define TRACE_INCLUDE_PATH .                                                                                                                                                                   
      |                                                                                                                                                                                                
In file included from include/trace/define_trace.h:93,                                                                                                                                                 
                 from include/trace/events/syscalls.h:72,                                                                                                                                              
                 from arch/arm64/kernel/ptrace.c:50:                                                                                                                                                   
include/trace/trace_events.h:200: warning: "TRACE_INCLUDE_PATH" redefined                                                                                                                              
  200 | #define TRACE_INCLUDE_PATH ../../drivers/gpu/msm                                                                                                                                               
      |                                                                                                                                                                                                
include/trace/trace_events.h:199: note: this is the location of the previous definition                                                                                                                
  199 | #define TRACE_INCLUDE_PATH .                                                                                                                                                                   
      |                                                                                                                                                                                                
In file included from include/trace/define_trace.h:93,                                                                                                                                                 
                 from include/trace/events/syscalls.h:72,                                                                                                                                              
                 from arch/arm64/kernel/ptrace.c:50:                                                                                                                                                   
include/trace/trace_events.h:492:16: warning: 'struct trace_event_data_offsets_sys_enter' declared inside parameter list will not be visible outside of this definition or declaration                 
  492 |         struct trace_event_data_offsets_##call *__data_offsets, proto)  \                                                                                                                      
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                       
include/trace/trace_events.h:60:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'                                                                                                                   
   60 |         DECLARE_EVENT_CLASS(name,                              \                                                                                                                               
      |         ^~~~~~~~~~~~~~~~~~~
include/trace/trace_events.h:123:9: note: in expansion of macro 'TRACE_EVENT'
  123 |         TRACE_EVENT(name, PARAMS(proto), PARAMS(args),                  \
      |         ^~~~~~~~~~~
include/trace/events/syscalls.h:17:1: note: in expansion of macro 'TRACE_EVENT_FN'
   17 | TRACE_EVENT_FN(sys_enter,
      | ^~~~~~~~~~~~~~
include/trace/trace_events.h:492:16: warning: 'struct trace_event_data_offsets_sys_exit' declared inside parameter list will not be visible outside of this definition or declaration
  492 |         struct trace_event_data_offsets_##call *__data_offsets, proto)  \
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~
include/trace/trace_events.h:60:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
   60 |         DECLARE_EVENT_CLASS(name,                              \
      |         ^~~~~~~~~~~~~~~~~~~
include/trace/trace_events.h:123:9: note: in expansion of macro 'TRACE_EVENT'
  123 |         TRACE_EVENT(name, PARAMS(proto), PARAMS(args),                  \
      |         ^~~~~~~~~~~
include/trace/events/syscalls.h:43:1: note: in expansion of macro 'TRACE_EVENT_FN'
   43 | TRACE_EVENT_FN(sys_exit,
      | ^~~~~~~~~~~~~~
In file included from include/trace/define_trace.h:93,                                                                                                                                         [10/306]
                 from include/trace/events/syscalls.h:72,
                 from arch/arm64/kernel/ptrace.c:50:
include/trace/events/syscalls.h: In function 'trace_event_raw_event_sys_enter':
include/trace/trace_events.h:668:63: error: storage size of '__data_offsets' isn't known
  668 |         struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
      |                                                               ^~~~~~~~~~~~~~
include/trace/trace_events.h:60:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
   60 |         DECLARE_EVENT_CLASS(name,                              \
      |         ^~~~~~~~~~~~~~~~~~~
include/trace/trace_events.h:123:9: note: in expansion of macro 'TRACE_EVENT'
  123 |         TRACE_EVENT(name, PARAMS(proto), PARAMS(args),                  \
      |         ^~~~~~~~~~~
include/trace/events/syscalls.h:17:1: note: in expansion of macro 'TRACE_EVENT_FN'
   17 | TRACE_EVENT_FN(sys_enter,
      | ^~~~~~~~~~~~~~
include/trace/events/syscalls.h: In function 'trace_event_raw_event_sys_exit':
include/trace/trace_events.h:668:63: error: storage size of '__data_offsets' isn't known
  668 |         struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
      |                                                               ^~~~~~~~~~~~~~
include/trace/trace_events.h:60:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
   60 |         DECLARE_EVENT_CLASS(name,                              \
      |         ^~~~~~~~~~~~~~~~~~~
include/trace/trace_events.h:123:9: note: in expansion of macro 'TRACE_EVENT'
  123 |         TRACE_EVENT(name, PARAMS(proto), PARAMS(args),                  \
      |         ^~~~~~~~~~~
include/trace/events/syscalls.h:43:1: note: in expansion of macro 'TRACE_EVENT_FN'
   43 | TRACE_EVENT_FN(sys_exit,
      | ^~~~~~~~~~~~~~
In file included from include/trace/define_trace.h:94,
                 from include/trace/events/syscalls.h:72,
                 from arch/arm64/kernel/ptrace.c:50:
include/trace/events/syscalls.h: In function 'perf_trace_sys_enter':
include/trace/perf.h:38:63: error: storage size of '__data_offsets' isn't known
   38 |         struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
      |                                                               ^~~~~~~~~~~~~~
include/trace/trace_events.h:60:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
   60 |         DECLARE_EVENT_CLASS(name,                              \
      |         ^~~~~~~~~~~~~~~~~~~
include/trace/trace_events.h:123:9: note: in expansion of macro 'TRACE_EVENT'
  123 |         TRACE_EVENT(name, PARAMS(proto), PARAMS(args),                  \
      |         ^~~~~~~~~~~
include/trace/events/syscalls.h:17:1: note: in expansion of macro 'TRACE_EVENT_FN'
   17 | TRACE_EVENT_FN(sys_enter,
      | ^~~~~~~~~~~~~~
include/trace/events/syscalls.h: In function 'perf_trace_sys_exit':
include/trace/perf.h:38:63: error: storage size of '__data_offsets' isn't known
   38 |         struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
      |                                                               ^~~~~~~~~~~~~~
include/trace/trace_events.h:60:9: note: in expansion of macro 'DECLARE_EVENT_CLASS'
   60 |         DECLARE_EVENT_CLASS(name,                              \
      |         ^~~~~~~~~~~~~~~~~~~
include/trace/trace_events.h:123:9: note: in expansion of macro 'TRACE_EVENT'
  123 |         TRACE_EVENT(name, PARAMS(proto), PARAMS(args),                  \
      |         ^~~~~~~~~~~
include/trace/events/syscalls.h:43:1: note: in expansion of macro 'TRACE_EVENT_FN'
   43 | TRACE_EVENT_FN(sys_exit,
      | ^~~~~~~~~~~~~~
make[1]: *** [scripts/Makefile.build:286: arch/arm64/kernel/ptrace.o] Error 1
make: *** [Makefile:1034: arch/arm64/kernel] Error 2

I am not familiar with postmarketOS, but a couple of questions:

  1. Do you have to use the gnu gcc for compilation?
  2. Have you tried building with clang? We have optimized the kernel for that, and tbh I haven't tried gcc in a long, long time.
  1. Do you have to use the gnu gcc for compilation?

I don't have any requirements for building, I want to build from this repo, boot it to my phone and try to learn Linux from it.

  1. Have you tried building with clang? We have optimized the kernel for that, and tbh I haven't tried gcc in a long, long time.

No I haven't tried yet. Can you please provide a working build environment that I could perhaps follow?

i always use a full android build environment for this, but following the instructions here should probably work. E.g. the manifest for wahoo (https://android.googlesource.com/kernel/manifest/+/refs/heads/android-msm-wahoo-4.4-android10/default.xml) should probably have what you need.

Maybe @nathanchances README is also a good help (https://github.com/nathanchance/android-kernel-clang).

I'd like to expand on this hopefully I can understand how to add patches while using lineage-18.1 branch.

postmarketOS port was started by orsonmmz on this repository https://gitlab.com/orsonmmz/pmaports/-/tree/device/sony-lilac/device/testing/linux-sony-lilac.

Yes I have built the image but it is stuck on the boot logo, same as his previous attempt (https://wiki.postmarketos.org/wiki/Sony_Xperia_XZ1_Compact_(sony-lilac))

On his APKBUILD file he is still using lineage-16.0 branch.

I'm guessing without prior knowledge on this topic. Longshot, that if this was built on a newer branch say lineage-18.1. It would fix it and would be more compatible with the device? I would just need to change the paths patch?

So coming back to using clang, one of the issues with gcc is also that for some reason, our BL doesn't like a too large kernel inside the boot.img, if it's built with gcc (or outdated clang's that is). As a result, the boot would get stuck at the BL unlock warning and then reboot (iirc). Can you try to disable the qcacld driver from the defconfig and see if it continues then?

An alternative would then be to build wlan as a module, which also requires some init changes to load the module etc, but we can go through that once we know if that helps at all.

I'll close this due due inactivity