Setting up an AOSP build environment

Hello,
I am trying to compile android on OMV Cooker. However, upon compilation I am faced with the following error:

ld.lld: error: cannot open crtbegin.o: No such file or directory
ld.lld: error: unable to find library -lgcc
ld.lld: error: unable to find library -lgcc
ld.lld: error: cannot open crtend.o: No such file or directory
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)

It seems clear that I am missing a package of some sorts, though I can’t for the life of me figure out what, even after installing the aarch64 cross packages that appear when running dnf provides */crtbegin.o
I am not using a DE, I am running Hyprland.

The error.log generated is attached.

FAILED: Building Kernel Config
Outputs: out/target/product/judypn/obj/KERNEL_OBJ/.config
Error: exited with code: 1
Command: /bin/bash -c "(PATH=/ssd/yaap/out/host/linux-x86/bin:\$PATH PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/lib64:\$LD_LIBRARY_PATH PATH=/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/lib:\$LD_LIBRARY_PATH PERL5LIB=/ssd/yaap/prebuilts/tools-lineage/common/perl-base PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/bin:/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:\$PATH /ssd/yaap/prebuilts/build-tools/linux-x86/bin/make  -j28 CPATH=\"/usr/include:/usr/include/x86_64-linux-gnu\" HOSTCFLAGS=\"-fuse-ld=lld\" HOSTLDFLAGS=\"-L/usr/lib/x86_64-linux-gnu -L/usr/lib64 -fuse-ld=lld\" HOSTCC=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang HOSTCXX=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang++ DTC_EXT=/ssd/yaap/out/host/linux-x86/bin/dtc HOSTCFLAGS=\"-fuse-ld=lld -Wno-unused-command-line-argument\" AR=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/llvm-ar LD=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/ld.lld -C kernel/lge/sdm845 O=/ssd/yaap/out/target/product/judypn/obj/KERNEL_OBJ ARCH=arm64 CROSS_COMPILE=\"/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-\" CROSS_COMPILE_ARM32=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CROSS_COMPILE_COMPAT=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CLANG_TRIPLE=aarch64-linux-gnu- CC=\"/usr/bin/ccache clang\"  VARIANT_DEFCONFIG= SELINUX_DEFCONFIG= lineageos_judypn_defconfig ) && (if [ ! -z \"\" ]; then 			echo \"Overriding kernel config with ''\"; 			echo  >> out/target/product/judypn/obj/KERNEL_OBJ/.config; 			PATH=/ssd/yaap/out/host/linux-x86/bin:\$PATH PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/lib64:\$LD_LIBRARY_PATH PATH=/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/lib:\$LD_LIBRARY_PATH PERL5LIB=/ssd/yaap/prebuilts/tools-lineage/common/perl-base PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/bin:/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:\$PATH /ssd/yaap/prebuilts/build-tools/linux-x86/bin/make  -j28 CPATH=\"/usr/include:/usr/include/x86_64-linux-gnu\" HOSTCFLAGS=\"-fuse-ld=lld\" HOSTLDFLAGS=\"-L/usr/lib/x86_64-linux-gnu -L/usr/lib64 -fuse-ld=lld\" HOSTCC=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang HOSTCXX=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang++ DTC_EXT=/ssd/yaap/out/host/linux-x86/bin/dtc HOSTCFLAGS=\"-fuse-ld=lld -Wno-unused-command-line-argument\" AR=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/llvm-ar LD=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/ld.lld -C kernel/lge/sdm845 O=/ssd/yaap/out/target/product/judypn/obj/KERNEL_OBJ ARCH=arm64 CROSS_COMPILE=\"/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-\" CROSS_COMPILE_ARM32=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CROSS_COMPILE_COMPAT=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CLANG_TRIPLE=aarch64-linux-gnu- CC=\"/usr/bin/ccache clang\"  oldconfig; 		fi ) && (if [ \"\" = \"none\" ]; then 			kernel/lge/sdm845/scripts/config --file out/target/product/judypn/obj/KERNEL_OBJ/.config 			-d LTO_CLANG 			-e LTO_NONE 			-d LTO_CLANG_THIN 			-d LTO_CLANG_FULL 			-d THINLTO; 			PATH=/ssd/yaap/out/host/linux-x86/bin:\$PATH PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/lib64:\$LD_LIBRARY_PATH PATH=/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/lib:\$LD_LIBRARY_PATH PERL5LIB=/ssd/yaap/prebuilts/tools-lineage/common/perl-base PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/bin:/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:\$PATH /ssd/yaap/prebuilts/build-tools/linux-x86/bin/make  -j28 CPATH=\"/usr/include:/usr/include/x86_64-linux-gnu\" HOSTCFLAGS=\"-fuse-ld=lld\" HOSTLDFLAGS=\"-L/usr/lib/x86_64-linux-gnu -L/usr/lib64 -fuse-ld=lld\" HOSTCC=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang HOSTCXX=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang++ DTC_EXT=/ssd/yaap/out/host/linux-x86/bin/dtc HOSTCFLAGS=\"-fuse-ld=lld -Wno-unused-command-line-argument\" AR=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/llvm-ar LD=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/ld.lld -C kernel/lge/sdm845 O=/ssd/yaap/out/target/product/judypn/obj/KERNEL_OBJ ARCH=arm64 CROSS_COMPILE=\"/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-\" CROSS_COMPILE_ARM32=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CROSS_COMPILE_COMPAT=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CLANG_TRIPLE=aarch64-linux-gnu- CC=\"/usr/bin/ccache clang\"  olddefconfig; 		elif [ \"\" = \"thin\" ]; then 			kernel/lge/sdm845/scripts/config --file out/target/product/judypn/obj/KERNEL_OBJ/.config 			-e LTO_CLANG 			-d LTO_NONE 			-e LTO_CLANG_THIN 			-d LTO_CLANG_FULL 			-e THINLTO; 			PATH=/ssd/yaap/out/host/linux-x86/bin:\$PATH PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/lib64:\$LD_LIBRARY_PATH PATH=/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/lib:\$LD_LIBRARY_PATH PERL5LIB=/ssd/yaap/prebuilts/tools-lineage/common/perl-base PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/bin:/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:\$PATH /ssd/yaap/prebuilts/build-tools/linux-x86/bin/make  -j28 CPATH=\"/usr/include:/usr/include/x86_64-linux-gnu\" HOSTCFLAGS=\"-fuse-ld=lld\" HOSTLDFLAGS=\"-L/usr/lib/x86_64-linux-gnu -L/usr/lib64 -fuse-ld=lld\" HOSTCC=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang HOSTCXX=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang++ DTC_EXT=/ssd/yaap/out/host/linux-x86/bin/dtc HOSTCFLAGS=\"-fuse-ld=lld -Wno-unused-command-line-argument\" AR=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/llvm-ar LD=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/ld.lld -C kernel/lge/sdm845 O=/ssd/yaap/out/target/product/judypn/obj/KERNEL_OBJ ARCH=arm64 CROSS_COMPILE=\"/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-\" CROSS_COMPILE_ARM32=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CROSS_COMPILE_COMPAT=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CLANG_TRIPLE=aarch64-linux-gnu- CC=\"/usr/bin/ccache clang\"  olddefconfig; 		elif [ \"\" = \"full\" ]; then 			kernel/lge/sdm845/scripts/config --file out/target/product/judypn/obj/KERNEL_OBJ/.config 			-e LTO_CLANG 			-d LTO_NONE 			-d LTO_CLANG_THIN 			-e LTO_CLANG_FULL 			-d THINLTO; 			PATH=/ssd/yaap/out/host/linux-x86/bin:\$PATH PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/lib64:\$LD_LIBRARY_PATH PATH=/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/lib:\$LD_LIBRARY_PATH PERL5LIB=/ssd/yaap/prebuilts/tools-lineage/common/perl-base PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/bin:/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:\$PATH /ssd/yaap/prebuilts/build-tools/linux-x86/bin/make  -j28 CPATH=\"/usr/include:/usr/include/x86_64-linux-gnu\" HOSTCFLAGS=\"-fuse-ld=lld\" HOSTLDFLAGS=\"-L/usr/lib/x86_64-linux-gnu -L/usr/lib64 -fuse-ld=lld\" HOSTCC=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang HOSTCXX=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang++ DTC_EXT=/ssd/yaap/out/host/linux-x86/bin/dtc HOSTCFLAGS=\"-fuse-ld=lld -Wno-unused-command-line-argument\" AR=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/llvm-ar LD=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/ld.lld -C kernel/lge/sdm845 O=/ssd/yaap/out/target/product/judypn/obj/KERNEL_OBJ ARCH=arm64 CROSS_COMPILE=\"/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-\" CROSS_COMPILE_ARM32=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CROSS_COMPILE_COMPAT=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CLANG_TRIPLE=aarch64-linux-gnu- CC=\"/usr/bin/ccache clang\"  olddefconfig; 		fi ) && (PATH=/ssd/yaap/out/host/linux-x86/bin:\$PATH PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/lib64:\$LD_LIBRARY_PATH PATH=/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/lib:\$LD_LIBRARY_PATH PERL5LIB=/ssd/yaap/prebuilts/tools-lineage/common/perl-base PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/bin:/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:\$PATH /ssd/yaap/prebuilts/build-tools/linux-x86/bin/make  -j28 CPATH=\"/usr/include:/usr/include/x86_64-linux-gnu\" HOSTCFLAGS=\"-fuse-ld=lld\" HOSTLDFLAGS=\"-L/usr/lib/x86_64-linux-gnu -L/usr/lib64 -fuse-ld=lld\" HOSTCC=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang HOSTCXX=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang++ DTC_EXT=/ssd/yaap/out/host/linux-x86/bin/dtc HOSTCFLAGS=\"-fuse-ld=lld -Wno-unused-command-line-argument\" AR=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/llvm-ar LD=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/ld.lld -C kernel/lge/sdm845 O=/ssd/yaap/out/target/product/judypn/obj/KERNEL_OBJ ARCH=arm64 CROSS_COMPILE=\"/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-\" CROSS_COMPILE_ARM32=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CROSS_COMPILE_COMPAT=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CLANG_TRIPLE=aarch64-linux-gnu- CC=\"/usr/bin/ccache clang\"  savedefconfig ) && (if [ ! -z \"\" ]; then 			echo \"Using additional config ''\"; 			kernel/lge/sdm845/scripts/kconfig/merge_config.sh -m -O out/target/product/judypn/obj/KERNEL_OBJ out/target/product/judypn/obj/KERNEL_OBJ/.config kernel/lge/sdm845/arch/arm64/configs/; 			PATH=/ssd/yaap/out/host/linux-x86/bin:\$PATH PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/lib64:\$LD_LIBRARY_PATH PATH=/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin:\$PATH LD_LIBRARY_PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/lib:\$LD_LIBRARY_PATH PERL5LIB=/ssd/yaap/prebuilts/tools-lineage/common/perl-base PATH=/ssd/yaap/prebuilts/tools-lineage/linux-x86/bin:/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:\$PATH /ssd/yaap/prebuilts/build-tools/linux-x86/bin/make  -j28 CPATH=\"/usr/include:/usr/include/x86_64-linux-gnu\" HOSTCFLAGS=\"-fuse-ld=lld\" HOSTLDFLAGS=\"-L/usr/lib/x86_64-linux-gnu -L/usr/lib64 -fuse-ld=lld\" HOSTCC=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang HOSTCXX=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-r450784d/bin/clang++ DTC_EXT=/ssd/yaap/out/host/linux-x86/bin/dtc HOSTCFLAGS=\"-fuse-ld=lld -Wno-unused-command-line-argument\" AR=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/llvm-ar LD=/ssd/yaap/prebuilts/clang/host/linux-x86/clang-proton/bin/ld.lld -C kernel/lge/sdm845 O=/ssd/yaap/out/target/product/judypn/obj/KERNEL_OBJ ARCH=arm64 CROSS_COMPILE=\"/ssd/yaap/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-\" CROSS_COMPILE_ARM32=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CROSS_COMPILE_COMPAT=\"/ssd/yaap/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel-\" CLANG_TRIPLE=aarch64-linux-gnu- CC=\"/usr/bin/ccache clang\"  KCONFIG_ALLCONFIG=/ssd/yaap/out/target/product/judypn/obj/KERNEL_OBJ/.config alldefconfig; 		fi )"
Output:
make: Entering directory '/ssd/yaap/kernel/lge/sdm845'
make[1]: Entering directory '/ssd/yaap/out/target/product/judypn/obj/KERNEL_OBJ'
  HOSTCC  scripts/basic/fixdep
  GEN     ./Makefile
ld.lld: error: cannot open crtbegin.o: No such file or directory
ld.lld: error: unable to find library -lgcc
ld.lld: error: unable to find library -lgcc
ld.lld: error: cannot open crtend.o: No such file or directory
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [scripts/Makefile.host:101: scripts/basic/fixdep] Error 1
make[1]: *** [/ssd/yaap/kernel/lge/sdm845/Makefile:466: scripts_basic] Error 2
make[1]: Leaving directory '/ssd/yaap/out/target/product/judypn/obj/KERNEL_OBJ'
make: *** [Makefile:152: sub-make] Error 2
make: Leaving directory '/ssd/yaap/kernel/lge/sdm845'

What can I do?

Many thanks,
Collin

Hi,
what exactly are you trying to build? Last time I checked, AOSP neither used gcc nor did it try to compile a kernel from source. This looks more like LineageOS or something derived from that.

LineageOS and its derivates can’t find libgcc.a, crtend.o because it hardcodes where Debian puts those files (which happens to be a different location). This is easy to fix though.

Edit vendor/lineage/config/BoardConfigKernel.mk (that file might live in a slightly different location or have a slightly different name depending on LineageOS version or derived tree).

Find the line saying

KERNEL_MAKE_FLAGS += CPATH="/usr/include:/usr/include/x86_64-linux-gnu" HOSTCFLAGS="-fuse-ld=lld" HOSTLDFLAGS="-L/usr/lib/x86_64-linux-gnu -L/usr/lib64 -fuse-ld=lld"

And replace it with

KERNEL_MAKE_FLAGS += CPATH="/usr/include:/usr/include/x86_64-linux-gnu" HOSTCFLAGS="-fuse-ld=lld" HOSTLDFLAGS="-L/usr/lib/x86_64-linux-gnu -L$(shell /usr/bin/dirname $(shell /usr/bin/gcc -print-libgcc-file-name)) -B$(shell /usr/bin/dirname $(shell /usr/bin/gcc -print-libgcc-file-name)) -L/usr/lib64 -fuse-ld=lld"

I’ve been meaning to send that patch to the Lineage guys for a while, just never got around to it

Hello,
Thank you so much, you’re a lifesaver!
And yes I’d neglected to specify that it’s a rom (YAAP specifically) and not stock AOSP, that’s my bad.

Changing that line worked and it’s now compiling smoothly.