Skip to content

Instantly share code, notes, and snippets.

@felixbuenemann
Created November 25, 2020 17:04
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixbuenemann/5f4dcb30ebb3b86e1302e2ec305bac89 to your computer and use it in GitHub Desktop.
Save felixbuenemann/5f4dcb30ebb3b86e1302e2ec305bac89 to your computer and use it in GitHub Desktop.
--- openssl-1.0.2u/Configure 2019-12-20 14:02:41.000000000 +0100
+++ openssl-1.0.2u/Configure 2020-11-22 16:23:13.000000000 +0100
@@ -650,7 +650,9 @@
"darwin-i386-cc","cc:-arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:".eval{my $asm=$x86_asm;$asm=~s/cast\-586\.o//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
"debug-darwin-i386-cc","cc:-arch i386 -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
"darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+"darwin64-arm64-cc","cc:-arch arm64 -O3 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-arch arm64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
"debug-darwin64-x86_64-cc","cc:-arch x86_64 -ggdb -g2 -O0 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+"debug-darwin64-arm64-cc","cc:-arch arm64 -ggdb -g2 -O0 -DL_ENDIAN -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-arch arm64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
"debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
# iPhoneOS/iOS
"iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
@oh-ok
Copy link

oh-ok commented Mar 26, 2024

Also experiencing this on Ruby 2.3.1.

You can disable the elliptical curve routines with the no-ec flag in configure. Though compiling with this still does not pass the cms‑test (so may be unstable), but it does compile and allow you to at least install gems.

EDIT 1:
Managed to compile a functional OpenSSL 1.0.2u with elliptical curve routines using Xcode 13 by downloading it, xcode-select --switch /path/to/new/Xcode.app/Contents/Developer/, then do a HOMEBREW_FAKE_MACOS="11.3" brew install rbenv/tap/openssl@1.0, and then xcode-select back to your native version. No guarantees of stability since this would fail the same cms‑test as above, but will at least have working elliptical curve routines and also be able to access rubygems.

EDIT 2:
Seems test_cms is expected to fail since the certs being tested have expired. Setting the system clock back to 2022 for make test fixes it 🤷‍♀️ otherwise, these solutions pass all tests.
The elliptical curve thing seems to be an LLVM-ism since I also managed to get it to compile perfectly with llvm@13 clang, but anything above that would fail.

EDIT 3:
After some more poking around, it turns out the elliptical curve issue was due to over-aggressive optimization by clang 14 and up. Fixed in https://github.com/rbenv/homebrew-tap/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment