Skip to content

Apply temporary fix for gcc 15. - #874

Merged
devinamatthews merged 2 commits into
masterfrom
temp-fix-gcc15
Jun 24, 2025
Merged

devinamatthews merged 2 commits into
masterfrom
temp-fix-gcc15

Conversation

@devinamatthews

Copy link
Copy Markdown
Member

Details:

  • As reported in Haswell kernels fail with GCC 15 #845, gcc 15 fails to build the haswell gemmsup kernels due to the use of rbp.
  • As a temporary fix, disable slp-tree-vectorization in just the affected files.
  • Thanks @loveshack for reporting and @chillenb for the suggested fix.
  • Eventually, the kernels should be rewritten to avoid using rbp.

Details:
- As reported in #845, gcc 15 fails to build the haswell
  gemmsup kernels due to the use of rbp.
- As a temporary fix, disable slp-tree-vectorization in just
  the affected files.
- Thanks @loveshack for reporting and @chillenb for the suggested
  fix.
- Eventually, the kernels should be rewritten to avoid using rbp.
@devinamatthews
devinamatthews merged commit 36effd7 into master Jun 24, 2025
@devinamatthews
devinamatthews deleted the temp-fix-gcc15 branch June 24, 2025 20:38
devinamatthews added a commit that referenced this pull request Jun 24, 2025
Details:
- As reported in #845, gcc 15 fails to build the haswell
  gemmsup kernels due to the use of rbp.
- As a temporary fix, disable slp-tree-vectorization in just
  the affected files.
- Thanks @loveshack for reporting and @chillenb for the suggested
  fix.
- Eventually, the kernels should be rewritten to avoid using rbp.

(cherry picked from commit 36effd7)
devinamatthews added a commit that referenced this pull request Jun 24, 2025
Details:
- As reported in #845, gcc 15 fails to build the haswell
  gemmsup kernels due to the use of rbp.
- As a temporary fix, disable slp-tree-vectorization in just
  the affected files.
- Thanks @loveshack for reporting and @chillenb for the suggested
  fix.
- Eventually, the kernels should be rewritten to avoid using rbp.

(cherry picked from commit 36effd7)
@hominhquan

hominhquan commented Jun 24, 2025 •

Copy link
Copy Markdown
Contributor

Hah, the prb has been workaround-ed by adding -fomit-frame-pointer into CKOPTFLAGS of config/haswell/make_defs.mk, but we fell into a bad order of flag concatenation in common.mk.

With this diff the build is success:

diff --git a/common.mk b/common.mk
index 0b01fa7d..f5941c0a 100644
--- a/common.mk
+++ b/common.mk
@@ -195,9 +195,9 @@ get-frame-cxxflags-for   = $(strip $(call load-var-for,COPTFLAGS,$(1)) \
                                    $(BUILD_SYMFLAGS) \
                             )

-get-kernel-cflags-for    = $(strip $(call load-var-for,CKOPTFLAGS,$(1)) \
+get-kernel-cflags-for    = $(strip $(call get-noopt-cflags-for,$(1)) \
+                                   $(call load-var-for,CKOPTFLAGS,$(1)) \
                                    $(call load-var-for,CKVECFLAGS,$(1)) \
-                                   $(call get-noopt-cflags-for,$(1)) \
                                    -DBLIS_CNAME=$(1) \
                                    -DBLIS_CNAME_UPPER=$(shell echo $(1) | tr a-z A-Z) \
                                    $(BUILD_CPPFLAGS) \

I consider this a bug, since compilers always take the last occurrence of the flag, hence flags order should start from the most naive (noopt) to the most advanced ones. Also, the noopt currently contains the user-given CFLAGS in ./configure CFLAGS="... -fno-omit-frame-pointer". The diff above should be applied to all others places in common.mk as well.

It's my sleep time. I can do it tomorrow if you've not done it before.

@devinamatthews

Copy link
Copy Markdown
Member Author

I await your PR, thanks for looking into it.

@leekillough

Copy link
Copy Markdown
Collaborator

Note that -fomit-frame-pointer is on by default at -O1 and higher.

At -O0 the compiler uses rbp for the frame pointer by default, and forbids it from being used in inline assembly, hence the build error you got.

You can explicitly add -fomit-frame-pointer so that applies to -O0 as well.

If the code uses rbp in inline assembly, it should list rbp in the list of clobbered registers (after the output and input lists):

asm volatile("xor rbp, rbp" : : : "rbp");

// This avoids a known issue with GCC15 ("error: bp cannot be used in asm here", #845).
// Only check for version 15 since this may be fixed in 16 (**fingers crossed**), and also
// make sure the compiler isn't clang since it also confusingly defines __GNUC__
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ == 15

@thesamesam thesamesam Aug 26, 2025 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a bit optimistic. It broke here because GCC got better at vectorising and it's unlikely to change here. A friend explained that LLVM handles spills (for the vector variables to the stack, which then needs a GPR for stack realignment) with asms that clobber all GPRs but GCC doesn't. While it may be implemented at some point, it's complex and I wouldn't bet it on it being fixed in 16 or anything like that.

I'd also suggest disabling all vectorisation here, not just SLP, i.e. always do it (not just for == 15, or at least do >= 15), and do -fno-tree-vectorize instead.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, this is broken again with gcc-16.

negril added a commit to negril/gentoo that referenced this pull request Sep 11, 2025
use edo
use if where possible
quote variables
refactor get_confname to set confname once
work around flame/blis#874 for gcc-16
handle USE=serial
use myeconfargs

Signed-off-by: Paul Zander <[email protected]>
negril added a commit to negril/gentoo that referenced this pull request Sep 11, 2025
use edo
use if where possible
quote variables
refactor get_confname to set confname once
work around flame/blis#874 for gcc-16
handle USE=serial
use myeconfargs

fix metadata typo

Signed-off-by: Paul Zander <[email protected]>
@devinamatthews

Copy link
Copy Markdown
Member Author

I think I'll just change it to >=.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants