• Re: LLVM Linker

    From Jeffrey Walton@21:1/5 to riesebie@lxtec.de on Sat Oct 16 17:00:01 2021
    On Sat, Oct 16, 2021 at 10:16 AM Elimar Riesebieter <riesebie@lxtec.de> wrote:

    does somebody knows why lld isn't available for powerpc?

    I don't have an answer to this. Maybe the LLVM folks have not provided
    it? Maybe it is available, but not on-path?

    (LLVM has some sharp edges on PowerPC. I ran into a fair amount of
    trouble in the past, when I was building LLVM/Compiler-Rt/libc++ for
    PPC).

    compile a kernel with
    'make LLVM=1 HOSTCC=/usr/bin/clang-13 HOSTCXX=/usr/bin/clang++-13 CC=/usr/bin/clang-13'
    where LLVM=1 points to the llvm linker. Without LLVM-1 it seems to use the binutils.

    I believe it depends on the builtin makefile rules and what the author
    of the makefile is doing.

    You can check the builtin makefile rules with '-p' option:

    $ make -p | grep -E 'LD|LINK'
    ...
    LINK.m = $(OBJC) $(OBJCFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
    LINK.o = $(CC) $(LDFLAGS) $(TARGET_ARCH)
    LINK.p = $(PC) $(PFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
    LINK.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
    LD = ld
    LINK.r = $(FC) $(FFLAGS) $(RFLAGS) $(LDFLAGS) $(TARGET_ARCH)
    LINK.C = $(LINK.cc)
    LINK.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_MACH)
    LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
    LINK.s = $(CC) $(ASFLAGS) $(LDFLAGS) $(TARGET_MACH)
    LINK.cpp = $(LINK.cc)
    ...

    If you want to use a different linker, then set the variable LD to that linker.

    Jeff

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Elimar Riesebieter@21:1/5 to All on Sat Oct 16 16:20:01 2021
    Hi all,

    does somebody knows why lld isn't available for powerpc? I want to
    compile a kernel with
    'make LLVM=1 HOSTCC=/usr/bin/clang-13 HOSTCXX=/usr/bin/clang++-13 CC=/usr/bin/clang-13'
    where LLVM=1 points to the llvm linker. Without LLVM-1 it seems to use the binutils.

    Thanks
    Elimar
    --
    Do you smell something burning or is it me?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Elimar Riesebieter@21:1/5 to All on Sat Oct 16 18:00:02 2021
    * Jeffrey Walton <noloader@gmail.com> [2021-10-16 10:53 -0400]:

    On Sat, Oct 16, 2021 at 10:16 AM Elimar Riesebieter <riesebie@lxtec.de> wrote:

    does somebody knows why lld isn't available for powerpc?

    [...]

    You can check the builtin makefile rules with '-p' option:

    $ make -p | grep -E 'LD|LINK'
    ...
    LINK.m = $(OBJC) $(OBJCFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
    LINK.o = $(CC) $(LDFLAGS) $(TARGET_ARCH)
    LINK.p = $(PC) $(PFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
    LINK.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
    LD = ld
    LINK.r = $(FC) $(FFLAGS) $(RFLAGS) $(LDFLAGS) $(TARGET_ARCH)
    LINK.C = $(LINK.cc)
    LINK.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_MACH)
    LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
    LINK.s = $(CC) $(ASFLAGS) $(LDFLAGS) $(TARGET_MACH)
    LINK.cpp = $(LINK.cc)
    ...

    If you want to use a different linker, then set the variable LD to that linker.

    I believe this is what LLVM=1 does. Start a compile with LVM=1 set
    ld.lld, which is part of ldd package, isn't found.

    Elimar
    --
    From The Collaborative International Dictionary of English v.0.48 [gcide]:
    .
    arsehole \arse"hole`\ ([aum]rs"h[=o]l`), n.
    1. execretory opening at the end of the alimentary canal.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jeffrey Walton@21:1/5 to All on Sat Oct 16 19:50:02 2021
    If you want to use a different linker, then set the variable LD to that linker.

    I believe this is what LLVM=1 does. Start a compile with LVM=1 set
    ld.lld, which is part of ldd package, isn't found.

    You might try -fuse-ld=lld. From https://lld.llvm.org/:

    If you don’t want to change the system setting,
    you can use clang’s -fuse-ld option. In this way,
    you want to set -fuse-ld=lld to LDFLAGS when
    building your programs.

    Jeff

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Paul Adrian Glaubitz@21:1/5 to Elimar Riesebieter on Sat Oct 16 22:50:01 2021
    Hello!

    On 10/16/21 16:09, Elimar Riesebieter wrote:
    does somebody knows why lld isn't available for powerpc?

    It's not available because we're currently not building LLVM for powerpc and ppc64, see:

    https://salsa.debian.org/pkg-llvm-team/llvm-toolchain/-/blob/snapshot/debian/rules#L284

    It's most likely disabled because it failed building in the past but it might work these days. I haven't tried but I will maybe give it a try in the upcoming days.

    Adrian

    --
    .''`. John Paul Adrian Glaubitz
    : :' : Debian Developer - glaubitz@debian.org
    `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
    `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jeffrey Walton@21:1/5 to glaubitz@physik.fu-berlin.de on Sat Oct 16 23:50:01 2021
    On Sat, Oct 16, 2021 at 4:43 PM John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> wrote:

    On 10/16/21 16:09, Elimar Riesebieter wrote:
    does somebody knows why lld isn't available for powerpc?

    It's not available because we're currently not building LLVM for powerpc and ppc64, see:

    According to https://lld.llvm.org, PowerPC and PowerPC64 are supported arches:

    It supports various CPUs/ABIs including AArch64, AMDGPU, ARM, Hexagon,
    MIPS 32/64 big/little-endian, PowerPC, PowerPC64, RISC-V, SPARC V9,
    x86-32 and x86-64. Among these, AArch64, ARM (>= v6), PowerPC,
    PowerPC64, x86-32 and x86-64 have production quality. MIPS seems
    decent too.

    It may be time to give lld a whirl.

    libcxx and libcxxabi may be a different story, however.

    Jeff

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Elimar Riesebieter@21:1/5 to All on Sun Oct 17 02:00:01 2021
    * Jeffrey Walton <noloader@gmail.com> [2021-10-16 13:47 -0400]:

    If you want to use a different linker, then set the variable LD to that linker.

    I believe this is what LLVM=1 does. Start a compile with LVM=1 set
    ld.lld, which is part of ldd package, isn't found.

    You might try -fuse-ld=lld. From https://lld.llvm.org/:

    If you don’t want to change the system setting,
    you can use clang’s -fuse-ld option. In this way,
    you want to set -fuse-ld=lld to LDFLAGS when
    building your programs.

    Jeff


    * Jeffrey Walton <noloader@gmail.com> [2021-10-16 17:44 -0400]:

    On Sat, Oct 16, 2021 at 4:43 PM John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> wrote:

    On 10/16/21 16:09, Elimar Riesebieter wrote:
    does somebody knows why lld isn't available for powerpc?

    It's not available because we're currently not building LLVM for powerpc and
    ppc64, see:

    According to https://lld.llvm.org, PowerPC and PowerPC64 are supported arches:

    It supports various CPUs/ABIs including AArch64, AMDGPU, ARM, Hexagon,
    MIPS 32/64 big/little-endian, PowerPC, PowerPC64, RISC-V, SPARC V9,
    x86-32 and x86-64. Among these, AArch64, ARM (>= v6), PowerPC,
    PowerPC64, x86-32 and x86-64 have production quality. MIPS seems
    decent too.

    It may be time to give lld a whirl.

    libcxx and libcxxabi may be a different story, however.

    Linux version 5.14.12-aragorn-lxtec-ppc (riesebie@aragorn) (Debian clang version 13.0.0-5, GNU ld (GNU Binutils for Debian) 2.37) #1lxtecppc1 Sat Oct 16 20:13:36 CEST 2021

    Well, linking witch the GNU linker works. Compiletime 4.5 h.
    Compiling completely with gcc the same config needs only 2 h.

    Will investigate further when ldd is available.

    Thanks in advance
    Elimar
    --
    Never make anything simple and efficient when a way
    can be found to make it complex and wonderful ;-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Paul Adrian Glaubitz@21:1/5 to Jeffrey Walton on Sun Oct 17 09:40:02 2021
    On 10/16/21 23:44, Jeffrey Walton wrote:> According to https://lld.llvm.org, PowerPC and PowerPC64 are supported arches:

    It supports various CPUs/ABIs including AArch64, AMDGPU, ARM, Hexagon,
    MIPS 32/64 big/little-endian, PowerPC, PowerPC64, RISC-V, SPARC V9,
    x86-32 and x86-64. Among these, AArch64, ARM (>= v6), PowerPC,
    PowerPC64, x86-32 and x86-64 have production quality. MIPS seems
    decent too.

    It may be time to give lld a whirl.

    Build fails on 32-bit PowerPC with LLDB enabled with a linker failure, see below.

    Will try 64-bit PowerPC now.

    Adrian

    FAILED: bin/lldb-server
    : && /home/glaubitz/llvm13/llvm-toolchain-13-13.0.0/build-llvm/./bin/clang++ -fPIC -Wno-unused-command-line-argument -Wno-unknown-warning-option -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-
    availability-new -Wall -Wex
    tra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-class-memaccess -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-
    virtual-dtor -Ws
    uggest-override -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -O2 -DNDEBUG -g1 -Wl,-
    z,relro -Wl,- rpath-link,/home/glaubitz/llvm13/llvm-toolchain-13-13.0.0/build-llvm/tools/clang/stage2-bins/./lib -Wl,-O3 -Wl,--gc-sections tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/Acceptor.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/
    lldb-gdbserver.cp
    p.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/lldb-platform.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/lldb-server.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/LLDBServerUtilities.cpp.o tools/lldb/tools/
    lldb-server/CMake
    Files/lldb-server.dir/SystemInitializerLLGS.cpp.o -o bin/lldb-server -Wl,-rpath,"\$ORIGIN/../lib" -lpthread lib/liblldbBase.a lib/liblldbHost.a lib/liblldbInitialization.a lib/liblldbPluginProcessLinux.a lib/liblldbPluginObjectFileELF.a lib/
    liblldbPluginInstruct
    ionARM.a lib/liblldbPluginInstructionMIPS.a lib/liblldbPluginInstructionMIPS64.a lib/liblldbPluginProcessGDBRemote.a lib/liblldbPluginPlatformMacOSX.a lib/liblldbPluginPlatformPOSIX.a lib/liblldbPluginProcessPOSIX.a lib/liblldbCore.a lib/
    liblldbSymbol.a lib/lib
    lldbTarget.a lib/liblldbPluginProcessUtility.a lib/liblldbInterpreter.a lib/liblldbBreakpoint.a lib/liblldbDataFormatters.a lib/liblldbExpression.a lib/liblldbPluginCPlusPlusLanguage.a lib/liblldbPluginObjCLanguage.a lib/liblldbCommands.a lib/
    liblldbPluginObjec
    tFileJIT.a lib/liblldbPluginClangCommon.a lib/liblldbPluginCPPRuntime.a lib/liblldbPluginTypeSystemClang.a lib/liblldbPluginAppleObjCRuntime.a lib/liblldbPluginExpressionParserClang.a lib/liblldbPluginSymbolFileDWARF.a lib/
    liblldbPluginSymbolFilePDB.a lib/liblld
    bPluginObjCRuntime.a lib/liblldbPluginRenderScriptRuntime.a lib/liblldbPluginSymbolFileNativePDB.a lib/liblldbPluginObjectFilePDB.a lib/liblldbCore.a lib/liblldbSymbol.a lib/liblldbTarget.a lib/liblldbPluginProcessUtility.a lib/liblldbInterpreter.
    a lib/liblldbB
    reakpoint.a lib/liblldbDataFormatters.a lib/liblldbExpression.a lib/liblldbPluginCPlusPlusLanguage.a lib/liblldbPluginObjCLanguage.a lib/liblldbCommands.a lib/liblldbPluginObjectFileJIT.a lib/liblldbPluginClangCommon.a lib/liblldbPluginCPPRuntime.
    a lib/liblldbP
    luginTypeSystemClang.a lib/liblldbPluginAppleObjCRuntime.a lib/liblldbPluginExpressionParserClang.a lib/liblldbPluginSymbolFileDWARF.a lib/liblldbPluginSymbolFilePDB.a lib/liblldbPluginObjCRuntime.a lib/liblldbPluginRenderScriptRuntime.a lib/
    liblldbPluginSymbolFi
    leNativePDB.a lib/liblldbPluginObjectFilePDB.a lib/liblldbCore.a lib/liblldbSymbol.a lib/liblldbTarget.a lib/liblldbPluginProcessUtility.a lib/liblldbInterpreter.a lib/liblldbBreakpoint.a lib/liblldbDataFormatters.a lib/liblldbExpression.a lib/
    liblldbPluginCPl
    usPlusLanguage.a lib/liblldbPluginObjCLanguage.a lib/liblldbCommands.a lib/liblldbPluginObjectFileJIT.a lib/liblldbPluginClangCommon.a lib/liblldbPluginCPPRuntime.a lib/liblldbPluginTypeSystemClang.a lib/liblldbPluginAppleObjCRuntime.a lib/
    liblldbPluginExpressio
    nParserClang.a lib/liblldbPluginSymbolFileDWARF.a lib/liblldbPluginSymbolFilePDB.a lib/liblldbPluginObjCRuntime.a lib/liblldbPluginRenderScriptRuntime.a lib/liblldbPluginSymbolFileNativePDB.a lib/liblldbPluginObjectFilePDB.a lib/liblldbCore.a lib/
    liblldbSymbol.a
    lib/liblldbTarget.a lib/liblldbPluginProcessUtility.a lib/liblldbInterpreter.a lib/liblldbBreakpoint.a lib/liblldbDataFormatters.a lib/liblldbExpression.a lib/liblldbPluginCPlusPlusLanguage.a lib/liblldbPluginObjCLanguage.a lib/liblldbCommands.
    a lib/liblldbPl
    uginObjectFileJIT.a lib/liblldbPluginClangCommon.a lib/liblldbPluginCPPRuntime.a lib/liblldbPluginTypeSystemClang.a lib/liblldbPluginAppleObjCRuntime.a lib/liblldbPluginExpressionParserClang.a lib/liblldbPluginSymbolFileDWARF.a lib/
    liblldbPluginSymbolFilePDB.a l
    ib/liblldbPluginObjCRuntime.a lib/liblldbPluginRenderScriptRuntime.a lib/liblldbPluginSymbolFileNativePDB.a lib/liblldbPluginObjectFilePDB.a lib/liblldbCore.a lib/liblldbSymbol.a lib/liblldbTarget.a lib/liblldbPluginProcessUtility.a lib/
    liblldbInterpreter.a lib
    /liblldbBreakpoint.a lib/liblldbDataFormatters.a lib/liblldbExpression.a lib/liblldbPluginCPlusPlusLanguage.a lib/liblldbPluginObjCLanguage.a lib/liblldbCommands.a lib/liblldbPluginObjectFileJIT.a lib/liblldbPluginClangCommon.a lib/
    liblldbPluginCPPRuntime.a lib
    /liblldbPluginTypeSystemClang.a lib/liblldbPluginAppleObjCRuntime.a lib/liblldbPluginExpressionParserClang.a lib/liblldbPluginSymbolFileDWARF.a lib/liblldbPluginSymbolFilePDB.a lib/liblldbPluginObjCRuntime.a lib/liblldbPluginRenderScriptRuntime.a
    lib/liblldbPlugi
    nSymbolFileNativePDB.a lib/liblldbPluginObjectFilePDB.a -lcurses /usr/lib/powerpc-linux-gnu/libform.so /usr/lib/powerpc-linux-gnu/libpanel.so /usr/lib/powerpc-linux-gnu/libtinfo.so lib/liblldbBase.a lib/liblldbHost.a /usr/lib/powerpc-linux-gnu/
    libxml2.so /usr/l
    ib/powerpc-linux-gnu/libedit.so lib/liblldbUtility.a -lpthread lib/libclang-cpp.so.13 lib/libLLVM-13.so.1 -ldl -latomic && :
    /usr/bin/ld: lib/liblldbPluginProcessLinux.a(NativeThreadLinux.cpp.o): in function `lldb_private::process_linux::NativeThreadLinux::NativeThreadLinux(lldb_private::process_linux::NativeProcessLinux&, unsigned long long)':
    /home/glaubitz/llvm13/llvm-toolchain-13-13.0.0/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp:96: undefined reference to `lldb_private::process_linux::NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(lldb_private::ArchSpec const&,
    lldb_private::process_linux::NativeThreadLinux&)'
    clang-13: error: linker command failed with exit code 1 (use -v to see invocation)

    --
    .''`. John Paul Adrian Glaubitz
    : :' : Debian Developer - glaubitz@debian.org
    `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
    `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Paul Adrian Glaubitz@21:1/5 to John Paul Adrian Glaubitz on Sun Oct 17 09:50:02 2021
    Hello!

    On 10/17/21 09:38, John Paul Adrian Glaubitz wrote:
    /usr/bin/ld: lib/liblldbPluginProcessLinux.a(NativeThreadLinux.cpp.o): in function `lldb_private::process_linux::NativeThreadLinux::NativeThreadLinux(lldb_private::process_linux::NativeProcessLinux&, unsigned long long)':
    /home/glaubitz/llvm13/llvm-toolchain-13-13.0.0/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp:96: undefined reference to `lldb_private::process_linux::NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(lldb_private::ArchSpec
    const&, lldb_private::process_linux::NativeThreadLinux&)'
    clang-13: error: linker command failed with exit code 1 (use -v to see invocation)

    See this diff for a possible fix: https://reviews.llvm.org/D102872

    Adrian

    --
    .''`. John Paul Adrian Glaubitz
    : :' : Debian Developer - glaubitz@debian.org
    `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
    `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)