krzyzanowskim / OpenSSL

OpenSSL package for SwiftPM, CocoaPod, and Carthage, multiplatform
https://swift.best
Other
928 stars 340 forks source link

Workaround for Xcode 16.0 Beta uint64_t problem #215

Closed IvanGurtler closed 5 months ago

IvanGurtler commented 5 months ago

Workaround for Xcode 16.0 Beta problem with uint64_t by adding import to umbrella headers

IvanGurtler commented 5 months ago

Workaround for issue https://github.com/krzyzanowskim/OpenSSL/issues/213

Jan-E commented 5 months ago

This might be a temp problem. Would not it be better to wrap the extra lines in

#ifndef uint64_t
…
#endif
krzyzanowskim commented 5 months ago

I hope this is a temporary issue. waiting for beta2 to see if anything change

fpaasche commented 5 months ago

Xcode 16 beta 2 was just released, and the build still fails.

IvanGurtler commented 5 months ago

@krzyzanowskim I tried with Xcode 16.0 beta2 but the #213 problem is still there :(

Just to be sure ... I tried this PR workaround with beta2 build and it seems to be ok and ready to code review (and merge).

jessesquires commented 5 months ago

@krzyzanowskim I understand the hesitation here.

One idea:

  1. Merge this for now to unblock folks and tag a release
  2. Keep testing with the betas to see if it gets resolved
  3. Revert this later if necessary/possible
jessesquires commented 5 months ago

This patch is actually not working for my project.

It appears to be an issue in the original openssl project: https://github.com/openssl/openssl/blob/master/include/openssl/e_os2.h#L267

At the line above, Xcode 16 Beta 2 produces the error:

Declaration of 'uint64_t' must be imported from module 'DarwinFoundation.stdint.uint64_t' before it is required
IvanGurtler commented 5 months ago

This patch is actually not working for my project.

It appears to be an issue in the original openssl project: https://github.com/openssl/openssl/blob/master/include/openssl/e_os2.h#L267

At the line above, Xcode 16 Beta 2 produces the error:

Declaration of 'uint64_t' must be imported from module 'DarwinFoundation.stdint.uint64_t' before it is required

1) How did you use this changes? SPM or run create-frameworks.sh? (Rebuild of xcframework is required, since SPM package is using it as binary dependency. But we don’t have access to provisioning profile, therefore it’s not part of this pull request)

2) I thing that it is not issue in the original openssl project because with 15.x Xcode it is not problem.

jessesquires commented 5 months ago

1) How did you use this changes? SPM or run create-frameworks.sh? (Rebuild of xcframework is required, since SPM package is using it as binary dependency.

Ah! That's the problem. I attempted to pull in these changes via SPM.

krzyzanowskim commented 5 months ago

3.1.5006 should fix that - "works on my machine". Please somebody update and report back

fpaasche commented 5 months ago

Unfortunately, it didn't work for me. I updated the package version to 3.1.5006, deleted the derived data and opened my project in Xcode 16 beta 2. I got one compiler error.

The line causing the error contains

 #  include <inttypes.h>

The error messsage was:

OpenSSL.framework/Headers/e_os2.h:234:12 Include of non-modular header inside framework module 'OpenSSL.e_os2': '/Users/<username redacted>/Applications/Xcode-beta-06-26.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/include/inttypes.h'

while building module 'OpenSSL':

in file included from <module-includes>:1:

in file included from .../OpenSSL.framework/Headers/OpenSSL.h:2:

in file included from .../OpenSSL.framework/Headers/ssl.h:26:
krzyzanowskim commented 5 months ago

@fpaasche

how is that even. This is clean build of the Integration-Examples/SPM

https://github.com/krzyzanowskim/OpenSSL/assets/758033/da6bd2fa-4058-441a-a37c-789aebb4681a

send me your project

jessesquires commented 5 months ago

I'm seeing the same issue as @fpaasche.

OpenSSL.framework/Headers/e_os2.h:234:12 Include of non-modular header inside framework module 'OpenSSL.e_os2': '/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/include/inttypes.h'

@krzyzanowskim I think whatever SwiftPM is doing is different than an Xcode Project. Try integrating the library via SwiftPM for an Xcode app project.

krzyzanowskim commented 5 months ago

I think whatever SwiftPM is doing is different than an Xcode Project. Try integrating the library via SwiftPM for an Xcode app project.

please send me your sample project that fail to build

Here's my setup of new Xcode project:

https://github.com/krzyzanowskim/OpenSSL/assets/758033/0704e6dc-64ee-4ef8-b281-f4b65eb6d9ab

IvanGurtler commented 5 months ago

For our library using OpenSSL version 3.1.5006 resolved the build problem on Xcode 16.0 beta2 (for Package and Xcode project. On Xcode 15.4 it is OK too)

jessesquires commented 5 months ago

For our library using OpenSSL version 3.1.5006 resolved the build problem on Xcode 16.0 beta2 (for Package and Xcode project. On Xcode 15.4 it is OK too)

Ok, actually this is the same for us too.

@krzyzanowskim

Sorry for the confusion and back-and-forth. Release 3.1.5006 is working for us.

As for the issue that I described above:

OpenSSL.framework/Headers/e_os2.h:234:12 Include of non-modular header inside framework module 'OpenSSL.e_os2': 
'/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/include/inttypes.h'

This was happening because we had an internal framework (mixed ObjC and Swift) that was being imported into our main App Target. This framework depended on OpenSSL. We had an umbrella header that had #import <OpenSSL/OpenSSL.h>. I was able to get rid of our C/ObjC code and use everything we needed from OpenSSL directly in Swift (thus deleting the header files). After that, the error above was resolved.

krzyzanowskim commented 5 months ago

thank you!

I'm going to close that PR. It was a great inspiration nonetheless!

fpaasche commented 5 months ago

@fpaasche

how is that even. This is clean build of the Integration-Examples/SPM

Screen.Recording.2024-06-30.at.19.48.47.mov

send me your project

Here is a minimal example of a project that does not compile. It's a new project, with OpenSSL 3.1.5006 added as a package. Then two files were added, the SRP implementation from https://github.com/cocagne/csrp

Demo.zip

krzyzanowskim commented 5 months ago

@fpaasche

right. it builds when you disable modules CLANG_ENABLE_MODULES = NO

Screenshot 2024-07-01 at 21 11 45

or

CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES

Screenshot 2024-07-01 at 21 13 03

I don't know why, but apparently something has changed about that

fpaasche commented 5 months ago

Adding CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES made my code compile. Thank you very much!

krzyzanowskim commented 4 months ago

FYI 3.1.5007 has changes that affect these problems. (hopefully, all of it)