Repository: conan-io/conan-center-index

Issue:
[package] openssl/1.1.1k: Add macOS ARM target for assembly code
OpenSSL's darwin64-arm64-cc is available since 1.1.1i and is necessary to enable assembly code support.

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **openssl/1.1.1k**
  * Operating System+version: **macOS 11**
  * Compiler+version: **clang 12**
  * conan: **Conan version 1.39.0**
  * python: **Python 3.9.6**

### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
[settings]
os=Macos
os_build=Macos
os.version=11.0
arch=armv8
arch_build=armv8
compiler=apple-clang
compiler.version=12.0
compiler.libcxx=libc++
build_type=Release
compiler.cppstd=11
[options]
[build_requires]
[env]
```


### Steps to reproduce (Include if Applicable)

conan create . openssl/1.1.1k@gmeeker/stable -pr arm

openssl will compile, but uses the generic defines instead of using the ARM optimizations.

### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang  -I. -Iinclude -fPIC -O3 -fPIC -mmacosx-version-min=11.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -arch arm64 -O3 -fPIC -DOPENSSL_PIC -DOPENSSLDIR="\"/Users/gmeeker/.conan/data/openssl/1.1.1k/gmeeker/stable/package/117365423c88756548dc67f9d569270bb8464549/res\"" -DENGINESDIR="\"/Users/gmeeker/.conan/data/openssl/1.1.1k/gmeeker/stable/package/117365423c88756548dc67f9d569270bb8464549/lib/engines-1.1\"" -D_REENTRANT -DNDEBUG -DNDEBUG  -MMD -MF crypto/asn1/bio_ndef.d.tmp -MT crypto/asn1/bio_ndef.o -c -o crypto/asn1/bio_ndef.o crypto/asn1/bio_ndef.c
```

Should look like:
```
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang  -I. -Iinclude -fPIC -arch arm64 -O3 -fPIC -mmacosx-version-min=11.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -arch arm64 -O3 -Wall -fPIC -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/Users/gmeeker/.conan/data/openssl/1.1.1k/gmeeker/stable/package/117365423c88756548dc67f9d569270bb8464549/res\"" -DENGINESDIR="\"/Users/gmeeker/.conan/data/openssl/1.1.1k/gmeeker/stable/package/117365423c88756548dc67f9d569270bb8464549/lib/engines-1.1\"" -D_REENTRANT -DNDEBUG -DNDEBUG  -MMD -MF crypto/asn1/asn_mime.d.tmp -MT crypto/asn1/asn_mime.o -c -o crypto/asn1/asn_mime.o crypto/asn1/asn_mime.c
```

</details>



Discussion:

Resolving patch:
diff --git a/recipes/openssl/1.x.x/conanfile.py b/recipes/openssl/1.x.x/conanfile.py
--- a/recipes/openssl/1.x.x/conanfile.py
+++ b/recipes/openssl/1.x.x/conanfile.py
@@ -293,6 +293,7 @@ def _asm_target(self):
     def _targets(self):
         is_cygwin = self.settings.get_safe("os.subsystem") == "cygwin"
         is_1_0 = self._full_version < "1.1.0"
+        has_darwin_arm = self._full_version >= "1.1.1i" or is_1_0
         return {
             "Linux-x86-clang": ("%slinux-generic32" % self._target_prefix) if is_1_0 else "linux-x86-clang",
             "Linux-x86_64-clang": ("%slinux-x86_64" % self._target_prefix) if is_1_0 else "linux-x86_64-clang",
@@ -329,6 +330,7 @@ def _targets(self):
             "Macos-ppc32be-*": "%sdarwin-ppc-cc" % self._target_prefix,
             "Macos-ppc64-*": "darwin64-ppc-cc",
             "Macos-ppc64be-*": "darwin64-ppc-cc",
+            "Macos-armv8-*": "darwin64-arm64-cc" if has_darwin_arm else "darwin-common",
             "Macos-*-*": "darwin-common",
             "iOS-x86_64-*": "darwin64-x86_64-cc",
             "iOS-*-*": "iphoneos-cross",
@@ -725,6 +727,9 @@ def build(self):
                                     base_path=self._source_subfolder)
                     self._create_targets()
                 else:
+                    if self.settings.os == "Macos":
+                        tools.patch(patch_file=os.path.join("patches", "1.0.2u-darwin-arm64.patch"),
+                                    base_path=self._source_subfolder)
                     self._patch_configure()
                     self._patch_makefile_org()
                 with self._make_context():


Test patch: