#1069862 blktrace: FTBFS on ppc64el in Ubuntu (-O3?) due to wrong code analysis

Package:
blktrace
Source:
blktrace
Description:
utilities for block layer IO tracing
Submitter:
Steve Langasek
Date:
2024-09-25 13:42:01 UTC
Severity:
normal
Tags:
#1069862#5
Date:
2024-04-25 21:23:08 UTC
From:
To:
Package: blktrace
Version: 1.2.0-5
Severity: minor
Tags: patch
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu  ubuntu-patch

Dear maintainers,

In Ubuntu, we found that blktrace was failing to rebuild on ppc64el because
the compiler was wrongly identifying problems with format string handling:

[...]
gcc -o blkparse.o -c -D__DEB_CANARY_CPPFLAGS_4e732ced3463d06de0ca9a15b6153677__ -Wdate-time -D_FORTIFY_SOURCE=3 -g -O3 -Werror=implicit-function-declaration -Werror=array-bounds -Werror=clobbered -Werror=volatile-register-var -D__DEB_CANARY_CFLAGS_4e732ced3463d06de0ca9a15b6153677__ -fno-omit-frame-pointer -ffile-prefix-map=/<<PKGBUILDDIR>>=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fno-stack-clash-protection -fdebug-prefix-map=/<<PKGBUILDDIR>>=/usr/src/blktrace-1.2.0-5build1 -Wall -Wextra -Wno-shadow -Werror -g -Wl,-Bsymbolic-functions -Wl,-z,deb-canary-4e732ced3463d06de0ca9a15b6153677 -flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 blkparse.c
blkparse.c: In function ‘main’:
blkparse.c:376:56: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  376 |                 fprintf(stderr, "Out of memory, device %s (%d)\n", name, size);
      |                                                        ^~
[...]
blkparse.c:1885:68: error: ‘):’ directive output may be truncated writing 2 bytes into a region of size between 1 and 41 [-Werror=format-truncation=]
[...]

  (https://launchpad.net/ubuntu/+source/blktrace/1.2.0-5build1/+build/27931723)

It's possible/likely that this build failure is caused by the use of -O3 by
default for ppc64el builds in Ubuntu; so the attached patch, while it fixes
the problem in Ubuntu and should be harmless in Debian, may not be something
you want to apply as-is.  Perhaps you would prefer to use $(filter -O3,...)
instead?

Thanks for considering,

#1069862#10
Date:
2024-09-23 04:31:51 UTC
From:
To:
Hello Steve,
by
fixes
something
-O3,...)

Thank you for reporting this issue.

Your idea of using $(filter -O3,...) looks good to me, but I would like to
clarify one thing.

When I tried to reproduce the issue on ppc64el with Debian unstable as of
September 22, 2024, I was unable to do so.
According to the build log[0] on ppc64el, it appears that the -O2 option is
used for the build rather than -O3.

For further investigation, if the following change is applied to d/rules,
the issue is reproduced on ppc64el with Debian unstable, but that is not
what we want to do.

```
--- ../blktrace/debian/rules    2024-08-18 06:21:55.984000000 +0000
+++ debian/rules        2024-09-22 06:48:37.696000000 +0000
@@ -5,7 +5,7 @@
 include /usr/share/dpkg/architecture.mk
 include /usr/share/dpkg/pkg-info.mk

#1069862#15
Date:
2024-09-23 17:05:47 UTC
From:
To:
#1069862#20
Date:
2024-09-25 13:39:15 UTC
From:
To:
Thank you for your response.

After reviewing the source code of dpkg, I now understand that the -O3
optimisation level is set by default for ppc64el in Ubuntu.
However, it appears that there is no code to change the optimisation level
based on CPU architecture in Debian.
Therefore, I believe this issue is specific to Ubuntu.

If there are no objections, we can close this issue.
I am happy to continue this discussion if you’d like.

Best regards,
Fukui