Skip to content

Making fuse-ld=lld work for --target=x86_64-pc-solaris2.11 #202963

Open

Description

@am11

We have illumos sysroot created with:

$ curl -sSL https://github.com/dotnet/arcade/raw/0a80b03/eng/common/cross/build-rootfs.sh | \
    bash -s -- illumos x64 --rootfsdir /tmp/crossrootfs/x64

It installs host: linux-x64, target: illumos-x64 cross gcc toolchain at rootfsdir. From there, we use gcc toolchain to compiler code; it uses solaris linker.

If we try using host machine's lld, it runs into a few (workaroundable) errors.

Repro, fuse-ld=lld is instantly rejected:

$ ROOTFS_DIR=/tmp/crossrootfs/x64
$ clang-21 --target=x86_64-pc-solaris2.11 --sysroot=$ROOTFS_DIR \
    --gcc-install-dir=$ROOTFS_DIR/lib/gcc/x86_64-sun-solaris2.11/13.3.0 -fuse-ld=lld  -xassembler - <<EOF
.intel_syntax noprefix
test byte ptr [rdi], 0x8

.global main
main:
    ret
EOF

clang-21: error: invalid linker name in argument '-fuse-ld=lld'

To circumvent it, I created a wrapper script to invoke ld.lld instead, it doesn't like -C passed by the driver:

#!/bin/sh

eval exec ld.lld $@

chmod +x linker-wrapper.sh

and used -fuse-ld=$(pwd)/linker-wrapper.sh:

$ clang-21 --target=x86_64-pc-solaris2.11 --sysroot=$ROOTFS_DIR \
   --gcc-install-dir=$ROOTFS_DIR/lib/gcc/x86_64-sun-solaris2.11/13.3.0 -fuse-ld=$(pwd)/linker-wrapper.sh  -xassembler - <<EOF
.intel_syntax noprefix
test byte ptr [rdi], 0x8

.global main
main:
    ret
EOF
ld.lld: error: unknown argument '-C'
ld.lld: warning: unknown -z value: ignore
ld.lld: warning: unknown -z value: record
clang-21: error: linker command failed with exit code 1 (use -v to see invocation)

Then I modified the script:

#!/bin/sh

args=""
for a in "$@"; do
  [ "$a" = "-C" ] && continue
  # illumos sysroot currently ships libssp but not libssp_nonshared.
  [ "$a" = "-lssp_nonshared" ] && a="-lssp"
  args="$args \"$a\""
done
eval exec ld.lld $args

The current workaround addresses the immediate failure, but -fuse-ld=lld should work natively without requiring a wrapper script or manual argument filtering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions