Skip to content

SWBUtil: fix host architecture detection on FreeBSD PowerPC - #1860

Merged
rjmansfield merged 1 commit into
swiftlang:mainfrom
pkubaj:ppc64le-fbsd-fix
Oct 16, 2026
Merged

rjmansfield merged 1 commit into
swiftlang:mainfrom
pkubaj:ppc64le-fbsd-fix

Conversation

@pkubaj

@pkubaj pkubaj commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

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.

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.
@rjmansfield

Copy link
Copy Markdown
Contributor

@swift-ci test

@rjmansfield
rjmansfield enabled auto-merge October 13, 2026 13:38
@rjmansfield

Copy link
Copy Markdown
Contributor

@swift-ci test windows

1 similar comment
@rjmansfield

Copy link
Copy Markdown
Contributor

@swift-ci test windows

@rjmansfield
rjmansfield merged commit c42b290 into swiftlang:main Oct 16, 2026
3 checks passed
@pkubaj
pkubaj deleted the ppc64le-fbsd-fix branch October 18, 2026 16:47
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.

2 participants