dslm4515 / CMLFS

Clang-Built Musl Linux From Scratch
MIT License
99 stars 18 forks source link

llvmtools: 01-kernel-headers fails to compile using `LLVM=1` #10

Closed owl4ce closed 3 years ago

owl4ce commented 3 years ago

Gives me an error:

  HOSTCC  scripts/basic/fixdep
/bin/sh: line 1: scripts/basic/fixdep: No such file or directory
make[1]: *** [scripts/Makefile.host:95: scripts/basic/fixdep] Error 127
make[1]: *** Deleting file 'scripts/basic/fixdep'
make: *** [Makefile:535: scripts_basic] Error 2

Know issue: scripts/basic/fixdep.c failed to compile when using stage0 clang/llvm

dslm4515 commented 3 years ago

I am rebuilding CMLFS with LLVM11.0.0... and got this issue too. Previous build used older kernel source.

Kernel headers 5.12.x will not build with LLVM=1.

For now just use CC=clang CXX=clang++ make headers

owl4ce commented 3 years ago

Got it, thanks for the confirmation.

owl4ce commented 3 years ago

@dslm4515 This is strange, successfully build headers with ARCH=${CMLFS_ARCH} LLVM=1 CC=clang CXX=clang++ HOSTCC=${CMLFS_TARGET}-clang make headers

but not with HOSTCC in default (clang), altough it same symlinked to clang-12

owl4ce commented 3 years ago

@dslm4515 This is strange, successfully build headers with ARCH=${CMLFS_ARCH} LLVM=1 CC=clang CXX=clang++ HOSTCC=${CMLFS_TARGET}-clang make headers

but not with HOSTCC in default (clang), altough it same symlinked to clang-12

So, I think its succesful to build when HOSTCC value is uses same name in CMLFS_TARGET, when using clang-12 and clang still fails. And ${CMLFS_TARGET}-clang already symlinked to clang-12 when building stage0 clang.

dslm4515 commented 3 years ago

I always found it hard to find and remember what environment variables (i.e.HOSTCC) can be set when building with the kernel source....

Still failed for me:

cmlfs@amd64550:/mnt/cmlfs/sources/linux-5.12.10$ make mrproper -j2
  CLEAN   usr/include
  CLEAN   arch/x86/tools
  CLEAN   scripts/basic
  CLEAN   scripts
  CLEAN   include/generated arch/x86/include/generated
cmlfs@amd64550:/mnt/cmlfs/sources/linux-5.12.10$ ARCH=${CMLFS_ARCH} LLVM=1 CC=clang CXX=clang++ HOS
TCC=${CMLFS_TARGET}-clang make headers -j2
  HOSTCC  scripts/basic/fixdep
  WRAP    arch/x86/include/generated/uapi/asm/bpf_perf_event.h
  WRAP    arch/x86/include/generated/uapi/asm/errno.h
  WRAP    arch/x86/include/generated/uapi/asm/fcntl.h
  WRAP    arch/x86/include/generated/uapi/asm/ioctl.h
  WRAP    arch/x86/include/generated/uapi/asm/ioctls.h
  WRAP    arch/x86/include/generated/uapi/asm/ipcbuf.h
  WRAP    arch/x86/include/generated/uapi/asm/param.h
  WRAP    arch/x86/include/generated/uapi/asm/poll.h
  WRAP    arch/x86/include/generated/uapi/asm/resource.h
  WRAP    arch/x86/include/generated/uapi/asm/socket.h
  WRAP    arch/x86/include/generated/uapi/asm/sockios.h
  WRAP    arch/x86/include/generated/uapi/asm/termbits.h
  WRAP    arch/x86/include/generated/uapi/asm/termios.h
  WRAP    arch/x86/include/generated/uapi/asm/types.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_32.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_64.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_x32.h
  SYSTBL  arch/x86/include/generated/asm/syscalls_32.h
/bin/sh: scripts/basic/fixdep: No such file or directory
make[1]: *** [scripts/Makefile.host:95: scripts/basic/fixdep] Error 127
make[1]: *** Deleting file 'scripts/basic/fixdep'
make: *** [Makefile:535: scripts_basic] Error 2
make: *** Waiting for unfinished jobs....

for reference:

echo ${CMLFS_TARGET}-clang
x86_64-cmlfs-linux-musl-clang

which x86_64-cmlfs-linux-musl-clang
/cgnutools/bin/x86_64-cmlfs-linux-musl-clang

file /cgnutools/bin/x86_64-cmlfs-linux-musl-clang
/cgnutools/bin/x86_64-cmlfs-linux-musl-clang: symbolic link to clang-11
owl4ce commented 3 years ago

Reference about kernel's makefile environment variables. https://www.kernel.org/doc/html/latest/kbuild/llvm.html

owl4ce commented 3 years ago

I always found it hard to find and remember what environment variables (i.e.HOSTCC) can be set when building with the kernel source....

Still failed for me:

cmlfs@amd64550:/mnt/cmlfs/sources/linux-5.12.10$ make mrproper -j2
  CLEAN   usr/include
  CLEAN   arch/x86/tools
  CLEAN   scripts/basic
  CLEAN   scripts
  CLEAN   include/generated arch/x86/include/generated
cmlfs@amd64550:/mnt/cmlfs/sources/linux-5.12.10$ ARCH=${CMLFS_ARCH} LLVM=1 CC=clang CXX=clang++ HOS
TCC=${CMLFS_TARGET}-clang make headers -j2
  HOSTCC  scripts/basic/fixdep
  WRAP    arch/x86/include/generated/uapi/asm/bpf_perf_event.h
  WRAP    arch/x86/include/generated/uapi/asm/errno.h
  WRAP    arch/x86/include/generated/uapi/asm/fcntl.h
  WRAP    arch/x86/include/generated/uapi/asm/ioctl.h
  WRAP    arch/x86/include/generated/uapi/asm/ioctls.h
  WRAP    arch/x86/include/generated/uapi/asm/ipcbuf.h
  WRAP    arch/x86/include/generated/uapi/asm/param.h
  WRAP    arch/x86/include/generated/uapi/asm/poll.h
  WRAP    arch/x86/include/generated/uapi/asm/resource.h
  WRAP    arch/x86/include/generated/uapi/asm/socket.h
  WRAP    arch/x86/include/generated/uapi/asm/sockios.h
  WRAP    arch/x86/include/generated/uapi/asm/termbits.h
  WRAP    arch/x86/include/generated/uapi/asm/termios.h
  WRAP    arch/x86/include/generated/uapi/asm/types.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_32.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_64.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_x32.h
  SYSTBL  arch/x86/include/generated/asm/syscalls_32.h
/bin/sh: scripts/basic/fixdep: No such file or directory
make[1]: *** [scripts/Makefile.host:95: scripts/basic/fixdep] Error 127
make[1]: *** Deleting file 'scripts/basic/fixdep'
make: *** [Makefile:535: scripts_basic] Error 2
make: *** Waiting for unfinished jobs....

for reference:

echo ${CMLFS_TARGET}-clang
x86_64-cmlfs-linux-musl-clang

which x86_64-cmlfs-linux-musl-clang
/cgnutools/bin/x86_64-cmlfs-linux-musl-clang

file /cgnutools/bin/x86_64-cmlfs-linux-musl-clang
/cgnutools/bin/x86_64-cmlfs-linux-musl-clang: symbolic link to clang-11

Try to arrange make to first argument.

make -j2 ARCH=${CMLFS_ARCH} LLVM=1 CC=clang CXX=clang++ HOSTCC=${CMLFS_TARGET}-clang headers

I'm also recommending to all to using it. I think CC and CXX also useless in this case, because already set in LLVM=1, other arguments behind it just overriding if I'm not wrong.

dslm4515 commented 3 years ago

Try to arrange make to first argument.

okay, now it works. Wow. Going to make the change...1f7f84e