Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 729422 - app-crypt/johntheripper-1.8.0[custom-cflags] fails to compile: (with -mavx or -mxop): john.c: undefined reference to `CPU_detect'
Summary: app-crypt/johntheripper-1.8.0[custom-cflags] fails to compile: (with -mavx or...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: Normal normal
Assignee: Rick Farina (Zero_Chaos)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-24 11:21 UTC by Agostino Sarubbo
Modified: 2025-02-16 13:17 UTC (History)
0 users

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


Attachments
build.log (build.log,17.57 KB, text/plain)
2020-06-24 11:21 UTC, Agostino Sarubbo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2020-06-24 11:21:13 UTC
@@This is an auto-filed bug@@
Feel free to change the summary at your convenience.

Issue: app-crypt/johntheripper fails to compile.
Discovered on: amd64

NOTE:
If yout think this issue is related to clang/llvm toolchain, please block bug 408963. If you need further logs, feel free to ask.
Comment 1 Agostino Sarubbo gentoo-dev 2020-06-24 11:21:21 UTC
Created attachment 646030 [details]
build.log

build log and emerge --info
Comment 2 Arfrever Frehtes Taifersar Arahesis 2020-06-25 07:56:58 UTC
This bug is reproducible (with both GCC and Clang) if -mavx flag is used explicitly or implicitly through -march=... flag (at least on x86_64 architecture).
Comment 3 Arfrever Frehtes Taifersar Arahesis 2020-06-25 08:10:56 UTC
Another flag allowing to reproduce this bug is -mxop.


src/x86-64.h:
[[[
#define CPU_DETECT                      0

#ifdef __XOP__
#define JOHN_XOP
#endif
#if defined(__AVX__) || defined(JOHN_XOP)
#define JOHN_AVX
#endif
...
#if 0
#define DES_BS_VECTOR                   0
#define DES_BS_ALGORITHM_NAME           "DES 64/64"
#elif defined(JOHN_AVX) && (defined(__GNUC__) || defined(_OPENMP))
/*
 * Require gcc for AVX/XOP because DES_bs_all is aligned in a gcc-specific way,
 * except in OpenMP-enabled builds, where it's aligned by different means.
 */
#undef CPU_DETECT
#define CPU_DETECT                      1
]]]


So either __AVX__ or __XOP__ results in defining CPU_DETECT=1.
Otherwise CPU_DETECT=0.


src/john.c:
[[[
#if CPU_DETECT
extern int CPU_detect(void);
#endif
...
#if CPU_DETECT
static void CPU_detect_or_fallback(char **argv, int make_check)
{       
        if (!CPU_detect()) {
]]]
Comment 4 JS 2021-07-14 21:27:05 UTC
What's the solution to this?
Comment 5 xnaxdy 2023-01-29 21:34:06 UTC
The solution to this if you are using -march=... system-wide, is to create a file named e.g. nonative.conf in /etc/portage/env with the following contents:

```
COMMON_FLAGS="-O3 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLACS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
```

Then create a file in /etc/portage/package.env with the following contents:

```
app-crypt/johntheripper nonative.conf
```

johntheripper should then compile without issue
Comment 6 Larry the Git Cow gentoo-dev 2025-02-16 13:17:45 UTC
The bug has been referenced in the following commit(s):

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

commit 18189332f06a98ab06657cfc661ab2f4c9b106cb
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2025-02-16 13:12:00 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2025-02-16 13:17:10 +0000

    app-crypt/johntheripper-jumbo: add 1.9.0_p20250216
    
    Add a workaround for bug #729422 which isn't complete but should
    help with building in common configurations. Keeping the bug open
    so we can sort it out properly.
    
    Bug: https://bugs.gentoo.org/729422
    Closes: https://bugs.gentoo.org/948330
    Closes: https://bugs.gentoo.org/943973
    Signed-off-by: Sam James <sam@gentoo.org>

 app-crypt/johntheripper-jumbo/Manifest             |   1 +
 .../johntheripper-jumbo-1.9.0_p20250216.ebuild     | 161 +++++++++++++++++++++
 .../johntheripper-jumbo-9999.ebuild                |  12 +-
 3 files changed, 171 insertions(+), 3 deletions(-)