This patch fixes "multiple definition of `__mspabi_mpyi'" errors encountered with -mhwmult=f5series, by moving mpy.o out of libgcc and into libmul_none.a. The other libmul_*.a archives already provide a definition of _mspabi_mpyi.
mpy.c actually contains __mulhi3, but the msp430 backend renames that to _mspabi_mpyi. Built and tested (no regressions) as follows: Configured with: --target=msp430-elf --enable-languages=c Test variations: msp430-sim/-mcpu=msp430 msp430-sim/-mcpu=msp430x msp430-sim/-mcpu=msp430x/-mlarge/-mdata-region=either/-mcode-region=either msp430-sim/-mhwmult=none msp430-sim/-mhwmult=f5series I've also compared the output from msp430-elf-nm for lib/gcc/msp430-elf/7.0.0/lib*.a on before/after builds, confirming that moving _msp430abi_mpyi from libgcc to libmul_none.a is the only change. Test results actually show several progressions: # of expected passes +721 # of unexpected failures -396 # of unresolved testcases -26 If this patch is acceptable, I would appreciate it if someone would commit it on my behalf. Thanks, 2017-01-XX Joe Seymour <jo...@somniumtech.com> libgcc/ * config/msp430/t-msp430 (LIB2ADD): Remove mpy.c (mpy.o): New rule. (libmul_none.a): Add mpy.o gcc/testsuite/ * gcc.target/msp430/mul_f5_muldef.c: New test. --- gcc/testsuite/gcc.target/msp430/mul_f5_muldef.c | 15 +++++++++++++++ libgcc/config/msp430/t-msp430 | 6 ++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/msp430/mul_f5_muldef.c diff --git a/gcc/testsuite/gcc.target/msp430/mul_f5_muldef.c b/gcc/testsuite/gcc.target/msp430/mul_f5_muldef.c new file mode 100644 index 0000000..da1b1bb --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/mul_f5_muldef.c @@ -0,0 +1,15 @@ +/* { dg-do link } */ +/* { dg-options "-mhwmult=f5series" } */ + +/* This program used to result in a multiple definition error: + +libmul_f5.a(lib2hw_mul_f5.o): In function `__mulhi2_f5': +(.text.__mulhi2_f5+0x0): multiple definition of `__mspabi_mpyi' +libgcc.a(mpy.o):mpy.c:(.text.__mulhi3+0x0): first defined here */ + +#include <stdio.h> + +int main (void) +{ + printf ("%d", 430); +} diff --git a/libgcc/config/msp430/t-msp430 b/libgcc/config/msp430/t-msp430 index 107eb3d..668b943 100644 --- a/libgcc/config/msp430/t-msp430 +++ b/libgcc/config/msp430/t-msp430 @@ -30,7 +30,6 @@ LIB2ADD = \ $(srcdir)/config/msp430/lib2mul.c \ $(srcdir)/config/msp430/lib2shift.c \ $(srcdir)/config/msp430/epilogue.S \ - $(srcdir)/config/msp430/mpy.c \ $(srcdir)/config/msp430/slli.S \ $(srcdir)/config/msp430/srai.S \ $(srcdir)/config/msp430/srli.S \ @@ -43,6 +42,9 @@ LIB2ADD = \ HOST_LIBGCC2_CFLAGS += -Os -ffunction-sections -fdata-sections -mhwmult=none +mpy.o: $(srcdir)/config/msp430/mpy.c + $(gcc_compile) $< -c + lib2_mul_none.o: $(srcdir)/config/msp430/lib2mul.c $(gcc_compile) $< -c -DMUL_NONE @@ -58,7 +60,7 @@ lib2hw_mul_32.o: $(srcdir)/config/msp430/lib2hw_mul.S lib2hw_mul_f5.o: $(srcdir)/config/msp430/lib2hw_mul.S $(gcc_compile) $< -c -DMUL_F5 -libmul_none.a: lib2_mul_none.o +libmul_none.a: lib2_mul_none.o mpy.o $(AR_CREATE_FOR_TARGET) $@ $(filter %.o,$^) libmul_16.a: lib2hw_mul_16.o lib2_mul_16bit.o -- 1.7.1