Bug#1049903: petsc: misbuild with gcc-13

2023-09-28 Thread Drew Parsons
Source: petsc
Followup-For: Bug #1049903
Control: severity 1049903 important
Control: tags 1049903 moreinfo

I said previously I'd apply the patch, but I wanted to check the
problem first.  No problem is showing at
https://tests.reproducible-builds.org/debian/rb-pkg/petsc.html
even in the experimental rebuilds.

I tried rebuilding in an experimental chroot on barriere.debian.org
porterbox (amd64), using libc6-dev 2.38-3 with 13.2.0-4.
No problem there either, even with libc6 version 28.

It sounds like some problem might have entered into ubuntu mantic.
I think it would be better to track down that problem rather than
papering over it and ignoring it.

Downgrading severity since the error is not reliably reproducible.

Is Ubuntu still affected by the problem?



Bug#1049903: petsc: misbuild with gcc-13

2023-09-11 Thread Drew Parsons
Source: petsc
Followup-For: Bug #1049903

Thanks for the clarification.  I'll apply the patch.



Bug#1049903: petsc: misbuild with gcc-13

2023-08-30 Thread Drew Parsons
Source: petsc
Followup-For: Bug #1049903

Hi Steve, thanks for the bug report.

With patching, wouldn't it be simpler to just add -lstdc++ to
CXX_LINKER_FLAGS at configuration time (in debian/rules) rather than
hacking the upstream detection code?  As you say, hardcoding in the
upstream scripts doesn't really resolve the underlying problem.

Is there a reason why hacking CXX_LINKER_FLAGS in debian/rules doesn't
fix the build?

Drew



Bug#1049903: petsc: misbuild with gcc-13

2023-08-16 Thread Steve Langasek
Package: petsc
Version: 3.18.6+dfsg1-1
Severity: serious
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu mantic ubuntu-patch

Dear maintainers,

A no-change rebuild of petsc in Ubuntu for a libamd transition resulted in a
libpetsc64_complex that was missing linkage against libstdc++ and was
therefore unusable (identified via failing autopkgtests).

The root cause is:

 - petsc can use either a C compiler (mpicc, wrapping gcc) or a C++ compiler
   (mpicxx, wrapping g++) to build these libraries.  It defaults to C.
 - libpetsc64_complex, unlike the other variants, includes C++ code
 - petsc's build system includes code to detect what additional arguments,
   if any, need to be passed to the C compiler to link in the standard C++
   runtime library (-lstdc++)
 - the test case petsc uses to detect whether additional libraries are
   required SOMEHOW, only with gcc-13, gets all of its C++ dependencies
   emitted as weak symbols by the compiler with no requirement to link
   against libstdc++
 - as a result, petsc incorrectly links libpetsc64_complex without libstdc++,
   giving an unusable library with unresolvable symbols.

Now, there were binNMUs of petsc in Debian 8 days ago, and I checked and the
libpetsc64-complex from that build on amd64 did use gcc-13 as the compiler
and did NOT miss the linkage to libstdc++.  I do not have an explanation for
this; it's possible it's related to the fact that Ubuntu is ahead of Debian
on glibc versions.  Nevertheless, since there are no other toolchain
differences between Debian and Ubuntu other than this (and certainly no
delta related to MPI), I expect this is a foot-gun that will at some point
affect Debian as well.

And because Debian does not trigger autopkgtests for binNMUs and does not
gate testing promotion of binNMUs on successful autopkgtest results, this
would not be caught automatically in Debian the way it was in Ubuntu;
therefore I am filing this bug at serious severity.

The attached patch does two things:

  * debian/patches/gcc-13.patch: fix misdetection of required C++
library with gcc-13.
  * debian/rules: pass -Wl,-z,defs to the linker to guard against future
misbuilds.

The patch to the upstream build system is inelegant and simply hard-codes
libstdc++.  I couldn't find a cleaner way to pass this information to the
build system as a configure option, and modifying the test case to fail
without libstdc++ was also non-trivial.  I'm sure upstream will eventually
want a different fix.

And btw, the build log does show tests that have regressed because the
library is broken, but these failing tests did not block the package
build...

I've uploaded this delta to Ubuntu to unbreak petsc there.

Thanks for considering the patch.
-- 
Steve Langasek   Give me a lever long enough and a Free OS
Debian Developer   to set it on, and I can move the world.
Ubuntu Developer   https://www.debian.org/
slanga...@ubuntu.com vor...@debian.org
diff -Nru petsc-3.18.6+dfsg1/debian/control petsc-3.18.6+dfsg1/debian/control
--- petsc-3.18.6+dfsg1/debian/control   2023-07-30 13:56:16.0 -0700
+++ petsc-3.18.6+dfsg1/debian/control   2023-08-16 08:42:11.0 -0700
@@ -1,8 +1,7 @@
 Source: petsc
 Section: devel
 Priority: optional
-Maintainer: Ubuntu Developers 
-XSBC-Original-Maintainer: Debian Science Maintainers 

+Maintainer: Debian Science Maintainers 

 Uploaders: "Adam C. Powell, IV" , Drew Parsons 

 Standards-Version: 4.6.2
 Build-Depends: debhelper-compat (= 13), python3, gfortran,
diff -Nru petsc-3.18.6+dfsg1/debian/patches/gcc-13.patch 
petsc-3.18.6+dfsg1/debian/patches/gcc-13.patch
--- petsc-3.18.6+dfsg1/debian/patches/gcc-13.patch  1969-12-31 
16:00:00.0 -0800
+++ petsc-3.18.6+dfsg1/debian/patches/gcc-13.patch  2023-08-15 
23:12:13.0 -0700
@@ -0,0 +1,27 @@
+Description: fix misdetection of required C++ library with gcc-13
+ petsc tries to autodetect what libraries need to be passed to the C
+ compiler in order to correctly link C++ code.  Unfortunately, the test
+ case somehow manages to build just fine without an explicit -lstdc++
+ argument under gcc-13, causing missing linkage.  Hard code the library
+ option instead.
+Author: Steve Langasek 
+Forwarded: no
+Last-Update: 2023-08-15
+
+Index: petsc-3.18.6+dfsg1/config/BuildSystem/config/compilers.py
+===
+--- petsc-3.18.6+dfsg1.orig/config/BuildSystem/config/compilers.py
 petsc-3.18.6+dfsg1/config/BuildSystem/config/compilers.py
+@@ -446,6 +446,12 @@
+ '''Determines the libraries needed to link with C++ from C and Fortran'''
+ skipcxxlibraries = 1
+ self.setCompilers.saveLog()
++oldLibs = self.setCompilers.LIBS
++self.setCompilers.LIBS = '-lstdc++ '+self.setCompilers.LIBS
++self.logWrite(self.setCompilers.restoreLog())
++self.logPrint('C++ requires