Repository navigation
SWBUtil: fix host architecture detection on FreeBSD PowerPC - #1860
Merged
Merged
Conversation
Architecture.hostStringValue falls back to utsname.machine on non-Darwin, non-Windows hosts. On FreeBSD utsname.machine holds the platform (MACHINE) rather than the CPU architecture (MACHINE_ARCH), and every PowerPC flavor reports the same "powerpc". As a result host planning computes the triple powerpc-unknown-freebsdNN, and host build tool modules fail to compile against the powerpc64le standard library: <unknown>:0: error: could not find module 'Swift' for target 'powerpc-unknown-freebsd'; found: powerpc64le-unknown-freebsd ... The hw.machine_arch sysctl would give the right answer, but sysctlbyname is not exposed through the Swift Glibc module on FreeBSD, so resolve "powerpc" with the compile-time architecture instead: a native process's own architecture is the host architecture, and the existing amd64/arm64 mapping already assumes native execution. Seen while building the Swift 6.4 toolchain for powerpc64le-unknown-freebsd on FreeBSD/powerpc64le, where the SwiftPM bootstrap (swift-bootstrap) links SwiftBuild and planned the host modules with the bogus triple.
pkubaj
requested review from
cmcgee1024,
daveinglis,
jakepetroules,
mhrawdon,
owenv,
rconnell9 and
rjmansfield
as code owners
October 13, 2026 07:54
Contributor
|
@swift-ci test |
rjmansfield
approved these changes
Oct 13, 2026
rjmansfield
enabled auto-merge
October 13, 2026 13:38
Contributor
|
@swift-ci test windows |
1 similar comment
Contributor
|
@swift-ci test windows |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Architecture.hostStringValue falls back to utsname.machine on
non-Darwin, non-Windows hosts. On FreeBSD utsname.machine holds the
platform (MACHINE) rather than the CPU architecture (MACHINE_ARCH), and
every PowerPC flavor reports the same "powerpc". As a result host
planning computes the triple powerpc-unknown-freebsdNN, and host build
tool modules fail to compile against the powerpc64le standard library:
:0: error: could not find module 'Swift' for target
'powerpc-unknown-freebsd'; found: powerpc64le-unknown-freebsd ...
The hw.machine_arch sysctl would give the right answer, but
sysctlbyname is not exposed through the Swift Glibc module on FreeBSD,
so resolve "powerpc" with the compile-time architecture instead: a
native process's own architecture is the host architecture, and the
existing amd64/arm64 mapping already assumes native execution.
Seen while building the Swift 6.4 toolchain for
powerpc64le-unknown-freebsd on FreeBSD/powerpc64le, where the SwiftPM
bootstrap (swift-bootstrap) links SwiftBuild and planned the host
modules with the bogus triple.