tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Cross compiling Kernel with all options enabled and compiler wrapper



On 22/08/2025 13:45, RVP wrote:
This worked (though g++ griped about the `-std=gnu17'):

```
HOST_CFLAGS=-std=gnu17 HOST_CPPFLAGS=-std=gnu17 ./build.sh -j6 -N1 -M/tmp/obj -T/tmp/tools -m amd64 -U tools ```

I was able to compile the toolchain successfully with your provided command, but unfortunately I need to use clang. After a lot of trying, I did manage to compile the clang-toolchain with some modifications to the source:

src/external/apache2/llvm/dist/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h:

``` diff

15a16
> #include <cstdint>
```

src/tools/file/Makefile:

``` diff

12c12
<         --disable-warnings --disable-libseccomp
---
>         --disable-warnings --disable-libseccomp --disable-dependency-tracking
```

And the command `HOST_CFLAGS="-std=gnu11" HOST_CXXFLAGS="-std=gnu++11" HOST_CC="/usr/bin/clang" HOST_CXX="/usr/bin/clang++" ./build.sh -U -m amd64 -c clang -j 17 tools` (using host clang is probably unnecessary).


Finally I am able to compile the kernel, using the GENERIC config works but I'm having some trouble with the ALL config, the compilation fails with the following errors (I already commented out Intel QuickAssust because it didn't compile):

--- libkern.o ---
building standard kern library
/home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/tooldir.Linux-6.16.3-arch1-1-x86_64/bin/x86_64--netbsd-ld: cannot find /home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/tooldir.Linux-6.16.3-arch1-1-x86_64/lib/clang/13.0.0/lib/netbsd/libclang_rt.ubsan_standalone-x86_64.a: No such file or directory x86_64--netbsd-clang: error: linker command failed with exit code 1 (use -v to see invocation)

*** Failed target: libkern.o
*** Failed commands:
    @echo building standard ${.TARGET:T:S/.o//:S/lib//} library
    => @echo building standard kern library
    @rm -f ${.TARGET}
    => @rm -f libkern.o
    @${LINK.c:S/-nostdinc//} -nostdlib ${LDFLAGS} -Wno-unused-command-line-argument -r -o ${.TARGET} $$(NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT})     => @/home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/tooldir.Linux-6.16.3-arch1-1-x86_64/bin/x86_64--netbsd-clang -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -mno-avx -msoft-float -fsanitize=kernel-address -mllvm -asan-globals=1 -mllvm -asan-stack=1 -mllvm -asan-instrument-dynamic-allocas=1 -mllvm -asan-use-after-scope=1 -mllvm -asan-instrumentation-with-call-threshold=0 -mllvm -asan-mapping-offset=0xDFFF900000000000 -ffreestanding -fno-zero-initialized-in-bss -g -O2 -fno-omit-frame-pointer -fstack-protector -Wstack-protector --param ssp-buffer-size=1 -fno-strict-aliasing -fno-common -std=gnu99 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-unreachable-code -Wno-pointer-sign -Wno-attributes -Wno-type-limits -Wextra -Wno-unused-parameter -Wold-style-definition -Wno-sign-compare -Walloca -Wno-unknown-pragmas -Wno-conversion -Wno-self-assign -Wno-error=address-of-packed-member -Wno-error=constant-conversion -fsanitize-coverage=trace-pc,trace-cmp -fsanitize=undefined --sysroot=/home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/destdir.amd64 -Wl,-z,relro -nostdlib --sysroot=/home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/destdir.amd64 -Wl,-z,relro -Wno-unused-command-line-argument -r -o libkern.o $(NM=/home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/tooldir.Linux-6.16.3-arch1-1-x86_64/bin/x86_64--netbsd-nm NM=/home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/tooldir.Linux-6.16.3-arch1-1-x86_64/bin/x86_64--netbsd-nm MKTEMP=/home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/tooldir.Linux-6.16.3-arch1-1-x86_64/bin/nbmktemp /home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/tooldir.Linux-6.16.3-arch1-1-x86_64/bin/nblorder __main.o absvdi2.o absvsi2.o absvti2.o addvdi3.o addvsi3.o addvti3.o ashldi3.o ashlti3.o ashrdi3.o ashrti3.o atomic.o byte_swap_2.o byte_swap_4.o byte_swap_8.o cdbr.o clzdi2.o clzsi2.o clzti2.o cmpdi2.o cmpti2.o consttime_memequal.o copystr.o cpuset.o crc32.o ctzdi2.o ctzsi2.o ctzti2.o disklabel_swap.o divdi3.o divmoddi4.o divmodsi4.o divsi3.o divti3.o dkcksum.o entpool.o explicit_memset.o ffs.o ffsdi2.o ffsti2.o getfstypename.o heapsort.o hexdump.o imax.o imin.o inet_addr.o int_util.o intoa.o keccak.o kern_assert.o lmax.o lmin.o lshrdi3.o lshrti3.o mcount.o md4c.o md5c.o memchr.o memcmp.o memcpy.o memmem.o memmove.o memset.o mi_vector_hash.o moddi3.o modsi3.o modti3.o muldi3.o mulodi4.o mulosi4.o muloti4.o multi3.o mulvdi3.o mulvsi3.o mulvti3.o murmurhash.o negdi2.o negti2.o negvdi2.o negvsi2.o negvti2.o paritydi2.o paritysi2.o parityti2.o pmatch.o popcount32.o popcount64.o popcountdi2.o popcountsi2.o popcountti2.o ppath.o ppath_extant.o ppath_kmem_alloc.o proc_compare.o prop_array.o prop_array_util.o prop_bool.o prop_data.o prop_dictionary.o prop_dictionary_util.o prop_ingest.o prop_kern.o prop_number.o prop_object.o prop_stack.o prop_string.o ptree.o radixtree.o random.o rb.o rmd160.o rngtest.o rpst.o scanc.o sha1.o sha2.o sha3.o skpc.o snprintb.o strcasecmp.o strcat.o strchr.o strcmp.o strcpy.o strcspn.o strlcat.o strlcpy.o strlen.o strlist.o strncasecmp.o strncat.o strncmp.o strncpy.o strnlen.o strnvisx.o strpbrk.o strrchr.o strsep.o strspn.o strstr.o strtoi.o strtoimax.o strtoll.o strtou.o strtoul.o strtoull.o strtoumax.o subvdi3.o subvsi3.o subvti3.o ucmpdi2.o ucmpti2.o udivdi3.o udivmoddi4.o udivmodsi4.o udivmodti4.o udivsi3.o udivti3.o uimax.o uimin.o ulmax.o ulmin.o umoddi3.o umodsi3.o umodti3.o xlat_mbr_fstype.o | /home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/tooldir.Linux-6.16.3-arch1-1-x86_64/bin/nbtsort -q)
*** [libkern.o] Error code 1

nbmake[1]: stopped in /home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/sys/arch/amd64/compile/ALL_COMPILEABLE/lib/kern
1 error

nbmake[1]: stopped in /home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/sys/arch/amd64/compile/ALL_COMPILEABLE/lib/kern

nbmake: stopped in /home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/sys/arch/amd64/compile/ALL_COMPILEABLE
--- x86emu.o ---
/home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/tooldir.Linux-6.16.3-arch1-1-x86_64/bin/nbctfconvert -g -L VERSION -g x86emu.o
--- zlib.o ---
/home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/tooldir.Linux-6.16.3-arch1-1-x86_64/bin/nbctfconvert -g -L VERSION -g zlib.o
--- xhci.o ---
/home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/tooldir.Linux-6.16.3-arch1-1-x86_64/bin/nbctfconvert -g -L VERSION -g xhci.o



I ran the command manually with -v to see the linker error:
/home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/tooldir.Linux-6.16.3-arch1-1-x86_64/bin/x86_64--netbsd-ld: cannot find /home/nando/Documents/Schule/Maturitaetsarbeit/neu/netbsd-src-ftp/src/obj/tooldir.Linux-6.16.3-arch1-1-x86_64/lib/clang/13.0.0/lib/netbsd/libclang_rt.ubsan_standalone-x86_64.a: No such file or directory

I can't figure out how to configure the build system to compile this file, and copying a precompiled one (from the Arch Linux package manager) didn't work either.


-Nando



Home | Main Index | Thread Index | Old Index