Repository navigation
Closed
Labels
0.kind: bugSomething is broken
Description
Nixpkgs version
- Unstable (26.11)
Describe the bug
Building a swift package with C++ interop enabled fails with a linking error:
ld.bfd: /nix/store/…-stdlib-6.2.4-dev/lib/libswiftCxx.a(Cxx.o): unrecognized relocation type 0x13b in section `swift5_typeref'
ld.bfd: final link failed: bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Changing the linker to lld (swiftpmFlags = [ "-Xswiftc" "-use-ld=lld" ]) ends up with a different set of errors:
ld.lld: error: corrupt input file: version definition index 0 for symbol $ss12_SmallStringVyABSgSRys5UInt8VGcfC is out of bounds
ld.lld: error: corrupt input file: version definition index 0 for symbol $ss6SIMD64V8highHalfs6SIMD32VyxGvs is out of bounds
ld.lld: error: corrupt input file: version definition index 0 for symbol $ss30KeyedDecodingContainerProtocolP15decodeIfPresent_6forKeys6UInt64VSgAFm_0I0QztKFTq is out of bounds
ld.lld: error: corrupt input file: version definition index 0 for symbol $sSeTL is out of bounds
ld.lld: error: corrupt input file: version definition index 0 for symbol $ss5UInt8V5WordsVMa is out of bounds
Steps to reproduce
Try to build the following Swift package with main.swift:
import CxxStdlib
let hello = std.string("Hello, C++!")
print(Array(hello).count)// swift-tools-version: 6.2
import PackageDescription
let package = Package(
name: "Repro",
targets: [
.executableTarget(
name: "Repro",
swiftSettings: [.interoperabilityMode(.Cxx)]
)
]
){
pkgs ? import <nixpkgs> { },
}:
pkgs.swiftPackages.stdenv.mkDerivation {
name = "swift-cxx-interop-link-repro";
src = ./.;
strictDeps = true;
nativeBuildInputs = [
pkgs.swiftPackages.swift
pkgs.swiftPackages.swiftpm
];
installPhase = ''
runHook preInstall
"$(swiftpmBinPath)/Repro" | tee "$out"
runHook postInstall
'';
}Expected behaviour
Linking should finish successfully independent of what linker is being used
System metadata
- system:
"aarch64-linux" - host os:
Linux 6.8.0-117-generic - multi-user?:
yes - sandbox:
no - version:
nix-env (Nix) 2.35.2 - channels(root):
"" - nixpkgs:
/nix/store/y4g1nqn7vc8gxh49ni12cpksg9xc154y-source
Notify maintainers
cc @reckenrode @Samasaur1 @stephank
Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)
I assert that this issue is relevant for Nixpkgs
- I assert that this is a bug and not a support request.
- I assert that this is not a duplicate of an existing issue.
- I assert that I have read the NixOS Code of Conduct and agree to abide by it.
- I assert that I have read the automation/AI policy and that this issue report complies with it.
Is this issue important to you?
Add a 👍 reaction to issues you find important.
Metadata
Metadata
Assignees
Labels
0.kind: bugSomething is broken
Activity
reckenrode commentedon Oct 8, 2026
I’m switching Swift to use LLD on both Darwin and Linux to build the compiler and the stdlib. It appears to fix both of these issues. That work will land along with Swift 6.4, which I’m still targeting for 26.11.
reckenrode commentedon Oct 13, 2026
Quick change of plans. I am going to start landing some of the cleanups and fixes ahead of my Swift 6.4 branch. I still want to get Swift 6.4 into 26.11, but these can go straight to master and not have to wait on a staging cycle.
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker
swift: link using LLD instead of the default linker