[Android Software/Hacking General [Developers Only]] Bladehawkz:
Clang Segfaults

Attempting to compile Nathanchance's Flash Kernel for Marlin using Clang result in multiple Segmentation Faults during compilation. These segfaults do not occur when attempting to compile without Clang.

This occurs regardless of Clang chosen (google's Clang-4691093 for Pie, or DragonTC-7.0 prebuilt from xanaxdroid's git repo), or GCC Cross-compilers (aarch64 and arm32 toolchains recommended on this thread, and self-build Linaro 6.x Toolchains using nathanchance's build script). Both debian 9.6 and Ubuntu 18.04.1 systems were tested.

Commands issued are

>make O=out ARCH=arm64 flash_defconfig

>make -j4 O=out \

> ARCH=arm64 \

> CC="/home/david/android/dtc/dragontc-7.0/bin/clang" \

> CLANG_TRIPLE=aarch64-linux-gnu- \

> CROSS_COMPILE="/home/david/android/Linaro-6.x-arm64/aarch64-linux-gnu/bin/aarch64-linux-gnu-" \

> CROSS_COMPILE_ARM32="/home/david/android/Linaro-6.x-arm/arm-linux-gnueabi/bin/arm-linux-gnueabi-"

(With relevant file path' changed depending on toolchains used)

The following is example output of how the segfault occurs (appears to occur for specific files/modules, and then ignored in the total compilation). Output zimage untested for obvious reasons, but it is created. Full compilation output is attached.

make[1]: Entering directory '/home/david/android/kernel/marlin/out'
Segmentation fault (core dumped)
Segmentation fault (core dumped)
GEN ./Makefile
scripts/kconfig/conf --silentoldconfig Kconfig
Segmentation fault (core dumped)
Segmentation fault (core dumped)
CHK include/config/kernel.release
UPD include/config/kernel.release
Segmentation fault (core dumped)
Segmentation fault (core dumped)
GEN ./Makefile
WRAP arch/arm64/include/generated/asm/checksum.h
WRAP arch/arm64/include/generated/asm/clkdev.h
WRAP arch/arm64/include/generated/asm/bugs.h
...
...
LD drivers/staging/built-in.o
LD drivers/built-in.o
Segmentation fault (core dumped)
LINK vmlinux
LD vmlinux.o
MODPOST vmlinux.o
GEN .version
CHK include/generated/compile.h
UPD include/generated/compile.h
CC init/version.o
LD init/built-in.o
KSYM .tmp_kallsyms1.o
KSYM .tmp_kallsyms2.o
LD vmlinux
SORTEX vmlinux
SYSMAP System.map
Segmentation fault (core dumped)
DTC arch/arm64/boot/dts/htc/msm8996pro-htc_sailfish-a.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-v1.1-htc_marlin-xc.dtb
OBJCOPY arch/arm64/boot/Image
Segmentation fault (core dumped)
Building modules, stage 2.
MODPOST 0 modules
DTC arch/arm64/boot/dts/htc/msm8996pro-htc_sailfish-xb.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-v1.1-htc_sailfish-xd.dtb
DTC arch/arm64/boot/dts/htc/msm8996-v3-htc_marlin-xb.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-htc_sailfish-xc.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-v1.1-htc_marlin-xd.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-v1.1-htc_sailfish-a.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-htc_marlin-xb.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-v1.1-htc_marlin-a.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-htc_sailfish-xd.dtb
DTC arch/arm64/boot/dts/htc/msm8996-v3-htc_sailfish-xa.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-htc_marlin-xa.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-htc_marlin-xc.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-htc_sailfish-xa.dtb
DTC arch/arm64/boot/dts/htc/msm8996-v3-htc_sailfish-xb.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-htc_marlin-xd.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-v1.1-htc_sailfish-xc.dtb
DTC arch/arm64/boot/dts/htc/msm8996pro-htc_marlin-a.dtb
DTC arch/arm64/boot/dts/htc/msm8996-v3-htc_marlin-xa.dtb
LZ4 arch/arm64/boot/Image.lz4
CAT arch/arm64/boot/Image.lz4-dtb
make[1]: Leaving directory '/home/david/android/kernel/marlin/out'