Skip to content

Link error when building tests on Linux #295

Open
@dschaefer2

Description

@dschaefer2

On Linux, I get the following output from swift build --build-system swiftbuild --build-tests on a fresh library package from swift package init.

 0% [-----------------------------------------------------------------------------------]
warning: path("/home/dschaefer2/swift/datest/.build/aarch64-unknown-linux-gnu/Intermediates.noindex/datest.build/Debug-linux/datest_Module.build/Objects-normal/aarch64/datest_Module-master-emit-module.dia", fileLocation: nil) Could not read serialized diagnostics file: unable to find libclang []
warning: path("/home/dschaefer2/swift/datest/.build/aarch64-unknown-linux-gnu/Intermediates.noindex/datest.build/Debug-linux/datest_Module.build/Objects-normal/aarch64/datest.dia", fileLocation: nil) Co68% [========================================================---------------------------]
warning: unknown Argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument] []
warning: path("/home/dschaefer2/swift/datest/.build/aarch64-unknown-linux-gnu/Intermediates.noindex/datest.build/Debug-linux/datestTests.build/Objects-normal/aarch64/datestTests-master-emit-module.dia", fileLocation: nil) Could not read serialized diagnostics file: unable to find libclang []
warning: path("/home/dschaefer2/swift/datest/.build/aarch64-unknown-linux-gnu/Intermediates.noindex/datest.build/Debug-linux/datestTests.build/Objects-normal/aarch64/datestTests.dia", fileLocation: nil)90% [==========================================================================---------]
error: unknown Linker command failed with exit code 1 (use -v to see invocation) []

Activity

owenv

owenv commented on Mar 12, 2025

@owenv
Collaborator

@dschaefer2 which toolchain do you have installed? It may be one without swiftlang/swift#79108, which would explain the missing libclang

owenv

owenv commented on Mar 12, 2025

@owenv
Collaborator

There might still be a different failure underlying that one

dschaefer2

dschaefer2 commented on Mar 12, 2025

@dschaefer2
MemberAuthor

It's the feb 19'th nightly. I'll update to the latest. SwiftPM and swift-build are off of main.

dschaefer2

dschaefer2 commented on Mar 12, 2025

@dschaefer2
MemberAuthor

OK fixed my toolchain line up. Ran it this time with -v and got a better answer:

    /home/dschaefer2/swift/toolchains/current/usr/bin/clang -target aarch64-unknown-linux-gnu --sysroot / -O0 -L/home/dschaefer2/swift/datest/.build/aarch64-unknown-linux-gnu/Intermediates.noindex/EagerLinkingTBDs/Debug-linux -L/home/dschaefer2/swift/datest/.build/aarch64-unknown-linux-gnu/Products/Debug-linux -L/home/dschaefer2/swift/toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-03-10-a-ubuntu24.04-aarch64/usr/lib @/home/dschaefer2/swift/datest/.build/aarch64-unknown-linux-gnu/Intermediates.noindex/datest.build/Debug-linux/datestTests.build/Objects-normal/aarch64/datestTests.LinkFileList -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/../Frameworks -rdynamic -lswiftCore -lswiftSwiftOnoneSupport -L/home/dschaefer2/swift/toolchains/current/usr/lib/swift/linux -L/usr/lib/swift @/home/dschaefer2/swift/datest/.build/aarch64-unknown-linux-gnu/Intermediates.noindex/datest.build/Debug-linux/datestTests.build/Objects-normal/aarch64/datestTests.autolink -o /home/dschaefer2/swift/datest/.build/aarch64-unknown-linux-gnu/Products/Debug-linux/datestTests.xctest
error: unknown Linker command failed with exit code 1 (use -v to see invocation) []
info: /lib/aarch64-linux-gnu/Scrt1.o:function _start:(.text+0x1c): error: undefined reference to 'main'
/lib/aarch64-linux-gnu/Scrt1.o:function _start:(.text+0x20): error: undefined reference to 'main'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Looks like the warning about -rdynamic might be significant?

neonichu

neonichu commented on Mar 12, 2025

@neonichu
Collaborator

What's the content of datestTests.LinkFileList?

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @neonichu@owenv@dschaefer2

        Issue actions

          Link error when building tests on Linux · Issue #295 · swiftlang/swift-build