Skip to content

Adopt executable path API (sorta) from the stdlib.#1801

Open
grynspan wants to merge 1 commit into
mainfrom
jgrynspan/executable-path-in-stdlib
Open

Adopt executable path API (sorta) from the stdlib.#1801
grynspan wants to merge 1 commit into
mainfrom
jgrynspan/executable-path-in-stdlib

Conversation

@grynspan

Copy link
Copy Markdown
Contributor

swiftlang/swift#90476 added an exported function to the stdlib on non-Apple platforms to get the current executable's path. We should adopt this implementation instead of continuing to use our own.

On Apple platforms, due to back-deployment requirements, that function is not implemented and we instead continue to call _NSGetExecutablePath().

I have cherry-picked the change to 6.4.x here, so the change should work there too once the toolchain builds a new nightly.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

swiftlang/swift#90476 added an exported function to the
stdlib on non-Apple platforms to get the current executable's path. We should
adopt this implementation instead of continuing to use our own.

On Apple platforms, due to back-deployment requirements, that function is not
implemented and we instead continue to call `_NSGetExecutablePath()`.

I have cherry-picked the change to 6.4.x [here](swiftlang/swift#90659),
so the change should work there too once the toolchain builds a new nightly.
@grynspan grynspan added this to the Swift 6.5.0 (main) milestone Jul 17, 2026
@grynspan grynspan self-assigned this Jul 17, 2026
@grynspan
grynspan requested a review from stmontgomery as a code owner July 17, 2026 18:26
@grynspan grynspan added the enhancement New feature or request label Jul 17, 2026
@grynspan grynspan added the exit-tests ☠️ Work related to exit tests label Jul 17, 2026
@grynspan
grynspan requested a review from harlanhaskins as a code owner July 17, 2026 18:26
@grynspan grynspan added attachments/activities 🖇️ Work related to attachments and/or activities tech-debt 💾 reduces technical debt harness 🪢 Changes related to the testing harness labels Jul 17, 2026
static var executablePath: String {
get throws {
#if SWT_TARGET_OS_APPLE
#if hasFeature(Embedded) || os(WASI)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be its own configuration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

attachments/activities 🖇️ Work related to attachments and/or activities enhancement New feature or request exit-tests ☠️ Work related to exit tests harness 🪢 Changes related to the testing harness tech-debt 💾 reduces technical debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants