public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111605] New: Cross compilation doesn't work with `-fuse-ld=mold`
@ 2023-09-27  4:31 rui314 at gmail dot com
  2023-09-27  4:35 ` [Bug driver/111605] " pinskia at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: rui314 at gmail dot com @ 2023-09-27  4:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111605

            Bug ID: 111605
           Summary: Cross compilation doesn't work with `-fuse-ld=mold`
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rui314 at gmail dot com
  Target Milestone: ---

When I pass `-fuse-ld=mold` to a gcc cross compiler, gcc searches for `ld.mold`
from the crosstool's bin directories and then looks for `<triple>-ld.mold` from
$PATH. Here is a gcc's strace when invoked with `-fuse-ld=mold`.

[pid 3905484] newfstatat(AT_FDCWD,
"/usr/lib/gcc-cross/riscv64-linux-gnu/11/ld.mold", 0x7ffdd5a491a0, 0) = -1
ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/usr/lib/gcc-cross/riscv64-linux-gnu/11/ld.mold", 0x7ffdd5a491a0, 0) = -1
ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/usr/lib/gcc-cross/riscv64-linux-gnu/ld.mold", 0x7ffdd5a491a0, 0) = -1 ENOENT
(No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/usr/lib/gcc-cross/riscv64-linux-gnu/11/ld.mold", 0x7ffdd5a491a0, 0) = -1
ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/usr/lib/gcc-cross/riscv64-linux-gnu/ld.mold", 0x7ffdd5a491a0, 0) = -1 ENOENT
(No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/usr/lib/gcc-cross/riscv64-linux-gnu/11/../../../../riscv64-linux-gnu/bin/ld.mold",
0x7ffdd5a491a0, 0) = -1 ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/home/ruiu/.cargo/bin/riscv64-linux-gnu-ld.mold", 0x7ffdd5a491a0, 0) = -1
ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/home/ruiu/.local/bin/riscv64-linux-gnu-ld.mold", 0x7ffdd5a491a0, 0) = -1
ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD, "/home/ruiu/bin/riscv64-linux-gnu-ld.mold",
0x7ffdd5a491a0, 0) = -1 ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/home/ruiu/.cabal/bin/riscv64-linux-gnu-ld.mold", 0x7ffdd5a491a0, 0) = -1
ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/home/ruiu/prefix/bin/riscv64-linux-gnu-ld.mold", 0x7ffdd5a491a0, 0) = -1
ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/home/ruiu/bin/qemu/bin/riscv64-linux-gnu-ld.mold", 0x7ffdd5a491a0, 0) = -1
ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD, "/usr/lib/ccache/riscv64-linux-gnu-ld.mold",
0x7ffdd5a491a0, 0) = -1 ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD, "/home/ruiu/bin/riscv64-linux-gnu-ld.mold",
0x7ffdd5a491a0, 0) = -1 ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/home/ruiu/golang/bin/riscv64-linux-gnu-ld.mold", 0x7ffdd5a491a0, 0) = -1
ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/home/ruiu/.mozbuild/node/bin/riscv64-linux-gnu-ld.mold", 0x7ffdd5a491a0, 0) =
-1 ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/home/ruiu/bin/depot_tools/riscv64-linux-gnu-ld.mold", 0x7ffdd5a491a0, 0) = -1
ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD, "/usr/local/sbin/riscv64-linux-gnu-ld.mold",
0x7ffdd5a491a0, 0) = -1 ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD, "/usr/local/bin/riscv64-linux-gnu-ld.mold",
0x7ffdd5a491a0, 0) = -1 ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD, "/usr/sbin/riscv64-linux-gnu-ld.mold",
0x7ffdd5a491a0, 0) = -1 ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD, "/usr/bin/riscv64-linux-gnu-ld.mold",
0x7ffdd5a491a0, 0) = -1 ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD, "/sbin/riscv64-linux-gnu-ld.mold",
0x7ffdd5a491a0, 0) = -1 ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD, "/bin/riscv64-linux-gnu-ld.mold",
0x7ffdd5a491a0, 0) = -1 ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD, "/usr/games/riscv64-linux-gnu-ld.mold",
0x7ffdd5a491a0, 0) = -1 ENOENT (No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD,
"/usr/local/games/riscv64-linux-gnu-ld.mold", 0x7ffdd5a491a0, 0) = -1 ENOENT
(No such file or directory)
[pid 3905484] newfstatat(AT_FDCWD, "/snap/bin/riscv64-linux-gnu-ld.mold",
0x7ffdd5a491a0, 0) = -1 ENOENT (No such file or directory)

This behavior is appropriate for BFD linker which has one executable for each
cross target. However, it's incorrect for the mold linker because mold supports
all targets by a single executable. Therefore, when gcc searches mold from
$PATH, it should look for just `ld.mold`, without the triple.

The same is true for LLD.

The link to the upstream bug: https://github.com/rui314/mold/issues/1114

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-11-09 13:08 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27  4:31 [Bug c++/111605] New: Cross compilation doesn't work with `-fuse-ld=mold` rui314 at gmail dot com
2023-09-27  4:35 ` [Bug driver/111605] " pinskia at gcc dot gnu.org
2023-09-27  5:00 ` rui314 at gmail dot com
2023-09-27  5:11 ` pinskia at gcc dot gnu.org
2023-09-27  5:17 ` rui314 at gmail dot com
2023-09-27  5:21 ` pinskia at gcc dot gnu.org
2023-09-27  5:30 ` rui314 at gmail dot com
2023-09-27  5:34 ` pinskia at gcc dot gnu.org
2023-09-27  5:38 ` rui314 at gmail dot com
2023-09-27  7:28 ` redi at gcc dot gnu.org
2023-09-27  7:37 ` rui314 at gmail dot com
2023-09-27  8:50 ` rguenth at gcc dot gnu.org
2023-09-27  9:06 ` rui314 at gmail dot com
2023-11-09 13:06 ` cvs-commit at gcc dot gnu.org
2023-11-09 13:08 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).