Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
euanh opened this issue Nov 12, 2024 · 0 comments
Assignees

Comments

@euanh
Copy link
Contributor

euanh commented Nov 12, 2024

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

@euanh euanh self-assigned this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant