krzyzanowskim / OpenSSL

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

opensslconf.h is correct for one architecture; and not the others #23

Closed noloader closed 5 years ago

noloader commented 8 years ago

opensslconf.h is generated anew for each configuration of OpenSSL. Its _not_ safe to use one opensslconf.h for all OpenSSL configurations. Also see Is it safe to build the cURL library as multi-arch? (same problem, different library).

From the looks of opensslconf.h located in include-ios/openssl, it appears the conf file is for i386 (i.e., iOS debugging):

/* Generate 80386 code? */
#undef I386_ONLY
...

The work around for fat binaries is to copy each opensslconf.h with a new name. I.e, the opensslconf.h generated with armv7 would be named opensslconf-armv7.h, the opensslconf.h generated with i386 would be named opensslconf-i386.h, and so on.

Then, you provide one opensslconf.h which gathers up the architecture dependent conf files:

/* opensslconf.h */

#if defined(__APPLE__) && defined (__i386__)
# include opensslconf-i386.h
#endif

#if defined(__APPLE__) && defined (__arm__)
# include opensslconf-armv7.h
#endif

#if defined(__APPLE__) && (defined (__arm64__) || defined (__aarch64__))
# include opensslconf-arm64.h
#endif

...

My apologies if I am parsing things incorrectly.

krzyzanowskim commented 8 years ago

opensslconf.h is generated for arm64, though I agree it's better if it would match to the architectures. If you have some time you can try do changes to build script and generate it with such umbrella header.

krzyzanowskim commented 5 years ago

It's done now.