[Android Software/Hacking General [Developers Only]] janjan:
Hello [MENTION=6842057]nathanchance[/MENTION]

I was trying to use the latest Clang (Clang-8.0.1 -r339409) to compile kernel for google pixel 2 xl using your stable source (https://github.com/android-linux-stable/wahoo) but it fails. It failed due to following issue.

In file included from ../include/linux/seqlock.h:35:
In file included from ../include/linux/spinlock.h:57:
../include/linux/bottom_half.h:18:24: error: returning address of label, which is local [-Werror,-Wreturn-stack-address]
__local_bh_disable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
^~~~~~~~~
../include/linux/kernel.h:134:64: note: expanded from macro '_THIS_IP_'
#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
^~~~~~~~
In file included from ../arch/arm64/kernel/asm-offsets.c:21:
In file included from ../include/linux/sched.h:19:
In file included from ../include/linux/timex.h:56:
In file included from ../include/uapi/linux/timex.h:56:
In file included from ../include/linux/time.h:5:
In file included from ../include/linux/seqlock.h:35:
In file included from ../include/linux/spinlock.h:57:
../include/linux/bottom_half.h:31:23: error: returning address of label, which is local [-Werror,-Wreturn-stack-address]
__local_bh_enable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
^~~~~~~~~
../include/linux/kernel.h:134:64: note: expanded from macro '_THIS_IP_'
#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
^~~~~~~~
HOSTCC scripts/dtc/dtc-parser.tab.o
HOSTCC scripts/extract-cert
2 errors generated.
.././Kbuild:55: recipe for target 'arch/arm64/kernel/asm-offsets.s' failed
make[2]: *** [arch/arm64/kernel/asm-offsets.s] Error 1
/home/ajo/123android/msm/wahoo-pie-4.4157/Makefile:1090: recipe for target 'prepare0' failed
make[1]: *** [prepare0] Error 2
make[1]: *** Waiting for unfinished jobs....
HOSTLD scripts/dtc/dtc
HOSTLD scripts/mod/modpost

After a short search i used this patched to fix the issue but it failed again by giving below error.

I used this patched to fix the issue.

patch

Giving error after applying the above patch.

/tmp/vgettimeofday-7e403a.s:6283: Error: invalid operands (.debug_info and *ABS* sections) for `/'
/tmp/vgettimeofday-7e403a.s:6283: Error: division by zero
/tmp/vgettimeofday-7e403a.s:6332: Error: invalid operands (.debug_pubtypes and *ABS* sections) for `/'
/tmp/vgettimeofday-7e403a.s:6332: Error: division by zero
/tmp/vgettimeofday-7e403a.s:6335: Error: invalid operands (.debug_info and *ABS* sections) for `/'
/tmp/vgettimeofday-7e403a.s:6335: Error: division by zero
clang-8: error: assembler command failed with exit code 1 (use -v to see invocation)
../arch/arm64/kernel/vdso/Makefile:70: recipe for target 'arch/arm64/kernel/vdso/vgettimeofday.o' failed
make[2]: *** [arch/arm64/kernel/vdso/vgettimeofday.o] Error 1
arch/arm64/Makefile:215: recipe for target 'vdso_prepare' failed
make[1]: *** [vdso_prepare] Error 2

Patch I applied

#define _RET_IP_	(unsigned long)__builtin_return_address(0)
-#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
+#define _THIS_IP_ (	\
+{	\
+	_Pragma("clang diagnostic push")	\
+	_Pragma("clang diagnostic ignored \"-Wreturn-stack-address\"")	\
+	__label__ __here;	\
+__here: (unsigned long)&&__here;	\
+	_Pragma("clang diagnostic pop")	\
+}	\
+)
#ifdef CONFIG_LBDAF
# include <asm/div64.h>

Do you have any idea about fixing this issue? Thanks in advance

NOTE: There is no issue when using Clang_7.0.2-r328903