Giter Site home page Giter Site logo

Comments (18)

solskogen avatar solskogen commented on September 27, 2024 1

There is. Compile with this additional flag: USE_LD=ld

from amiberry.

giantclambake avatar giantclambake commented on September 27, 2024 1

So Amiberry internally chooses ld.gold?

In the Makefile.. USE_LD ?= gold If ld.gold doesn't work on riscv64, that needs to be fixed (but I don't have riscv64 hardware)

from amiberry.

solskogen avatar solskogen commented on September 27, 2024

from amiberry.

MichaIng avatar MichaIng commented on September 27, 2024

Checking the file list, there is a gold binary at least: https://packages.debian.org/sid/riscv64/binutils-riscv64-linux-gnu/filelist

/usr/bin/riscv64-linux-gnu-gold

But it is not in PATH:

root@Star64:~# which ld
/usr/bin/ld
root@Star64:~# which ld.gold
root@Star64:~# which gold
root@Star64:~#
root@Star64:~# ls -l /usr/bin/*ld*
-rwxr-xr-x 1 root root   35824 Jan  2 14:54 /usr/bin/fold
lrwxrwxrwx 1 root root      20 Dec 27 10:36 /usr/bin/ld -> riscv64-linux-gnu-ld
lrwxrwxrwx 1 root root      24 Dec 27 10:36 /usr/bin/ld.bfd -> riscv64-linux-gnu-ld.bfd
lrwxrwxrwx 1 root root      32 Dec  3 14:23 /usr/bin/ld.so -> /lib/ld-linux-riscv64-lp64d.so.1
-rwxr-xr-x 1 root root    5407 Dec  3 14:23 /usr/bin/ldd
-rwxr-xr-x 1 root root   14768 Dec  3 14:23 /usr/bin/pldd
lrwxrwxrwx 1 root root      24 Dec 27 10:36 /usr/bin/riscv64-linux-gnu-ld -> riscv64-linux-gnu-ld.bfd
-rwxr-xr-x 1 root root 2076792 Dec 27 10:36 /usr/bin/riscv64-linux-gnu-ld.bfd

Probably this would work?

ln -s riscv64-linux-gnu-gold /usr/bin/ld.gold

But it states that ld is missing, not ld.gold 🤔.

from amiberry.

solskogen avatar solskogen commented on September 27, 2024

from amiberry.

MichaIng avatar MichaIng commented on September 27, 2024

Sadly that did not help.

from amiberry.

solskogen avatar solskogen commented on September 27, 2024

Perhaps the gold-linker doesn't work on risc-v? I don't have access to a risc-v machine, so I can't be sure.

from amiberry.

MichaIng avatar MichaIng commented on September 27, 2024

I guess so. Also this riscv64-linux-gnu-gold actually does not exist in the package. There is a strange bug with the online file list (linked above): It is doubled, with a different list appended at the end of the actual (first) list. There are two /usr/bin sections: The actual first one does not have that binary, only the repeated one below has. However, when you check the actual content of the package, only the first one is present:

root@Star64:~# ls -l /usr/bin/riscv64-linux-gnu-gold
ls: cannot access '/usr/bin/riscv64-linux-gnu-gold': No such file or directory

Hence makes sense that the symlink had no effect 😄.

I first thought the ones at the bottom are symlinks (which are commonly sorted below real files), but vast parts of the paths are indeed doubled, and those which are additionally present at the bottom are completely missing in the package.

Is there a way to tell g++ to use the actual ld command pointing to /usr/bin/riscv64-linux-gnu-ld.bfd, instead of ld.gold?

from amiberry.

MichaIng avatar MichaIng commented on September 27, 2024

Confusing:

g++: error: unrecognized command-line option ‘-fuse-ld=ld’; did you mean ‘-fuse-ld=lld’?

Now I start to think that actually ld is tried to be used already (somehow makes sense according to error message and it explicitly is the default linker), but is not possible to be used for some reason in this case with g++. gold might probably work, so I could try to define it explicitly as well, but went with the suggestion as I also read that the LLVM linker is quite a good replacement nowadays.

from amiberry.

solskogen avatar solskogen commented on September 27, 2024

Sorry, that should be USE_LD=ld.bfd

from amiberry.

MichaIng avatar MichaIng commented on September 27, 2024

Right, USE_LD=lld cause the same error about missing "ld" as when not defining it.

from amiberry.

MichaIng avatar MichaIng commented on September 27, 2024

USE_LD=ld.bfd worked 🎉 !

ldd of course could not work, as it is not included in binutils either, but a dedicated package ldd.

So this means that neither gold nor GNU ld works with RISC-V in this case? Is there any theory why? And does it probably make sense to internally define USE_LD=ld.bfd for this build target/the architecture, if it was not explicitly set differently, to prevent others from running into this error?

from amiberry.

MichaIng avatar MichaIng commented on September 27, 2024

Okay, while it compiles fine now, it does not yet run on my PINE64 Star64 SBC.

I use a kernel based on StarFive's Linux 6.1 build for the VisionFive 2, but rebased onto latest mainline Linux 6.1, and pulled on top the changes for the Star64 from Fishwaldo's repo, the only one I currently know for this SBC (as long as upstreaming from StarFive has not finished): https://github.com/Fishwaldo/Star64_linux

It runs, it starts X11 desktops using DRI, but in case of Amiberry it first throws something like:

MESA-LOADER: failed to open starfive: /usr/lib/dri/starfive_dri.so: cannot open shared object file: No such file or directory

I looked around and found this library provided in StarFive's Debian userspace repo: https://github.com/starfive-tech/Debian/blob/20221225T084846Z/gpu/DDK1.19-binary-xorg/IMG_GPU-xorg.tar.gz
This archive contains a lot of GPU/DRM/GL(ES) related libraries, and the missing one as well. Copied it in place, and now get:

did not find extension DRI_Mesa version 1
failed to bind extensions

Now I remember that I asked about this already some time ago on a RISC-V/StarFive forum: https://forum.rvspace.org/t/failed-to-open-starfive-usr-lib-dri-starfive-dri-so/2325

This is definitely no Amiberry issue. But if someone was able to get it running on VisionFive 2 or Star64, I would be interested. Surely this affects other applications as well.

Final solution is of course using mainline Linux, after everything has been upstreamed. But some components I do not want to miss are still missing, including DRM 😉: https://rvspace.org/en/project/JH7110_Upstream_Plan

from amiberry.

solskogen avatar solskogen commented on September 27, 2024

ld comes with binutils, and it comes in to "flavors" ld.bfd and ld.gold.

from amiberry.

MichaIng avatar MichaIng commented on September 27, 2024

Okay, and ld.bfd is the default ld:

root@VM-Trixie:~# ls -l /usr/bin/*ld*
-rwxr-xr-x 1 root root   43920 Sep 20  2022 /usr/bin/fold
lrwxrwxrwx 1 root root      21 Dec 27 10:36 /usr/bin/gold -> x86_64-linux-gnu-gold
lrwxrwxrwx 1 root root      34 Oct  2 16:11 /usr/bin/grub-ntldr-img -> ../lib/grub/i386-pc/grub-ntldr-img
lrwxrwxrwx 1 root root      19 Dec 27 10:36 /usr/bin/ld -> x86_64-linux-gnu-ld
lrwxrwxrwx 1 root root      23 Dec 27 10:36 /usr/bin/ld.bfd -> x86_64-linux-gnu-ld.bfd
lrwxrwxrwx 1 root root      24 Dec 27 10:36 /usr/bin/ld.gold -> x86_64-linux-gnu-ld.gold
lrwxrwxrwx 1 root root      27 Dec  3 14:23 /usr/bin/ld.so -> /lib64/ld-linux-x86-64.so.2
-rwxr-xr-x 1 root root    5348 Dec  3 14:23 /usr/bin/ldd
-rwxr-xr-x 1 root root   23232 Dec  3 14:23 /usr/bin/pldd
lrwxrwxrwx 1 root root      24 Dec 27 10:36 /usr/bin/x86_64-linux-gnu-gold -> x86_64-linux-gnu-ld.gold
lrwxrwxrwx 1 root root      23 Dec 27 10:36 /usr/bin/x86_64-linux-gnu-ld -> x86_64-linux-gnu-ld.bfd
-rwxr-xr-x 1 root root 1422768 Dec 27 10:36 /usr/bin/x86_64-linux-gnu-ld.bfd
-rwxr-xr-x 1 root root 3265248 Dec 27 10:36 /usr/bin/x86_64-linux-gnu-ld.gold

So Amiberry internally chooses ld.gold? And that one is not available on riscv64, currently:

root@Star64:~# ls -l /usr/bin/*ld*
-rwxr-xr-x 1 root root   35824 Jan  2 14:54 /usr/bin/fold
lrwxrwxrwx 1 root root      20 Dec 27 10:36 /usr/bin/ld -> riscv64-linux-gnu-ld
lrwxrwxrwx 1 root root      24 Dec 27 10:36 /usr/bin/ld.bfd -> riscv64-linux-gnu-ld.bfd
lrwxrwxrwx 1 root root      32 Dec  3 14:23 /usr/bin/ld.so -> /lib/ld-linux-riscv64-lp64d.so.1
-rwxr-xr-x 1 root root    5407 Dec  3 14:23 /usr/bin/ldd
-rwxr-xr-x 1 root root   14768 Dec  3 14:23 /usr/bin/pldd
lrwxrwxrwx 1 root root      24 Dec 27 10:36 /usr/bin/riscv64-linux-gnu-ld -> riscv64-linux-gnu-ld.bfd
-rwxr-xr-x 1 root root 2076792 Dec 27 10:36 /usr/bin/riscv64-linux-gnu-ld.bfd

Not sure if this is a Debian thing, or if gold generally has issues with RISC-V and is not available on other distros as well.

from amiberry.

MichaIng avatar MichaIng commented on September 27, 2024

It seems so, though I fail to find some official info about this, only what has been found on other projects:

So yes, sounds like it makes sense to change the default in the Makefile to bfd for the riscv64 target/architecture.

from amiberry.

midwan avatar midwan commented on September 27, 2024

Perhaps we should skip the whole idea of trying to "force" the LD selection. I understand that gold might be a little faster, but maybe it's not worth the trouble.

@solskogen what do you think about this?

from amiberry.

solskogen avatar solskogen commented on September 27, 2024

We can add USE_LD=ld.bfd on RISC-V exclusively.

from amiberry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.