[PATCH] mpi: Fix powerpc32 build

Dirk Eibach dirk.eibach at gdsys.cc
Wed May 9 09:30:48 CEST 2018

> I've noticed underscore build problem with powerpc when cross-compiling on
> x86-64 system. This can be avoided by giving 'ac_cv_sys_symbol_underscore=no'
> parameter to 'configure'. When building on native powerpc system this does
> not appear to be required.

I am cross-compiling on a x86-64 machine. Configuring with
'ac_cv_sys_symbol_underscore=no' results in a succesful build.

Nevertheless there is still a bug in mpi/powerpc32/syntax.h that has
not shown up yet, because no one needs a build with
'ac_cv_sys_symbol_underscore=yes' .

ac_cv_sys_symbol_underscore is evaluated in mpi/config.links:
# Make sysdep.h
echo '/* created by config.links - do not edit */' >./mpi/sysdep.h
if test x$ac_cv_sys_symbol_underscore = xyes; then
    cat <<EOF >>./mpi/sysdep.h
#if __STDC__
#define C_SYMBOL_NAME(name) _##name
#define C_SYMBOL_NAME(name) _/**/name
    cat <<EOF >>./mpi/sysdep.h
#define C_SYMBOL_NAME(name) name

In the 'yes'-case the C_SYMBOL_NAME()-macro adds some kind of prefix,
in the 'no'-case it doesn't.

The ENTRY() macro in mpi/powerpc32/syntax.h uses C_SYMBOL_NAME() to
adapt the symbol while the END()-macro does not.
This will work fine int the 'no'-case (because C_SYMBOL_NAME() does
nothing anyway) but will blow up in the yes case.

The proposed fix is:
diff --git a/mpi/powerpc32/syntax.h b/mpi/powerpc32/syntax.h
index 5d4af9f0..e6e27838 100644
--- a/mpi/powerpc32/syntax.h
+++ b/mpi/powerpc32/syntax.h
@@ -71,5 +71,5 @@

 #undef END
 #define END(name)                   \

You can simply give it a try. Configure with
'ac_cv_sys_symbol_underscore=yes' (even though you don't need it).
Without the patch applied, the build will fail on assembly:
libtool: compile:  powerpc-e300c3-linux-gnu-gcc -DHAVE_CONFIG_H -I.
-I.. -I../src -I../src -Wa,--noexecstack
-I/home/de/root/root-e300/include -MT mpih-add1-asm.lo -MD -MP -MF
.deps/mpih-add1-asm.Tpo -c mpih-add1-asm.S  -fPIC -DPIC -o
/tmp/ccfWCRAp.s: Assembler messages:
/tmp/ccfWCRAp.s: Error: .size expression for _gcry_mpih_add_n does not
evaluate to a constant

With the patch applied the build will fail much later, when linking:
libtool: link: powerpc-e300c3-linux-gnu-gcc
-I/home/de/root/root-e300/include -fvisibility=hidden -Wall -o
.libs/mpicalc mpicalc-mpicalc.o  -L/home/de/root/root-e300/lib
./.libs/libgcrypt.so /home/de/root/root-e300/lib/libgpg-error.so
-Wl,-rpath -Wl,/home/de/root/root-e300/lib
./.libs/libgcrypt.so: undefined reference to `_gcry_mpih_lshift'
./.libs/libgcrypt.so: undefined reference to `_gcry_mpih_add_n'
./.libs/libgcrypt.so: undefined reference to `_gcry_mpih_addmul_1'
./.libs/libgcrypt.so: undefined reference to `_gcry_mpih_submul_1'
./.libs/libgcrypt.so: undefined reference to `_gcry_mpih_mul_1'
./.libs/libgcrypt.so: undefined reference to `_gcry_mpih_sub_n'
./.libs/libgcrypt.so: undefined reference to `_gcry_mpih_rshift'

So this will work for a toolchain that actually needs
'ac_cv_sys_symbol_underscore=yes' while it will certainly not work
without the patch applied.

More information about the Gcrypt-devel mailing list