nathanchance / android-kernel-clang

Information on compiling Android kernels with Clang
294 stars 83 forks source link

msm-4.4-pie broken? #3

Closed Stricted closed 6 years ago

Stricted commented 6 years ago

i applied the patches from the msm-4.4-pie branch to my kernel https://github.com/Stricted/android_kernel_sony_sdm660/tree/lineage-16.0-clang2

the only conflicts i had were nothing critical and only makefiles related

unfortunately the kernel does not boot (i only get it randomly to boot) with the applied patches regardless if compiled with gcc or clang (without the patches the kernel boots fine when compiled with gcc) do i miss something?

nathanchance commented 6 years ago

Run a git bisect and see exactly which patch broke booting.

Stricted commented 6 years ago

starting with this commit it stops boooting https://github.com/nathanchance/android-kernel-clang/commit/643b8aa17de6cf0c927ddb302e57fe9b50b4cd50

buildtest@lineage:~/android/lineage-16.0/kernel/sony/sdm660$ git bisect start
buildtest@lineage:~/android/lineage-16.0/kernel/sony/sdm660$ git bisect bad
buildtest@lineage:~/android/lineage-16.0/kernel/sony/sdm660$ git bisect good ffb39e09db84b8ea5eca892dd9fe32cef128cc96
Bisecting: 17 revisions left to test after this (roughly 4 steps)
[40e226cec4a2fc3e393e50e285bada6cd2527996] BACKPORT: kbuild: clang: remove crufty HOSTCFLAGS
buildtest@lineage:~/android/lineage-16.0/kernel/sony/sdm660$ git bisect good
Bisecting: 8 revisions left to test after this (roughly 3 steps)
[12518ec7fef3551e9572f9c6e834241be3e8b0a7] UPSTREAM: mm/zsmalloc.c: fix -Wunneeded-internal-declaration warning
buildtest@lineage:~/android/lineage-16.0/kernel/sony/sdm660$ git bisect good
Bisecting: 4 revisions left to test after this (roughly 2 steps)
[88cd1d74093b83c9d8bdbfaa2906b0e7fc87718e] BACKPORT: sched/sysctl: Fix attributes of some extern declarations
buildtest@lineage:~/android/lineage-16.0/kernel/sony/sdm660$ git bisect good
Bisecting: 2 revisions left to test after this (roughly 1 step)
[84c34e28c08d717f6e615b43211d06787d68e603] icnss: Fix enum-conversion warning from Clang
buildtest@lineage:~/android/lineage-16.0/kernel/sony/sdm660$ git bisect good
Bisecting: 0 revisions left to test after this (roughly 1 step)
[1ff20641d421d5035829ac1aeb4de9fa4d0362b4] sched/sysctl: Fix one more attribute on extern declaration
buildtest@lineage:~/android/lineage-16.0/kernel/sony/sdm660$ git bisect bad
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[1b5bdf14eb955d8ae1b3e11f89ac26172ffa9f30] msm-4.4: Fix strlcpy-strlcat-size Clang warnings
buildtest@lineage:~/android/lineage-16.0/kernel/sony/sdm660$ git bisect bad
1b5bdf14eb955d8ae1b3e11f89ac26172ffa9f30 is the first bad commit
commit 1b5bdf14eb955d8ae1b3e11f89ac26172ffa9f30
Author: Nathan Chancellor <natechancellor@gmail.com>
Date:   Fri Apr 6 23:43:51 2018 -0700

    msm-4.4: Fix strlcpy-strlcat-size Clang warnings

    warning: size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination [-Wstrlcpy-strlcat-size]

    Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

:040000 040000 f1fd51d180d04a5c7e9f52d5987e712b2014edd4 6323f6b67fda0021f62b56f53e2828aada43ae6e M      drivers
buildtest@lineage:~/android/lineage-16.0/kernel/sony/sdm660$ git bisect reset

i was able to nail the problem down, this is the change that makes the kernel unbootable

diff --git a/drivers/thermal/msm_thermal.c b/drivers/thermal/msm_thermal.c
index 7beef24035f8..7b43144e02ae 100644
--- a/drivers/thermal/msm_thermal.c
+++ b/drivers/thermal/msm_thermal.c
@@ -6348,7 +6348,7 @@ static int fetch_cpu_mitigaiton_info(struct msm_thermal_data *data,
            goto fetch_mitig_exit;
        }
        strlcpy((char *) cpus[_cpu].sensor_type, sensor_name,
-           strlen(sensor_name) + 1);
+           strlen((char *) cpus[_cpu].sensor_type) + 1);
        create_alias_name(_cpu, limits, pdev);
    }

i dont understand why that once change breaks but the other changes in the same patch (that do the same thing) just work fine

nathanchance commented 6 years ago

Thanks for doing this investigation I really appreciate it. You can squash that commit into the original warnings fix commit in your tree if you would like. Cheers!