Code compiles but fails with non-Apple compiler

Some code in one of my projects has a significant performance regression and outright fails (compiles, no errors) when using clang 16.0.6 (arch linux & raspberry pi os), but works as expected when running on dev machine (iMac 2019, Sonoma 14.3.1, Xcode 15.3 & VSCode 1.87.0) with Apple clang version 15.0.0 (clang-1500.3.9.4).

Been trying to fix this problem moving the code around, using different machines (2 x86_64 [AMD: threadripper 1900x; 7800x3D], 2 arm [raspberry pi 4B & 5]), different swift versions (5.7, 5.9, 5.10), but no luck. Everything just works on my dev machine, but completely fails when using non-Apple compiler (for production use).

Upgrading or downgrading clang/gcc/llvm is not possible on the production machines. I've started writing the program in Rust to avoid this inconsistency, but that will take a lot more time than just try adding compile/execution flags or changing configurations somewhere.

What other options can I try? Swift is my go-to language for everything, but this is a dealbreaker.

You're going to have to be waaaay more specific if you'd like anyone to help you here. What code are you running and what does it do?

It's an unfortunate fact that Apple compiles their own versions of LLVM and Swift, and their LLVM versioning does not match the public LLVM versioning. So there's really no public equivalent much of the time.

1 Like

The problem is I can't share the exact code because it is proprietary, however I can share that it is a static non-async recursive function (about 200 lines of code, broken up into 7 functions, passing inout variables with each other, all done on the stack [no heap involved]) that assigns balanced time slots between teams for League Scheduling.

Of course after I seek help I find a workaround to this problem by moving code around for a few hours. The performance is the same as my dev machine, and actually works now.