Closed skull-squadron closed 7 years ago
Will troubleshoot because there is some dependency differences between Homebrew and user-attended causing it to fail.
Intel's avx-optimized asm scripts appear to output empty files with all of the following nasm versions on OS X:
& Generating empty .s files
(cd crypto/chacha20poly130 && /usr/bin/perl asm/chacha20_avx2.pl macosx)
Perhaps non-avx platforms need dependencies altered to match fallbacks to non-avx/-avx2 implementations.
@steakknife The problem is due to newer versions of Apple's clang no longer showing the original clang version, so you need to add another avx check at the top of each perl file:
if (`$ENV{CC} -v 2>&1` =~ /^Apple LLVM version [7-9]/) {
$avx = 2;
}
After that the files get generated, but I'm running into another error:
Undefined symbols for architecture x86_64:
"poly1305_finish_x64", referenced from:
_poly1305_finish_avx2 in libcrypto.a(poly1305_avx2.o)
(maybe you meant: _poly1305_finish_x64)
"poly1305_update_x64", referenced from:
_poly1305_update_avx2 in libcrypto.a(poly1305_avx2.o)
(maybe you meant: _poly1305_update_x64)
ld: symbol(s) not found for architecture x86_64
I fixed this manually by replacing jmp poly1305_update_x64
with jmp _poly1305_update_x64
inside poly1305_avx2.s
it seems this is a translation error by the x86_64-xlate.pl
script, which should also mangle the symbol for the jump, because it references a global that is mangled.
After reading the code of x86_64-xlate.pl
I noticed that those unmagled symbols should've been marked as extern, so the complete fix is:
diff --git a/crypto/chacha20poly1305/asm/chacha20_avx.pl b/crypto/chacha20poly1305/asm/chacha20_avx.pl
index bf3e3f0..4a8e9f3 100644
--- a/crypto/chacha20poly1305/asm/chacha20_avx.pl
+++ b/crypto/chacha20poly1305/asm/chacha20_avx.pl
@@ -68,6 +68,10 @@ if (`$ENV{CC} -v 2>&1` =~ /(^clang version|based on LLVM) ([3-9])\.([0-9]+)/) {
$avx = ($ver>=3.0) + ($ver>=3.01);
}
+if (`$ENV{CC} -v 2>&1` =~ /^Apple LLVM version [7-9]/) {
+ $avx = 2;
+}
+
if ($avx>=1) {{
my ($rol8, $rol16, $state_cdef, $tmp,
diff --git a/crypto/chacha20poly1305/asm/chacha20_avx2.pl b/crypto/chacha20poly1305/asm/chacha20_avx2.pl
index 9f31f86..f6dcb31 100644
--- a/crypto/chacha20poly1305/asm/chacha20_avx2.pl
+++ b/crypto/chacha20poly1305/asm/chacha20_avx2.pl
@@ -67,6 +67,10 @@ if (`$ENV{CC} -v 2>&1` =~ /(^clang version|based on LLVM) ([3-9])\.([0-9]+)/) {
$avx = ($ver>=3.0) + ($ver>=3.01);
}
+if (`$ENV{CC} -v 2>&1` =~ /^Apple LLVM version [7-9]/) {
+ $avx = 2;
+}
+
if ($avx>=2) {{
my ($state_4567, $state_89ab, $state_cdef, $tmp,
diff --git a/crypto/chacha20poly1305/asm/poly1305_avx.pl b/crypto/chacha20poly1305/asm/poly1305_avx.pl
index cedeca1..c30f6a1 100644
--- a/crypto/chacha20poly1305/asm/poly1305_avx.pl
+++ b/crypto/chacha20poly1305/asm/poly1305_avx.pl
@@ -74,6 +74,10 @@ if (`$ENV{CC} -v 2>&1` =~ /(^clang version|based on LLVM) ([3-9])\.([0-9]+)/) {
$avx = ($ver>=3.0) + ($ver>=3.01);
}
+if (`$ENV{CC} -v 2>&1` =~ /^Apple LLVM version [7-9]/) {
+ $avx = 2;
+}
+
if ($avx>=1) {{
my ($_r0_, $_r1_, $_r2_, $_r3_, $_r4_,
diff --git a/crypto/chacha20poly1305/asm/poly1305_avx2.pl b/crypto/chacha20poly1305/asm/poly1305_avx2.pl
index d2dd51f..90dc4a8 100644
--- a/crypto/chacha20poly1305/asm/poly1305_avx2.pl
+++ b/crypto/chacha20poly1305/asm/poly1305_avx2.pl
@@ -57,6 +57,10 @@ if (`$ENV{CC} -v 2>&1` =~ /(^clang version|based on LLVM) ([3-9])\.([0-9]+)/) {
$avx = ($ver>=3.0) + ($ver>=3.01);
}
+if (`$ENV{CC} -v 2>&1` =~ /^Apple LLVM version [7-9]/) {
+ $avx = 2;
+}
+
if ($avx>=1) {{
my ($_r0_, $_r1_, $_r2_, $_r3_, $_r4_,
@@ -395,6 +399,7 @@ my ($state, $in, $in_len, $hlp, $rsp_save)
$code.=<<___;
+.extern poly1305_update_x64
###############################################################################
# void poly1305_update_avx2(void* $state, void* in, uint64_t in_len)
.globl poly1305_update_avx2
@@ -907,6 +912,7 @@ poly1305_update_avx2:
6:
ret
.size poly1305_update_avx2,.-poly1305_update_avx2
+.extern poly1305_finish_x64
###############################################################################
# void poly1305_finish_avx2(void* $state, uint8_t mac[16]);
.type poly1305_finish_avx2,\@function,2
diff --git a/crypto/chacha20poly1305/asm/poly1305_x64.pl b/crypto/chacha20poly1305/asm/poly1305_x64.pl
index 31c4c47..478f707 100644
--- a/crypto/chacha20poly1305/asm/poly1305_x64.pl
+++ b/crypto/chacha20poly1305/asm/poly1305_x64.pl
@@ -55,6 +55,10 @@ if (`$ENV{CC} -v 2>&1` =~ /(^clang version|based on LLVM) ([3-9])\.([0-9]+)/) {
$avx = ($ver>=3.0) + ($ver>=3.01);
}
+if (`$ENV{CC} -v 2>&1` =~ /^Apple LLVM version [7-9]/) {
+ $avx = 2;
+}
+
{
{
After that compilation and make test
on macosx with OpenSSL_1_0_2-stable is successful.
Awesome, thanks Apple (sarcasm) while thanks (non-sarcasm) @felixbuenemann.
Looks like there maybe a dependency issue which is not present in vanilla 1.0.2g.
Edit: Fails in all tested configurations: default configure options,
no-shared
,no-fips
, etc.More build logs here updated: minimal examples