Repository navigation
Fix swift compilation to use a release build on release - #138038
Conversation
|
Azure Pipelines: Successfully started running 4 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the Swift optimization-flag selection change.
No open issues 🎉
What changed in this PR
Fixes build-type matching for the Apple cryptography Swift shim so release builds select the intended optimization flag.
Changes:
- Uses
UPPERCASE_CMAKE_BUILD_TYPEwith uppercase values for CMake’s case-sensitive comparisons. - Correctly selects
-Ononefor debug builds and-Ofor release builds.
| File | Description |
|---|---|
src/native/libs/System.Security.Cryptography.Native.Apple/CMakeLists.txt |
Corrects the debug and release conditions used to select Swift optimization flags. |
Review effort: Balanced
|
nice find! seems like a backport candidate? |
|
Actually, given that https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html explicitly documents https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#id80 discusses this some more and says to always compare against e.g. uppercase but I see no reason to not just follow the established casing. |
I’m not so sure. I’m reluctant to change anything about how the swift object is built in servicing. Just recently we ran into this with the SHA-3 work because of complex interactions. I don’t expect anything to break, but I also think I would bucket it as a “medium” risk. Given that it doesn’t actually fix anything, and it’s been this way… forever… my personal opinion is it should be left as is.
Yeah that seems like a good idea. I will file an issue for it, but for this fix since it explicitly uses the _UPPER variable now, I think it’s fine. |
|
Thanks for catching this! The follow-up is in #138121. It passes canonical Note This comment was generated with GitHub Copilot. |
<!-- --> Follow-up to #138038, where an uppercase `CMAKE_BUILD_TYPE` exposed a case-sensitive comparison in the Apple crypto Swift build. - Have `build-commons.sh` pass the canonical build type explicitly. Both generator wrappers now forward `-DCMAKE_BUILD_TYPE` unchanged. - Share the case-insensitive comparison value and canonical cache choices across single-config generators. Make Rollup use the same case-insensitive Release check for its configuration and optimization mode. - Install the IJW test Debug CRT based on the configuration being installed, rather than the configure-time build type. Built and linked `System.Security.Cryptography.Native.Apple` locally with Ninja on macOS arm64 in both Debug and Release. The verbose build confirmed `swiftc -Onone` for Debug and `swiftc -O` for Release. Focused CMake checks covered argument forwarding and overrides, mixed-case native library optimization flags, and Debug-only CRT installation with Ninja and Ninja Multi-Config. The unmodified zstd target built with the canonical Debug value, and a Node smoke check covered mixed-case Rollup settings. A native Windows IJW build was not run. > [!NOTE] > This description was generated with GitHub Copilot. Co-authored-by: Copilot App <[email protected]>
I don't believe we ever correctly fixed building swift libraries in release mode. In #104383 we added changes to cmake to make this work, but it used the wrong casing, and Cmake's
STREQUALis case-sensitive.For libraries builds,
CMAKE_BUILD_TYPEalways appears to be upper case:CMAKE_BUILD_TYPEgets set here to$buildtyperuntime/eng/native/gen-buildsys.sh
Line 179 in e56caa3
And
buildtypeis set here:runtime/eng/native/gen-buildsys.sh
Lines 46 to 49 in e56caa3
upperIis the uppercase version of the build, so the string comparison would fail.This change instead uses the
UPPERCASE_CMAKE_BUILD_TYPEexplicitly, and compares it to the uppercase version.This makes the System.Security.Cryptography.Apple.dylib about 16% smaller. It also gives a modest performance improvement to things that go through the swift shim.