Skip to content

Conversation

@kcieplak
Copy link
Contributor

@kcieplak kcieplak commented Nov 5, 2025

There is a bug in the gold linker on amazon linux 2

See: https://sourceware.org/bugzilla/show_bug.cgi?id=23016

It is triggered when linking relocatable objects built with LLVM based compilers.

  • Add gear to detect the os distribution and version
  • For amazon linux 2 force ALTERNATE_LINKER to lld
  • Add tests mocking the various linux distributions

There is a bug in the gold linker on amazon linux 2
See: https://sourceware.org/bugzilla/show_bug.cgi?id=23016

It is triggered when linking relocatable objects built with
LLVM based compilers.

* Add gear to detect the os distribution and version
* For amazon linux 2 force ALTERNATE_LINKER to lld
@kcieplak
Copy link
Contributor Author

kcieplak commented Nov 5, 2025

* Add a series of tests for checking distribution logic.
@kcieplak kcieplak force-pushed the topics/add-os-distribution-version-detection branch from 08ff7c4 to 97a028f Compare November 5, 2025 13:31
@kcieplak
Copy link
Contributor Author

kcieplak commented Nov 5, 2025

@swift-ci test

Previously was getting the computed property multiple times
which would reparse files in the filesystem takeing time.

Get the propertry once.
…ectly.

Tests were reimplementing the parsing, which is not
of much value.  Call the detectHostLinuxDistribution()
function directly to exercise the parsing logic.

Add a way to pass in a filesystem so we can pass
the mocked filesystem.
Copy link
Collaborator

@jakepetroules jakepetroules left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this looks great! Just some minor formatting feedback.

let osReleasePath = Path("/etc/os-release")
if fs.exists(osReleasePath) {
if let osReleaseData = try? fs.read(osReleasePath),
let osRelease = String(data: Data(osReleaseData.bytes), encoding: .utf8) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: prefer the stdlib constructor instead of the Foundation one:

Suggested change
let osRelease = String(data: Data(osReleaseData.bytes), encoding: .utf8) {
let osRelease = String(decoding: Data(osReleaseData.bytes), as: UTF8.self) {

#expect(distribution == nil)
}
}
} No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: files should end with newlines

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, can you please fix this before merging? #893 adds some validations

@kcieplak
Copy link
Contributor Author

kcieplak commented Nov 5, 2025

@swift-ci test

@kcieplak kcieplak force-pushed the topics/add-os-distribution-version-detection branch from d75a53d to 19f6a31 Compare November 5, 2025 23:19
Mocked filesystem does not work properly with
paths like /etc/os-release.

No point in running them on Windows
@kcieplak kcieplak force-pushed the topics/add-os-distribution-version-detection branch from 19f6a31 to 2da727f Compare November 6, 2025 11:53
@kcieplak
Copy link
Contributor Author

kcieplak commented Nov 6, 2025

@swift-ci test

@kcieplak kcieplak merged commit 1d602f2 into swiftlang:main Nov 6, 2025
51 of 52 checks passed
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

Successfully merging this pull request may close these issues.

3 participants