Skip to content

FreeBSD: ld.lld: error: -r and --export-dynamic may not be used together #899

@jakepetroules

Description

@jakepetroules

Building an executable package from template fails with the following error:

# swift build --build-system swiftbuild
error: /root/testpkg/Package.swift Linker command failed with exit code 1 (use -v to see invocation)
error: Ld /root/testpkg/.build/x86_64-unknown-freebsd/Products/Debug-freebsd/ExecutableModules/testpkg-4A664059B3045C89-testable.o normal failed with a nonzero exit code. Command line:     cd /root/testpkg
    /root/usr/bin/clang -target x86_64-unknown-freebsd14.3 -r --sysroot / -O0 -L/root/testpkg/.build/x86_64-unknown-freebsd/Intermediates.noindex/EagerLinkingTBDs/Debug-freebsd -L/root/testpkg/.build/x86_64-unknown-freebsd/Products/Debug-freebsd -L/root/usr/lib @/root/testpkg/.build/x86_64-unknown-freebsd/Intermediates.noindex/testpkg.build/Debug-freebsd/testpkg-4A664059B3045C89-testable.build/Objects-normal/x86_64/testpkg-4A664059B3045C89-testable.LinkFileList -nostdlib -rdynamic -fuse-ld\=lld -o /root/testpkg/.build/x86_64-unknown-freebsd/Products/Debug-freebsd/ExecutableModules/testpkg-4A664059B3045C89-testable.o
error: Ld /root/testpkg/.build/x86_64-unknown-freebsd/Products/Debug-freebsd/testpkg normal failed with a nonzero exit code. Command line:     cd /root/testpkg
    /root/usr/bin/swiftc -target x86_64-unknown-freebsd14.3 -emit-executable -sysroot / -L/root/testpkg/.build/x86_64-unknown-freebsd/Intermediates.noindex/EagerLinkingTBDs/Debug-freebsd -L/root/testpkg/.build/x86_64-unknown-freebsd/Products/Debug-freebsd -L/root/usr/lib @/root/testpkg/.build/x86_64-unknown-freebsd/Intermediates.noindex/testpkg.build/Debug-freebsd/testpkg.build/Objects-normal/x86_64/testpkg.LinkFileList -Xlinker --gc-sections -Xclang-linker -rdynamic -lswiftCore -lswiftSwiftOnoneSupport -L/root/usr/lib/swift/freebsd -L/usr/lib/swift @/root/testpkg/.build/x86_64-unknown-freebsd/Intermediates.noindex/testpkg.build/Debug-freebsd/testpkg.build/Objects-normal/x86_64/testpkg.autolink -use-ld\=lld -o /root/testpkg/.build/x86_64-unknown-freebsd/Products/Debug-freebsd/testpkg
error: Build failed
root@freebsd:~/testpkg # swift --version
Swift version 6.3-dev (LLVM c9d322e8f6b5e97, Swift f149a8bce4ce25b)
Target: x86_64-unknown-freebsd14.3
Build config: +assertions

Invoking the link command shows the real error:

# /root/usr/bin/clang -target x86_64-unknown-freebsd14.3 -r --sysroot / -O0 -L/root/testpkg/.build/x86_64-unknown-freebsd/Intermediates.noindex/EagerLinkingTBDs/Debug-freebsd -L/root/testpkg/.build/x86_64-unknown-freebsd/Products/Debug-freebsd -L/root/usr/lib @/root/testpkg/.build/x86_64-unknown-freebsd/Intermediates.noindex/testpkg.build/Debug-freebsd/testpkg-4A664059B3045C89-testable.build/Objects-normal/x86_64/testpkg-4A664059B3045C89-testable.LinkFileList -nostdlib -rdynamic -fuse-ld\=lld -o /root/testpkg/.build/x86_64-unknown-freebsd/Products/Debug-freebsd/ExecutableModules/testpkg-4A664059B3045C89-testable.o
ld.lld: error: -r and --export-dynamic may not be used together

This package succeeds with the native build system and fails with Swift Build.

Metadata

Metadata

Assignees

No one assigned

    Labels

    freebsdSupport for the FreeBSD platform

    Type

    No type

    Projects

    Status

    Done

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions