Recently, a change in binutils introduced a build failure on Power systems.
Jakub Jelinek fixed the problem for POWER5+ and below with this patch
but the problem remains for POWER6, since ARCH_PWR6 doesn't define '.machine
"power6"', so the same has to be done in the #ifdef ARCH_PWR6 part of those asm
I'm attaching a patch that fixes this on POWER6 systems.
Created attachment 3920 [details]
Patch for fixing the use of 4-operand mtfsf instruction in *context functions on POWER6
The patch really is bogus:
# ifdef _ARCH_PWR6
+ .machine push
+ .machine "power6"
/* Use the extended four-operand version of the mtfsf insn. */
+ .machine pop
The if and else branch both start with the same pseudo ops.
The reason why Jakub probably didn't add it outside the #if is because if
_ARCH_PWR6 is defined the assembler should be in power6 mode.
Investigate why this isn't the case.
I found that the GLIBC target rules for .S files don't include $(CFLAGS) and the
submachine target from --with-cpu=CPU isn't propagated to $(ASFLAGS).
compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags)
compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \
$(ASFLAGS) $(ASFLAGS-$(suffix $@))
The --with-cpu=CPU switch only propagates to $CFLAGS via configure's
`@libc_cv_cc_submachine@' to config.make.in's $(cflags-cpu) to Makeconfig's
$(+cflags) to OVERRIDE CFLAGS.
When compiling a .S file with GCC the switch -mcpu=CPU should be used as well
such that the assembler can be invoked against the CPU insn set (implicit
equivalent to .machine "CPU"). The same thing can be accomplished by passing
-Wa,-mCPU but -mcpu=CPU is less error prone. In the case of this bug, this fix
should result in _ARCH_PWR6 1 being emitted and the assembler in power6 insn
I'll post a patch shortly.
Created attachment 3927 [details]
asflags.diff : patch to propagate -mcpu=CPU to the compiler for --with-cpu=CPU when compiling .S files.
When GLIBC is configured using --with-cpu=CPU this patch set will cause -mcpu=
CPU to be emitted to the compiler when compiling .S files. Currently -mcpu-CPU
is only emitted for .c files.
I chose -mcpu=CPU vs. -Wa,-mCPU because -mcpu=CPU causes TARGET_CMPB to be set
in the compiler and it will then emit an _ARCH_CPU definition as well as set
the assembler in CPU insn mode. -Wa,-mCPU will only set the assembler into CPU
I've tested this for a --with-cpu=power6 build and it fixes the problem.
The reason we didn't catch this until recently is because the assembler was
recently changed to only recognize power6 instructions when in power6 mode.
Comments on the patch?
Can someone test this on x86[_64]?
I'd like to pass it through a few more runs on Power as well.
Btw, we still need the .machine push; .machine "power6"; ... ; .machine pop from
Jakub in the non-Power6 leg of the .S files since in those cases _ARCH_PWR6
isn't defined and the assembler is in power6 insn mode.
Ah, that explains why power6 glibc builds just fine for me.
I have -mcpu=power6 setting in CC and CXX env vars at configure time.
Jakub, in the case where you pass -mcpu=power6 in CC and configuring using
--with-cpu=power6 are you getting -mcpu=power6 twice for the GCC invocations?
Does this patch look complete to you?
I applied the patch.
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via db8fed87d9741b6b3da6c2257f01d63ef2fe407c (commit)
from 0cd2828695cc328aa1b48379436d15c39d433076 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
Author: Martin Sebor <firstname.lastname@example.org>
Date: Mon Jun 1 14:12:09 2015 -0300
powerpc: setcontext.S uses power6 mtfsf when not supported [BZ #18116]
The attached patch fixes a glibc build failure with gcc 5 on powerpc64le
caused by a recent change in gcc where the compiler defines the
_ARCH_PWR6 macro when processing assembly files but doesn't invoke the
assembler in the corresponding machine mode (unless it has been
explicitly configured to target POWER 6 or later). A bug had been filed
with gcc for this (65341) but was closed as won't fix. Glibc relies on
the _ARCH_PWR6 macro in a few .S files to make use of Power ISA 2.5
instructions (specifically, the four-argument form of the mtfsf insn).
A similar problem had occurred in the past (bug 10118) but the fix that
was committed for it didn't anticipate this new problem.
Summary of changes:
ChangeLog | 9 +++++
.../unix/sysv/linux/powerpc/powerpc64/setcontext.S | 30 +++++++++++++---
.../sysv/linux/powerpc/powerpc64/swapcontext.S | 36 +++++++++++++++----
3 files changed, 61 insertions(+), 14 deletions(-)