SwiftPM: Passing flags to Clang

I've a library with three modules/targets. One of the target is a pure C project. I need to prevent tail sibling call optimization via -fno-optimize-sibling-calls for this project.

As far as I can see, there seems to be no way of achieving this, so this is a shot in the dark in the hopes I'm overlooking something, or there's at least some hacky solution I'm not seeing.

Thank you!

SE-0238 describes how SwiftPM can pass flags to the Clang or Swift compilers.

In your case, adding this to your target declaration should work:

    cSettings: [

The (big) caveat: SwiftPM will no longer allow products containing targets with unsafe flags to be used as a dependency in another package.

1 Like