Package: binutils-msp430
Version: 2.40.50~ti1
Severity: normal
Tags: patch
User: [email protected]
Usertags: origin-ubuntu mantic ubuntu-patch

Dear Maintainer,

In Ubuntu we found binutils-msp430 failing to build when -O3 optimization level 
is used,
Debian defaults to -O2, but people building manually might trigger this bug if 
they choose
a different optimization for that architecture.

The fix would be to fix binutils to not error out on ppc64el,
https://launchpad.net/ubuntu/+source/binutils-msp430/2.40.50~ti1/+build/26385650/+files/buildlog_ubuntu-mantic-ppc64el.binutils-msp430_2.40.50~ti1_BUILDING.txt.gz

But also forcing -O2 on ppc64el should work.

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -DBINDIR=\"/usr/bin\" -DLIBDIR=\"/usr/lib/msp430\" -I. -I. -I./../include 
-DHAVE_msp430_elf32_vec -DHAVE_msp430_elf32_ti_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec -Wdate-time -D_FORTIFY_SOURCE=2 -W -Wall 
-Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -fPIC -g -O3 
"-ffile-prefix-map=/<<PKGBUILDDIR>>=." -fstack-protector-strong -Wformat -Werror=format-security 
"-fdebug-prefix-map=/<<PKGBUILDDIR>>=/usr/src/binutils-msp430-2.40.50~ti1" -D_FORTIFY_SOURCE=2 -c format.c -fPIE -o 
format.o
archive.c: In function ‘_bfd_archive_bsd_update_armap_timestamp’:
archive.c:2654:60: error: ‘__builtin___snprintf_chk’ output may be truncated 
before the last format character [-Werror=format-truncation=]
 2654 |   _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
      |                                                            ^
In file included from /usr/include/stdio.h:906,
                 from sysdep.h:30,
                 from archive.c:134:
In function ‘snprintf’,
    inlined from ‘_bfd_ar_spacepad’ at archive.c:209:3,
    inlined from ‘_bfd_archive_bsd_update_armap_timestamp’ at archive.c:2654:3:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:54:10: note: 
‘__builtin___snprintf_chk’ output between 2 and 21 bytes into a destination of 
size 20
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
/bin/bash ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.  -DBINDIR='"/usr/bin"' 
-DLIBDIR='"/usr/lib/msp430"' -I. -I. -I./../include  -DHAVE_msp430_elf32_vec -DHAVE_msp430_elf32_ti_vec 
-DHAVE_elf32_le_vec -DHAVE_elf32_be_vec  -Wdate-time -D_FORTIFY_SOURCE=2 -W -Wall -Wstrict-prototypes -Wmissing-prototypes 
-Wshadow -Wstack-usage=262144 -Werror   -fPIC -g -O3 -ffile-prefix-map=/<<PKGBUILDDIR>>=. 
-fstack-protector-strong -Wformat -Werror=format-security 
-fdebug-prefix-map=/<<PKGBUILDDIR>>=/usr/src/binutils-msp430-2.40.50~ti1 -fPIE -D_FORTIFY_SOURCE=2     -c -o 
hash.lo hash.c


Thanks for considering the patch.

*** /tmp/tmpgaq1rqtl/binutils-msp430_2.40.50~ti1ubuntu1.debdiff
diff -Nru binutils-msp430-2.40.50~ti1/debian/rules 
binutils-msp430-2.40.50~ti1ubuntu1/debian/rules
--- binutils-msp430-2.40.50~ti1/debian/rules    2023-06-28 23:45:44.000000000 
+0200
+++ binutils-msp430-2.40.50~ti1ubuntu1/debian/rules     2023-07-04 
00:58:51.000000000 +0200
@@ -11,6 +11,14 @@
 TARGET = msp430
 BINUTILS_VER := $(shell dpkg-query -W -f="\$${Version}\n" binutils-source)
+
+DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
+
+ifeq ($(DEB_HOST_ARCH),ppc64el)
+export DEB_CFLAGS_MAINT_STRIP = -O3
+export DEB_CFLAGS_MAINT_APPEND = -O2
+endif
+
 BUILD_TREE = $(shell find . -maxdepth 1 -mindepth 1 -type d -name 'binutils*')
 DEB_BINUTILS = .

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to