Repository: conan-io/conan-center-index

Issue:
[package] s2n/1.0.11: compilation error with gcc 8 on Ubuntu 16.04
<!-- 
  Please don't forget to update the issue title.
  Include all applicable information to help us reproduce your problem.
-->

error from assembler:
```
/tmp/ccgRylqp.s:21: Error: operand type mismatch for `vpclmulqdq'
```

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **s2n/1.0.11**
  * Operating System+version: **Linux Ubuntu 16.04**
  * Compiler+version: **GCC 8**
  * Docker image: **conanio/gcc8-ubuntu16.04**
  * Conan version: **conan 1.41.0**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux
os_build=Linux
[options]
[build_requires]
[env]
```


### Steps to reproduce (Include if Applicable)

conan install --build s2n s2n/1.0.11@

### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux
os_build=Linux
[options]
[build_requires]
[env]

openssl/1.1.1k: Not found in local cache, looking in remotes...
openssl/1.1.1k: Trying with 'artifactory'...
Downloading conanmanifest.txt completed [0.18k]                                          
Downloading conanfile.py completed [38.94k]                                              
Downloading conan_export.tgz completed [0.25k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
openssl/1.1.1k: Downloaded recipe revision 4f045ca28f916bb73ba1088d599e3c4b
s2n/1.0.11: Forced build from source
Installing package: s2n/1.0.11
Requirements
    openssl/1.1.1k from 'artifactory' - Downloaded
    s2n/1.0.11 from 'artifactory' - Cache
Packages
    openssl/1.1.1k:1d877a3df840030e6a8abb74c5ffb9088d08b47a - Download
    s2n/1.0.11:350d33ddf32155dd06e685053280c2bc034a85f7 - Build

Installing (downloading, building) binaries...
openssl/1.1.1k: Retrieving package 1d877a3df840030e6a8abb74c5ffb9088d08b47a from remote 'conancenter' 
Downloading conanmanifest.txt completed [6.30k]                                          
Downloading conaninfo.txt completed [2.27k]                                              
Downloading conan_package.tgz completed [3910.02k]                                       
Decompressing conan_package.tgz completed [0.00k]                                        
openssl/1.1.1k: Package installed 1d877a3df840030e6a8abb74c5ffb9088d08b47a
openssl/1.1.1k: Downloaded package revision d98d4502d60eb17df288dd73e9b2172b
[HOOK - conan-recipes.py] post_package_info(): [CMAKE FILE NOT IN BUILD FOLDERS (KB-H019)] OK
[HOOK - conan-recipes.py] post_package_info(): [LIBRARY DOES NOT EXIST (KB-H054)] OK
s2n/1.0.11: Copying sources to build folder
s2n/1.0.11: Building your package in /home/conan/.conan/data/s2n/1.0.11/_/_/build/350d33ddf32155dd06e685053280c2bc034a85f7
s2n/1.0.11: Generator cmake created conanbuildinfo.cmake
s2n/1.0.11: Generator cmake_find_package created FindOpenSSL.cmake
s2n/1.0.11: Aggregating env generators
[HOOK - conan-recipes.py] pre_build(): [FPIC MANAGEMENT (KB-H007)] OK. 'fPIC' option found and apparently well managed
[HOOK - conan-recipes.py] pre_build(): [FPIC MANAGEMENT (KB-H007)] OK
s2n/1.0.11: Calling build()
-- The C compiler identification is GNU 8.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/local/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Conan: called by CMake conan helper
-- Conan: called inside local cache
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Conan: Adjusting fPIC flag (ON)
-- This project seems to be plain C, using 'GNU' compiler
-- Conan: Compiler GCC>=5, checking major version 8
-- Conan: Checking correct version: 8
-- Conan: Using autogenerated FindOpenSSL.cmake
-- Found OpenSSL: 1.1.1k (found version "1.1.1k") 
-- Conan: Component 'Crypto' found in package 'OpenSSL'
-- Library ssl found /home/conan/.conan/data/openssl/1.1.1k/_/_/package/1d877a3df840030e6a8abb74c5ffb9088d08b47a/lib/libssl.a
-- Found: /home/conan/.conan/data/openssl/1.1.1k/_/_/package/1d877a3df840030e6a8abb74c5ffb9088d08b47a/lib/libssl.a
-- Library crypto found /home/conan/.conan/data/openssl/1.1.1k/_/_/package/1d877a3df840030e6a8abb74c5ffb9088d08b47a/lib/libcrypto.a
-- Found: /home/conan/.conan/data/openssl/1.1.1k/_/_/package/1d877a3df840030e6a8abb74c5ffb9088d08b47a/lib/libcrypto.a
-- Library crypto found /home/conan/.conan/data/openssl/1.1.1k/_/_/package/1d877a3df840030e6a8abb74c5ffb9088d08b47a/lib/libcrypto.a
-- Found: /home/conan/.conan/data/openssl/1.1.1k/_/_/package/1d877a3df840030e6a8abb74c5ffb9088d08b47a/lib/libcrypto.a
-- Library ssl found /home/conan/.conan/data/openssl/1.1.1k/_/_/package/1d877a3df840030e6a8abb74c5ffb9088d08b47a/lib/libssl.a
-- Found: /home/conan/.conan/data/openssl/1.1.1k/_/_/package/1d877a3df840030e6a8abb74c5ffb9088d08b47a/lib/libssl.a
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- The ASM compiler identification is GNU
-- Found assembler: /usr/local/bin/cc
-- Enabling SIKEP434R3 assembly code
-- Enabling BIKE_R3 x86_64 optimizations
-- Support for ADX assembly instructions detected
-- S2N found target: crypto
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_EXPORT_NO_PACKAGE_REGISTRY


-- Build files have been written to: /home/conan/.conan/data/s2n/1.0.11/_/_/build/350d33ddf32155dd06e685053280c2bc034a85f7
Scanning dependencies of target s2n
[  0%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_aead_cipher_aes_gcm.c.o
[  0%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_aead_cipher_chacha20_poly1305.c.o
[  1%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_cbc_cipher_3des.c.o
[  1%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_cipher.c.o
[  2%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_cbc_cipher_aes.c.o
[  2%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_certificate.c.o
[  2%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_composite_cipher_aes_sha.c.o
[  3%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_crypto.c.o
[  3%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_dhe.c.o
[  4%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_drbg.c.o
[  4%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_ecc_evp.c.o
[  5%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_ecdsa.c.o
[  5%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_evp.c.o
[  5%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_fips.c.o
[  6%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_hash.c.o
[  6%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_hkdf.c.o
[  7%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_hmac.c.o
[  7%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_openssl_x509.c.o
[  7%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_pkey.c.o
[  8%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_rsa.c.o
[  8%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_rsa_pss.c.o
[  9%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_rsa_signing.c.o
[  9%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_sequence.c.o
[ 10%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_stream_cipher_null.c.o
[ 10%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_stream_cipher_rc4.c.o
[ 10%] Building C object source_subfolder/CMakeFiles/s2n.dir/crypto/s2n_tls13_keys.c.o
[ 11%] Building C object source_subfolder/CMakeFiles/s2n.dir/error/s2n_errno.c.o
[ 11%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r1/aes_ctr_prf.c.o
[ 12%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r1/bike_r1_kem.c.o
[ 12%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r1/converts_portable.c.o
[ 12%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r1/decode.c.o
[ 13%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r1/error.c.o
[ 13%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r1/gf2x_mul.c.o
[ 14%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r1/gf2x_portable.c.o
[ 14%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r1/openssl_utils.c.o
[ 15%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r1/parallel_hash.c.o
[ 15%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r1/sampling.c.o
[ 15%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r1/sampling_portable.c.o
[ 16%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r1/secure_decode_portable.c.o
[ 16%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r1/utilities.c.o
[ 17%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r2/aes_ctr_prf.c.o
[ 17%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r2/bike_r2_kem.c.o
[ 17%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r2/decode.c.o
[ 18%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r2/error.c.o
[ 18%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r2/gf2x_mul.c.o
[ 19%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r2/gf2x_portable.c.o
[ 19%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r2/openssl_utils.c.o
[ 20%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r2/sampling.c.o
[ 20%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r2/sampling_portable.c.o
[ 20%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r2/secure_decode_portable.c.o
[ 21%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r2/utilities.c.o
[ 21%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/aes_ctr_prf.c.o
[ 22%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/bike_r3_kem.c.o
[ 22%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/decode.c.o
[ 22%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/decode_avx2.c.o
[ 23%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/decode_avx512.c.o
[ 23%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/decode_portable.c.o
[ 24%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/error.c.o
[ 24%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/gf2x_inv.c.o
[ 25%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/gf2x_ksqr_avx2.c.o
[ 25%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/gf2x_ksqr_avx512.c.o
[ 25%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/gf2x_ksqr_portable.c.o
[ 26%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/gf2x_mul.c.o
[ 26%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/gf2x_mul_avx2.c.o
[ 27%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/gf2x_mul_avx512.c.o
[ 27%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/gf2x_mul_base_pclmul.c.o
[ 27%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/gf2x_mul_base_portable.c.o
[ 28%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/gf2x_mul_base_vpclmul.c.o
[ 28%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/gf2x_mul_portable.c.o
[ 29%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/sampling.c.o
[ 29%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/sampling_avx2.c.o
[ 30%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/sampling_avx512.c.o
[ 30%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/sampling_portable.c.o
[ 30%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/utilities.c.o
[ 31%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/kyber_90s_r2/aes256ctr.c.o
[ 31%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/kyber_90s_r2/aes_c.c.o
[ 32%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/kyber_90s_r2/cbd.c.o
[ 32%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/kyber_90s_r2/indcpa.c.o
[ 32%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/kyber_90s_r2/kyber_90s_r2_kem.c.o
[ 33%] Building C object source_subfolder/CMakeFiles/s2n.dir/pq-crypto/kyber_90s_r2/ntt.c.o
/tmp/ccgRylqp.s: Assembler messages:
/tmp/ccgRylqp.s:21: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:25: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:37: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:45: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:53: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:57: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:61: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:62: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:70: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:74: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:102: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:126: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:128: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:132: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:136: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:140: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:141: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:148: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:151: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:183: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:195: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:201: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:209: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:212: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:214: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:224: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:226: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:283: Error: operand type mismatch for `vpclmulqdq'
/tmp/ccgRylqp.s:284: Error: operand type mismatch for `vpclmulqdq'
source_subfolder/CMakeFiles/s2n.dir/build.make:952: recipe for target 'source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/gf2x_mul_base_vpclmul.c.o' failed
make[2]: *** [source_subfolder/CMakeFiles/s2n.dir/pq-crypto/bike_r3/gf2x_mul_base_vpclmul.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:112: recipe for target 'source_subfolder/CMakeFiles/s2n.dir/all' failed
make[1]: *** [source_subfolder/CMakeFiles/s2n.dir/all] Error 2
Makefile:148: recipe for target 'all' failed
make: *** [all] Error 2
s2n/1.0.11: 
s2n/1.0.11: ERROR: Package '350d33ddf32155dd06e685053280c2bc034a85f7' build failed
s2n/1.0.11: WARN: Build folder /home/conan/.conan/data/s2n/1.0.11/_/_/build/350d33ddf32155dd06e685053280c2bc034a85f7
ERROR: s2n/1.0.11: Error in build() method, line 60
        cmake.build()
        ConanException: Error 2 while executing cmake --build '/home/conan/.conan/data/s2n/1.0.11/_/_/build/350d33ddf32155dd06e685053280c2bc034a85f7' '--' '-j8'```

</details>



Discussion:
also opened upstream: https://github.com/aws/s2n-tls/issues/3166

Resolving patch:
diff --git a/recipes/s2n/all/conanfile.py b/recipes/s2n/all/conanfile.py
--- a/recipes/s2n/all/conanfile.py
+++ b/recipes/s2n/all/conanfile.py
@@ -1,5 +1,6 @@
 from conans import ConanFile, CMake, tools
 from conans.errors import ConanInvalidConfiguration
+from conan.tools.files import apply_conandata_patches
 import os
 
 required_conan_version = ">=1.43.0"
@@ -12,7 +13,6 @@ class S2n(ConanFile):
     url = "https://github.com/conan-io/conan-center-index"
     homepage = "https://github.com/aws/s2n-tls"
     license = "Apache-2.0",
-
     settings = "os", "arch", "compiler", "build_type"
     options = {
         "shared": [True, False],
@@ -23,7 +23,6 @@ class S2n(ConanFile):
         "fPIC": True,
     }
 
-    exports_sources = "CMakeLists.txt"
     generators = "cmake", "cmake_find_package"
     _cmake = None
 
@@ -31,6 +30,11 @@ class S2n(ConanFile):
     def _source_subfolder(self):
         return "source_subfolder"
 
+    def export_sources(self):
+        self.copy("CMakeLists.txt")
+        for patch in self.conan_data.get("patches", {}).get(self.version, []):
+            self.copy(patch["patch_file"])
+
     def configure(self):
         if self.options.shared:
             del self.options.fPIC
@@ -58,6 +62,7 @@ def _configure_cmake(self):
         return self._cmake
 
     def build(self):
+        apply_conandata_patches(self)
         cmake = self._configure_cmake()
         cmake.build()
 


Test patch: