# Clang: error: unknown argument: '-fswift-async-fp=always'

**URL:** <https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168>\
**Category:** Compiler\
**Tags:** xcode, build-script, help-needed\
**Created:** [September 17, 2021, 5:11pm UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168 "2021-09-17T17:11:47Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![LucianoPAlmeida](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lucianopalmeida/32/2134_2.png) [@LucianoPAlmeida](https://forums.swift.org/u/LucianoPAlmeida)\
**Post date:** [September 17, 2021, 5:11pm UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/1 "2021-09-17T17:11:47Z")

</div>

Hi,  
After an update-checkout, trying to re-build the the compiler for Xcode with `SKIP_XCODE_VERSION_CHECK=1 ./swift/utils/build-script --xcode --release-debuginfo --debug-swift --skip-build-benchmarks --swift-darwin-supported-archs "$(uname -m)" --sccache --skip-ios --skip-tvos --skip-watchos` and `clang: **error:** unknown argument: '-fswift-async-fp=always'` come up, the problem seems that for Xcode builds it is using the pre-built version that ships with Xcode (using 12.5.1), ninja build seems fine since it uses the one built from source. We have a similar problem before, here [[SR-14714] Builds with non-swift/main Clang fail with unknown LLVM argument · Issue #57064 · apple/swift · GitHub](https://bugs.swift.org/browse/SR-14714) but with a different flag.

So my question is if there is a simple way to get around this? Make Xcode builds use the from source built clang or it is better to download and try a beta version of Xcode to fix this? Or maybe another approach?  
Thanks in advance!

Best Regards,  
Luciano Almeida

---

<div class="post-metadata">

**Author:** ![typesanitizer](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/typesanitizer/32/8661_2.png) [@typesanitizer](https://forums.swift.org/u/typesanitizer)\
**Post date:** [September 17, 2021, 5:16pm UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/2 "2021-09-17T17:16:09Z")

</div>

To me, it seems like a bug that the `--xcode` build doesn't use the locally built Clang. Different build systems should still be using the same overall compilation commands, otherwise this issue will keep coming up from time to time because of the skew between apple/llvm-project and what is available in the latest Xcode release.

(cc @Michael_Gottesman)

---

<div class="post-metadata">

**Author:** ![benrimmington](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/benrimmington/32/695_2.png) [@benrimmington](https://forums.swift.org/u/benrimmington)\
**Post date:** [September 17, 2021, 8:19pm UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/3 "2021-09-17T20:19:14Z")

</div>

> [@LucianoPAlmeida](#):
>
> Xcode (using 12.5.1)

The required version of Xcode is currently **13 beta 4** or newer, according to the information on [ci.swift.org](https://ci.swift.org/) and [GettingStarted.md](https://github.com/apple/swift/blob/main/docs/HowToGuides/GettingStarted.md#installing-dependencies).

I think the [build-script](https://github.com/apple/swift/blob/6766824d5140d3516a4395d4902dca42932a532b/utils/build-script#L52-L60) should only contain that version number, so we don't need to use `SKIP_XCODE_VERSION_CHECK=1` for newer versions (e.g. the release candidate).

The only issue is that Xcode build numbers may not be monotonic, for beta and release versions.

---

<div class="post-metadata">

**Author:** ![Finagolfin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/finagolfin/32/34388_2.png) [@Finagolfin](https://forums.swift.org/u/Finagolfin)\
**Post date:** [September 19, 2021, 10:34am UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/4 "2021-09-19T10:34:09Z")

</div>

There is a broader issue here, which is that till now it was possible to build the Swift stdlib with a stock upstream OSS clang on all platforms. However, [the pull that added this flag](https://github.com/apple/swift/pull/39245) would now require that only the Swift-forked clang be used to build the stdlib, eg [on my Android CI which uses the NDK clang and just broke because of this change](https://github.com/buttaface/swift-android-sdk/runs/3644126454?check_suite_focus=true#step:7:1342).

Maybe we can detect whether the Swift-forked clang is being used and only pass flags like this to it?

---

<div class="post-metadata">

**Author:** ![Douglas\_Gregor](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/douglas_gregor/32/1362_2.png) [@Douglas\_Gregor](https://forums.swift.org/u/Douglas_Gregor)\
**Post date:** [September 19, 2021, 1:48pm UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/5 "2021-09-19T13:48:42Z")

</div>

> [@Finagolfin](#):
>
> There is a broader issue here, which is that till now it was possible to build the Swift stdlib with a stock upstream OSS clang on all platforms. However, [the pull that added this flag](https://github.com/apple/swift/pull/39245) would now require that only the Swift-forked clang be used to build the stdlib, eg [on my Android CI which uses the NDK clang and just broke because of this change](https://github.com/buttaface/swift-android-sdk/runs/3644126454?check_suite_focus=true#step:7:1342).

Unless the NDK clang is tracking LLVM's main fairly closely, I expect you'll run into problems with async/await support, because Swift is relying on custom async calling conventions implemented in LLVM within the last few months.

Now, this particular change that adds the `-fswift-async-fp=always` flag is only specifically relevant to Darwin, because the default behavior on all other platforms is good enough. We should go ahead and not pass the flag for non-Darwin platforms.

That doesn't necessarily help @LucianoPAlmeida's Xcode build. We can disable the flag there, and I think only the back-deployed concurrency stuff under development will break, so perhaps that is enough.

> [@Finagolfin](#):
>
> Maybe we can detect whether the Swift-forked clang is being used and only pass flags like this to it?

The danger here is that these flags may have an effect on code generation, and if the C++ bits of the Swift runtime are built without them, the resulting runtime could be broken.

Doug

---

<div class="post-metadata">

**Author:** ![Finagolfin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/finagolfin/32/34388_2.png) [@Finagolfin](https://forums.swift.org/u/Finagolfin)\
**Post date:** [September 19, 2021, 5:08pm UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/6 "2021-09-19T17:08:33Z")

</div>

> Unless the NDK clang is tracking LLVM's main fairly closely, I expect you'll run into problems with async/await support

It doesn't track it that closely, as [the latest NDK 23 from last month](https://github.com/android/ndk/wiki/Changelog-r23) appears to use [a clang commit from January](https://android.googlesource.com/toolchain/llvm-project/+log/refs/heads/llvm-r416183). I built the Sept. 2 trunk source snapshot of the Swift toolchain with the upstream clang 12.0.1 on my Android phone, and all the compiler validation suite Concurrency tests passed on Android 11 AArch64 so it hasn't been a problem yet.

> We should go ahead and not pass the flag for non-Darwin platforms.

OK, I will submit a pull for that.

> The danger here is that these flags may have an effect on code generation, and if the C++ bits of the Swift runtime are built without them, the resulting runtime could be broken.

Good to know. Is the plan to let the Swift-forked clang permanently diverge from upstream clang or get these clang differences upstreamed eventually, [as @DaveZ has been monitoring for](https://github.com/apple/swift/pull/36805#issuecomment-849608446)?

---

<div class="post-metadata">

**Author:** ![Douglas\_Gregor](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/douglas_gregor/32/1362_2.png) [@Douglas\_Gregor](https://forums.swift.org/u/Douglas_Gregor)\
**Post date:** [September 19, 2021, 5:12pm UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/7 "2021-09-19T17:12:28Z")

</div>

> [@Finagolfin](#):
>
> Good to know. Is the plan to let the Swift-forked clang permanently diverge from upstream clang or get these clang differences upstreamed eventually, [as @DaveZ has been monitoring for](https://github.com/apple/swift/pull/36805#issuecomment-849608446)?

The plan is to get it all upstream. This flag is already upstream (it went there first), but there’s always lag until the next release for a given platform/vendor.

---

<div class="post-metadata">

**Author:** ![Finagolfin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/finagolfin/32/34388_2.png) [@Finagolfin](https://forums.swift.org/u/Finagolfin)\
**Post date:** [September 19, 2021, 5:49pm UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/8 "2021-09-19T17:49:41Z")

</div>

Oh, I see you [upstreamed it on Thursday](https://reviews.llvm.org/D109392). Looking at your patch, it appears removing that flag from the non-Darwin stdlib build will change it on non-Darwin from `never` to the default of `always`, but it had the same behavior before you added the flag, so I guess `always` should be fine too.

I'll submit the pull in a little bit, thanks for the info.

---

<div class="post-metadata">

**Author:** ![Finagolfin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/finagolfin/32/34388_2.png) [@Finagolfin](https://forums.swift.org/u/Finagolfin)\
**Post date:** [September 19, 2021, 6:33pm UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/9 "2021-09-19T18:33:49Z")

</div>

> I built the Sept. 2 trunk source snapshot of the Swift toolchain with the upstream clang 12.0.1 on my Android phone, and all the compiler validation suite Concurrency tests passed on Android 11 AArch64 so it hasn't been a problem yet.

I looked into this a bit more, and while a few C++ files in the stdlib are built with the host clang, ie upstream clang 12.0.1 in the Termux app, most are built with the Swift-forked clang that should have the changes you refer to, so that explains why that problem hasn't hit. My Android CI cross-compiles from linux with the NDK clang instead, so maybe the problem exists there but the Concurrency library is probably not used or exercised much by those Swift packages tested there yet.

---

<div class="post-metadata">

**Author:** ![LucianoPAlmeida](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lucianopalmeida/32/2134_2.png) [@LucianoPAlmeida](https://forums.swift.org/u/LucianoPAlmeida)\
**Post date:** [September 20, 2021, 1:13am UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/10 "2021-09-20T01:13:55Z")

</div>

> [@Douglas\_Gregor](#):
>
> That doesn't necessarily help @LucianoPAlmeida's Xcode build. We can disable the flag there, and I think only the back-deployed concurrency stuff under development will break, so perhaps that is enough.

Thanks for the response @Douglas_Gregor,  
I think for me disabling the flag for the Xcode build locally would be just enough, will not affect the workflow I currently have. But as @typesanitizer mentioned this is a recurrent issue that occurs whenever a new flag is added on clang to support some new swift fix/feature for example [[SR-14714] Builds with non-swift/main Clang fail with unknown LLVM argument · Issue #57064 · apple/swift · GitHub](https://bugs.swift.org/browse/SR-14714), so for that problem maybe the solution would be make the Xcode build use the locally built from source clang the same way ninja builds do today.  
I think it would be just fine, but I don't have much understanding about side effects such change would have ... do you think is a viable option?

---

<div class="post-metadata">

**Author:** ![typesanitizer](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/typesanitizer/32/8661_2.png) [@typesanitizer](https://forums.swift.org/u/typesanitizer)\
**Post date:** [September 20, 2021, 6:15pm UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/11 "2021-09-20T18:15:41Z")

</div>

JIRA ticket for this issue: [https://bugs.swift.org/browse/SR-15216](https://bugs.swift.org/browse/SR-15216)

---

<div class="post-metadata">

**Author:** ![RyanK](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@RyanK](https://forums.swift.org/u/RyanK)\
**Post date:** [September 20, 2021, 6:21pm UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/12 "2021-09-20T18:21:09Z")

</div>

Hey yall, I filed that jira ticket yesterday while somehow missing this discussion here.

Last night, I ended up deleting all of my previous Xcode versions and downloaded the 13.4 beta and accompanying command line tools to see if that would fix this issue. I started the build again without the skip xcode version check var, but I woke up to a failed build again with the same error messages this morning.

---

<div class="post-metadata">

**Author:** ![Finagolfin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/finagolfin/32/34388_2.png) [@Finagolfin](https://forums.swift.org/u/Finagolfin)\
**Post date:** [September 20, 2021, 6:26pm UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/13 "2021-09-20T18:26:45Z")

</div>

I've submitted [a pull that elides the flag if not found on non-Darwin and should error on Darwin for the Xcode build](https://github.com/apple/swift/pull/39368), based on a suggestion by @DaveZ.

---

<div class="post-metadata">

**Author:** ![amritpan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/amritpan/32/39281_2.png) [@amritpan](https://forums.swift.org/u/amritpan)\
**Post date:** [September 27, 2021, 5:55pm UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/15 "2021-09-27T17:55:37Z")

</div>

I've also run into this error now. I am using Xcode 13 beta 4.

---

<div class="post-metadata">

**Author:** ![LucianoPAlmeida](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lucianopalmeida/32/2134_2.png) [@LucianoPAlmeida](https://forums.swift.org/u/LucianoPAlmeida)\
**Post date:** [September 28, 2021, 12:03am UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/16 "2021-09-28T00:03:43Z")

</div>

@RyanK @amritpan It is still an issue for all Xcode builds right now, there are more details on @Finagolfin's PR here [https://github.com/apple/swift/pull/39368](https://github.com/apple/swift/pull/39368) but we still don't have a fix, and at least as far as I know we don't have a work around it as well ... so Xcode builds are not working right now.  
Does someone found a workaround for building it?

I think just to unlock the build maybe try **locally** revert the PR that introduced the flag [Add flag -swift-async-framepointer=auto,never,always to control swift extended frame information emission by aschwaighofer · Pull Request #39245 · apple/swift · GitHub](https://github.com/apple/swift/pull/39245) with `git revert cffc1b212196a52d45aabb007b5af156e0dfb82f -m 2` but note I didn't test this so maybe it doesn't work and also not sure is recommended 😅

---

<div class="post-metadata">

**Author:** ![amritpan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/amritpan/32/39281_2.png) [@amritpan](https://forums.swift.org/u/amritpan)\
**Post date:** [October 1, 2021, 1:04am UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/17 "2021-10-01T01:04:13Z")

</div>

Thanks! I've gotten a working build by going back to the 5.4 release with `git checkout swift-5.4-DEVELOPMENT-SNAPSHOT-2021-03-19-a && utils/update-checkout --tag swift-5.4-DEVELOPMENT-SNAPSHOT-2021-03-19-a`. This works for the meantime 🙂

---

<div class="post-metadata">

**Author:** ![Finagolfin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/finagolfin/32/34388_2.png) [@Finagolfin](https://forums.swift.org/u/Finagolfin)\
**Post date:** [October 3, 2021, 7:15am UTC](https://forums.swift.org/t/clang-error-unknown-argument-fswift-async-fp-always/52168/18 "2021-10-03T07:15:26Z")

</div>

That is fairly old: you should just checkout `swift-DEVELOPMENT-SNAPSHOT-2021-09-14-a`, which was the last tag before [the commit adding this flag was merged](https://github.com/apple/swift/commit/cffc1b212196a52d45aabb007b5af156e0dfb82f).

I've submitted [another pull to work around this issue on macOS](https://github.com/apple/swift/pull/39561), you could try that out on a more recent tag too.
