Skip to content
  • Nathan Chancellor's avatar
    f634ca65
    kbuild: Add $(KBUILD_HOSTLDFLAGS) to 'has_libelf' test · f634ca65
    Nathan Chancellor authored
    Normally, invocations of $(HOSTCC) include $(KBUILD_HOSTLDFLAGS), which
    in turn includes $(HOSTLDFLAGS), which allows users to pass in their own
    flags when linking. However, the 'has_libelf' test does not, meaning
    that if a user requests a specific linker via HOSTLDFLAGS=-fuse-ld=...,
    it is not respected and the build might error.
    
    For example, if a user building with clang wants to use all of the LLVM
    tools without any GNU tools, they might remove all of the GNU tools from
    their system or PATH then build with
    
    $ make HOSTLDFLAGS=-fuse-ld=lld LLVM=1 LLVM_IAS=1
    
    which says use all of the LLVM tools, the integrated assembler, and
    ld.lld for linking host executables. Without this change, the build will
    error because $(HOSTCC) uses its default linker, rather than the one
    requested via -fuse-ld=..., which is GNU ld in clang's case in a default
    configuration.
    
    error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please
    install libelf-dev, libelf-devel or elfutils-libelf-devel
    make[1]: *** [Makefile:1260: prepare-objtool] Error 1
    
    Add $(KBUILD_HOSTLDFLAGS) to the 'has_libelf' test so that the linker
    choice is respected.
    
    Link: https://github.com/ClangBuiltLinux/linux/issues/479
    
    
    Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
    Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
    f634ca65
    kbuild: Add $(KBUILD_HOSTLDFLAGS) to 'has_libelf' test
    Nathan Chancellor authored
    Normally, invocations of $(HOSTCC) include $(KBUILD_HOSTLDFLAGS), which
    in turn includes $(HOSTLDFLAGS), which allows users to pass in their own
    flags when linking. However, the 'has_libelf' test does not, meaning
    that if a user requests a specific linker via HOSTLDFLAGS=-fuse-ld=...,
    it is not respected and the build might error.
    
    For example, if a user building with clang wants to use all of the LLVM
    tools without any GNU tools, they might remove all of the GNU tools from
    their system or PATH then build with
    
    $ make HOSTLDFLAGS=-fuse-ld=lld LLVM=1 LLVM_IAS=1
    
    which says use all of the LLVM tools, the integrated assembler, and
    ld.lld for linking host executables. Without this change, the build will
    error because $(HOSTCC) uses its default linker, rather than the one
    requested via -fuse-ld=..., which is GNU ld in clang's case in a default
    configuration.
    
    error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please
    install libelf-dev, libelf-devel or elfutils-libelf-devel
    make[1]: *** [Makefile:1260: prepare-objtool] Error 1
    
    Add $(KBUILD_HOSTLDFLAGS) to the 'has_libelf' test so that the linker
    choice is respected.
    
    Link: https://github.com/ClangBuiltLinux/linux/issues/479
    
    
    Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
    Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Loading