Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 689162 - dev-libs/crypto++-8.2.0 with CXXFLAGS="-march=bdver1" - error: ‘_mm_roti_epi64’ was not declared in this scope
Summary: dev-libs/crypto++-8.2.0 with CXXFLAGS="-march=bdver1" - error: ‘_mm_roti_epi6...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal
Assignee: Crypto team [DISABLED]
URL: https://github.com/weidai11/cryptopp/...
Whiteboard:
Keywords:
Depends on:
Blocks: 689038
  Show dependency tree
 
Reported: 2019-07-02 15:11 UTC by 4ctrl.alt.del
Modified: 2019-07-03 18:59 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Build log (file_689162.txt,5.83 KB, text/plain)
2019-07-02 15:28 UTC, 4ctrl.alt.del
Details

Note You need to log in before you can comment on or make changes to this bug.
Description 4ctrl.alt.del 2019-07-02 15:11:59 UTC
When attempting to compile the ebuild crypto++-8.2.0 it fails if your CFLAGS/CXXFLAGS has the bdver1 architecture. If you add "-mno-fma4" the ebuild then compiles successfully with no errors. "-march=bdver2" also works with no errors. This has been verified by one other person on #gentoo by the nickname of iamben.
Comment 1 4ctrl.alt.del 2019-07-02 15:28:13 UTC
Created attachment 581760 [details]
Build log

Build log for crypto++8.2.0 when using march of bdver1 without disabling fma4
Comment 2 Ben Kohler gentoo-dev 2019-07-02 15:42:47 UTC
CXXFLAGS="-march=bdver1" -> FAIL
CXXFLAGS="-march=bdver1 -mbmi" -> SUCCESS
CXXFLAGS="-march=bdver1 -mno-fma4" -> SUCCESS
Comment 3 Alon Bar-Lev (RETIRED) gentoo-dev 2019-07-02 15:55:01 UTC
Please disable asm USE for now
Comment 4 Larry the Git Cow gentoo-dev 2019-07-02 16:51:21 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d116b2a7d690b9a9717b7b97b8c67eda503756e3

commit d116b2a7d690b9a9717b7b97b8c67eda503756e3
Author:     Alon Bar-Lev <alonbl@gentoo.org>
AuthorDate: 2019-07-02 16:48:35 +0000
Commit:     Alon Bar-Lev <alonbl@gentoo.org>
CommitDate: 2019-07-02 16:49:59 +0000

    dev-libs/crypto++: add explicit cpu_flags_x86 flag
    
    Closes: https://bugs.gentoo.org/show_bug.cgi?id=689162
    Signed-off-by: Alon Bar-Lev <alonbl@gentoo.org>
    Package-Manager: Portage-2.3.66, Repoman-2.3.11

 dev-libs/crypto++/crypto++-8.2.0-r1.ebuild         | 60 ++++++++++++++++++++++
 dev-libs/crypto++/files/crypto++-8.2.0-build.patch | 11 ++++
 dev-libs/crypto++/metadata.xml                     |  1 +
 3 files changed, 72 insertions(+)
Comment 5 Alon Bar-Lev (RETIRED) gentoo-dev 2019-07-02 16:52:46 UTC
Please try dev-libs/crypto++-8.2.0-r1 if not working, please attach emerge --info output
Comment 6 Jeffrey Walton 2019-07-02 19:35:20 UTC
We are trying to figure out the header we need with GCC. Neither <immintrin.h> or <ammintrin.h> are bringing in the symbol even though __XOP__ is defined in the preprocessor.

Also see Which header for AMD XOP _mm_roti_epi64?, https://gcc.gnu.org/ml/gcc-help/2019-07/msg00032.html .

(XOP rotates are fast, and I don't like to see it disabled).
Comment 7 Jeffrey Walton 2019-07-02 20:19:36 UTC
Here's a reproducer. We will likely have to file a GCC bug report for the issue.

bulldozer:~$ g++ -march=bdver1 -msse4.1 test.cxx
test.cxx: In function ‘int main(int, char**)’:
test.cxx:14:9: error: ‘_mm_roti_epi64’ was not declared in this scope
     b = _mm_roti_epi64(a, 1);
         ^~~~~~~~~~~~~~
test.cxx:14:9: note: suggested alternative: ‘_mm_srli_epi64’
     b = _mm_roti_epi64(a, 1);
         ^~~~~~~~~~~~~~
         _mm_srli_epi64

bulldozer:~$ cat test.cxx
#ifdef __XOP__
#include <immintrin.h>
#include <ammintrin.h>
#endif

#ifdef __SSE41__
#include <smmintrin.h>
#endif

int main(int argc, char* argv[])
{
    __m128i a=_mm_setzero_si128(), b=_mm_setzero_si128(), c;

#ifdef __XOP__
    b = _mm_roti_epi64(a, 1);
#endif

#ifdef __SSE41__
    c = _mm_blend_epi16(a, b, 0);
#endif

    return 0;
}
Comment 8 Jeffrey Walton 2019-07-02 20:46:09 UTC
Crypto++ is tracking the issue at https://github.com/weidai11/cryptopp/issues/859 .
Comment 9 Alon Bar-Lev (RETIRED) gentoo-dev 2019-07-02 20:52:33 UTC
(In reply to Jeffrey Walton from comment #8)
> Crypto++ is tracking the issue at
> https://github.com/weidai11/cryptopp/issues/859 .

Thanks!
Comment 10 Jeffrey Walton 2019-07-03 00:19:06 UTC
This should clear the issue: https://github.com/weidai11/cryptopp/commit/eeb7dadc7657

We had to use that awful <x86intrin.h> header. GCC did not use a standard header like <ammintrin.h>. The <x86intrin.h> header has been a bane for us. It is not available on may platforms, and it often leads to compile failures. We gutted it after a string of compile failures due to rdrand and rdseed.

The short of the eeb7dadc7657 change is, *_simd.cpp files that use XOP now do this gyration:

   #if defined(__XOP__)
   # include <ammintrin.h>
   # if defined(__GNUC__)
   #  include <x86intrin.h>
   # endif
   #endif

I'm not sure why we did not detect the problem earlier. I have a Bulldozer machine, and our test script is run on it. The test script uses -march=native (but not -march=bdver1). In fact, I ran it two days earlier and the XOP gear tested OK.
Comment 11 Larry the Git Cow gentoo-dev 2019-07-03 18:59:30 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ac1362559f5f84d43e121b0899927e8b9a15b741

commit ac1362559f5f84d43e121b0899927e8b9a15b741
Author:     Alon Bar-Lev <alonbl@gentoo.org>
AuthorDate: 2019-07-03 18:58:19 +0000
Commit:     Alon Bar-Lev <alonbl@gentoo.org>
CommitDate: 2019-07-03 18:58:58 +0000

    dev-libs/crypto++: fix amd64 asm
    
    Closes: https://bugs.gentoo.org/show_bug.cgi?id=689162
    Signed-off-by: Alon Bar-Lev <alonbl@gentoo.org>
    Package-Manager: Portage-2.3.66, Repoman-2.3.11

 ...++-8.2.0-r1.ebuild => crypto++-8.2.0-r2.ebuild} |   0
 dev-libs/crypto++/crypto++-8.2.0.ebuild            |   4 +
 dev-libs/crypto++/files/crypto++-8.2.0-build.patch | 260 +++++++++++++++++++++
 3 files changed, 264 insertions(+)