Sourceware Bugzilla – Bug 10118
GLIBC fails to build on POWER6 after binutils change
Last modified: 2009-05-09 15:59:58 UTC
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.