[GH-ISSUE #2743] MAYBE_INLINE is broken for GCC 5+ #1764

Closed
opened 2026-10-15 04:24:10 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @solardiz on GitHub (Sep 9, 2017).
Original GitHub issue: https://github.com/openwall/john/issues/2743

Commit 1c29d04c0a made as part of work on #1093 changed MAYBE_INLINE for GCC 5+ in a way that now results in failing to inline and a major performance regression (20%+ for one core in use, 10%+ for all in use) at least for descrypt at least when building with devtoolset-6's gcc 6.3.1 for AVX. I didn't look into the rationale for that old commit, but reverting from __attribute__((gnu_inline)) back to __attribute__((always_inline)) fixes the performance regression for me.

Originally created by @solardiz on GitHub (Sep 9, 2017). Original GitHub issue: https://github.com/openwall/john/issues/2743 Commit 1c29d04c0aed3cddf4ea0c9263e9a29e854464c2 made as part of work on #1093 changed MAYBE_INLINE for GCC 5+ in a way that now results in failing to inline and a major performance regression (20%+ for one core in use, 10%+ for all in use) at least for descrypt at least when building with devtoolset-6's gcc 6.3.1 for AVX. I didn't look into the rationale for that old commit, but reverting from `__attribute__((gnu_inline))` back to `__attribute__((always_inline))` fixes the performance regression for me.
bsakaguchi 2026-10-15 04:24:10 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@solardiz commented on GitHub (Sep 9, 2017):

This also fixes the issue for me:

diff --git a/src/common.h b/src/common.h
index 9ea02ab..0e9c534 100644
--- a/src/common.h
+++ b/src/common.h
@@ -49,7 +49,7 @@
 
 #ifdef __GNUC__
 #if __GNUC__ >= 5
-#define MAYBE_INLINE __attribute__((gnu_inline)) inline
+#define MAYBE_INLINE __attribute__((gnu_inline)) __attribute__((always_inline)) inline
 #elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || defined(__INTEL_COMPILER) || __NVCC__
 #define MAYBE_INLINE __attribute__((always_inline)) inline
 #elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)

I think the two attributes are not mutually-exclusive (or are they?), and it was a bug to drop __attribute__((always_inline)) in that fix for #1093. But we need to retest with early GCC 5 to ensure that issue isn't back with the fix above.

<!-- gh-comment-id:328295425 --> @solardiz commented on GitHub (Sep 9, 2017): This also fixes the issue for me: ``` diff --git a/src/common.h b/src/common.h index 9ea02ab..0e9c534 100644 --- a/src/common.h +++ b/src/common.h @@ -49,7 +49,7 @@ #ifdef __GNUC__ #if __GNUC__ >= 5 -#define MAYBE_INLINE __attribute__((gnu_inline)) inline +#define MAYBE_INLINE __attribute__((gnu_inline)) __attribute__((always_inline)) inline #elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || defined(__INTEL_COMPILER) || __NVCC__ #define MAYBE_INLINE __attribute__((always_inline)) inline #elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) ``` I think the two attributes are not mutually-exclusive (or are they?), and it was a bug to drop `__attribute__((always_inline))` in that fix for #1093. But we need to retest with early GCC 5 to ensure that issue isn't back with the fix above.
Author
Owner

@ghost commented on GitHub (Sep 9, 2017):

I would say: commit and watch bots working. We have gcc 4.8, 5.4, 6.3 and 7.2. Also, clang 3.9 and 4.0. It is not pure science, but you can also pay attention to the build time of all build jobs looking for any hints of trouble.

<!-- gh-comment-id:328299337 --> @ghost commented on GitHub (Sep 9, 2017): I would say: commit and watch bots working. We have gcc 4.8, 5.4, 6.3 and 7.2. Also, clang 3.9 and 4.0. It is not pure science, but you can also pay attention to **the build time** of all build jobs looking for any hints of trouble.
Author
Owner

@solardiz commented on GitHub (Sep 9, 2017):

I agree - let's commit. But this doesn't mean the problem won't resurface with early gcc 5. I've already tested my fix above with gcc 5.3.1, and there's no problem, but that version of gcc might already have a fix in it as well.

<!-- gh-comment-id:328299617 --> @solardiz commented on GitHub (Sep 9, 2017): I agree - let's commit. But this doesn't mean the problem won't resurface with _early_ gcc 5. I've already tested my fix above with gcc 5.3.1, and there's no problem, but that version of gcc might already have a fix in it as well.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#1764
No description provided.