Skip to content

ld-linux.so missing or at the wrong path in aarch64 SDKs generated from containers #147

Closed
@euanh

Description

@euanh

A test binary fails to link when using an aarch64 SDK generated from a container:

error: link command failed with exit code 1 (use -v to see invocation)
ld.lld: error: /Users/euanh/sandbox/github.com/swiftlang/swift-sdk-generator/Bundles/rhel-aarch64-sdk-from-container.artifactbundle/rhel-aarch64-sdk-from-container/aarch64-unknown-linux-gnu/rhel-ubi9.sdk/lib/gcc/aarch64-redhat-linux/11/../../../../lib64/libc.so:5: cannot find /lib/ld-linux-aarch64.so.1 inside /Users/euanh/sandbox/github.com/swiftlang/swift-sdk-generator/Bundles/rhel-aarch64-sdk-from-container.artifactbundle/rhel-aarch64-sdk-from-container/aarch64-unknown-linux-gnu/rhel-ubi9.sdk
>>> GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a  AS_NEEDED ( /lib/ld-linux-aarch64.so.1 ) )
>>>                                                                   ^
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
error: fatalError

This is because /lib/ld-linux-aarch64.so.1 cannot be found in the SDK.

Symptoms

Symptoms vary depending on how the SDK was built.

SDKs built directly from Ubuntu packages are not affected

% swift run swift-dk-generator
...
% find Bundles/5.10.1-RELEASE_ubuntu_jammy_aarch64.artifactbundle -name ld-linux\*                                                                     
Bundles/5.10.1-RELEASE_ubuntu_jammy_aarch64.artifactbundle/5.10.1-RELEASE_ubuntu_jammy_aarch64/aarch64-unknown-linux-gnu/ubuntu-jammy.sdk/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
Bundles/5.10.1-RELEASE_ubuntu_jammy_aarch64.artifactbundle/5.10.1-RELEASE_ubuntu_jammy_aarch64/aarch64-unknown-linux-gnu/ubuntu-jammy.sdk/lib/ld-linux-aarch64.so.1

x86_64 SDKs are not affected

% swift run swift-sdk-generator --with-docker --sdk-name ubuntu-x86_64-sdk-from-container --target x86_64-unknown-linux-gnu
...
% find Bundles/ubuntu-x86_64-sdk-from-container.artifactbundle -name ld-linux\*
Bundles/ubuntu-x86_64-sdk-from-container.artifactbundle/ubuntu-x86_64-sdk-from-container/x86_64-unknown-linux-gnu/ubuntu-jammy.sdk/usr/lib64/ld-linux-x86-64.so.2
Bundles/ubuntu-x86_64-sdk-from-container.artifactbundle/ubuntu-x86_64-sdk-from-container/x86_64-unknown-linux-gnu/ubuntu-jammy.sdk/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2

Ubuntu-derived SDKs built from containers contain the correct file, but not at the expected path:

% swift run swift-sdk-generator --with-docker --sdk-name ubuntu-aarch64-sdk-from-container --target aarch64-unknown-linux-gnu
...
% find Bundles/ubuntu-aarch64-sdk-from-container.artifactbundle -name ld-linux-\*
Bundles/ubuntu-aarch64-sdk-from-container.artifactbundle/ubuntu-aarch64-sdk-from-container/aarch64-unknown-linux-gnu/ubuntu-jammy.sdk/usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1

RHEL-derived SDKs built from containers do not contain the file at all:

% swift build --swift-sdks-path ~/sandbox/github.com/swiftlang/swift-sdk-generator/Bundles --swift-sdk rhel-aarch64-sdk-from-container
...
% find Bundles/rhel-aarch64-sdk-from-container.artifactbundle -name ld-linux\*
<no output>

The expected name and path of ld-linux.so varies depending on the architecture and some distributions store the file elsewhere and symlink it into the expected location. The generator is not copying all these files into the SDK.

Related to #138

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions