r-base: gfortran and gcc disagree on double complex

Bug #1950283 reported by Graham Inggs
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
r-base (Ubuntu)
Fix Released
Undecided
Unassigned
r-cran-expm (Ubuntu)
Invalid
Undecided
Unassigned
r-cran-irlba (Ubuntu)
Invalid
Undecided
Unassigned
r-cran-openmx (Ubuntu)
Invalid
Undecided
Unassigned
r-cran-pracma (Ubuntu)
Invalid
Undecided
Unassigned
r-cran-rsvd (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

autopkgtests of several R packages are failing with the error:

Fortran complex functions are not available on this platform

This message comes from r-base itself, and is shown when r-base is built without HAVE_FORTRAN_DOUBLE_COMPLEX

In recent build logs of r-base in Ubuntu, the following configure output can be seen on all architectures, except armhf and riscv64:

checking whether mixed C/Fortran code can be run... yes
checking whether gfortran and gcc -std=gnu99 -std=gnu11 agree on int and double... yes
checking whether gfortran and gcc -std=gnu99 -std=gnu11 agree on double complex...
 configure: WARNING: gfortran and gcc -std=gnu99 -std=gnu11 disagree on double complex

Recent build logs in Debian, including reproducible builds [1], show:

checking whether mixed C/Fortran code can be run... yes
checking whether gfortran and gcc -std=gnu99 -std=gnu11 agree on int and double... yes
checking whether gfortran and gcc -std=gnu99 -std=gnu11 agree on double complex... yes

[1] https://tests.reproducible-builds.org/debian/rb-pkg/r-base.html

Graham Inggs (ginggs)
tags: added: update-excuse
Revision history for this message
Dimitri John Ledkov (xnox) wrote :
Changed in r-base (Ubuntu):
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package r-base - 4.1.2-1ubuntu1

---------------
r-base (4.1.2-1ubuntu1) jammy; urgency=medium

  * Drop adding -std=gnu99, as R needs at least C11 compiler by default
    and adds -std=gnu11 which then lowers the standard than what gcc
    default is.
  * Turn off LTO as it missbuilds R with HAVE_FORTRAN_DOUBLE_COMPLEX not
    defined. LP: #1950283

 -- Dimitri John Ledkov <email address hidden> Tue, 09 Nov 2021 12:11:18 +0000

Changed in r-base (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Graham Inggs (ginggs) wrote :

While disabling LTO completely avoids the problem, per doc/NEWS it seems upstream does support LTO.

I found that enabling LTO again, and only disabling it for double complex test (as per attached patch) allows r-base to build with LTO and the autopkgtests of the affected packages still pass.

Revision history for this message
Graham Inggs (ginggs) wrote :

After isolating the double complex test (attached), I found that it only failed with the combination of -O2 and LTO. With -O1 or -O3 and LTO it was fine.

Revision history for this message
Graham Inggs (ginggs) wrote (last edit ):

A recent test build in a PPA of r-base/4.2.1-2 and the current toolchain (GCC 12, etc.) shows:

checking whether mixed C/Fortran code can be run... yes
checking whether gfortran and gcc agree on int and double... yes
checking whether gfortran and gcc agree on double complex... yes

So this appears to be solved (at least for amd64)

Revision history for this message
Graham Inggs (ginggs) wrote :

ppc64el log still shows:

checking whether mixed C/Fortran code can be run... yes
checking whether gfortran and gcc agree on int and double... yes
checking whether gfortran and gcc agree on double complex... configure: WARNING: gfortran and gcc disagree on double complex

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in r-cran-expm (Ubuntu):
status: New → Confirmed
Changed in r-cran-irlba (Ubuntu):
status: New → Confirmed
Changed in r-cran-openmx (Ubuntu):
status: New → Confirmed
Changed in r-cran-pracma (Ubuntu):
status: New → Confirmed
Changed in r-cran-rsvd (Ubuntu):
status: New → Confirmed
Revision history for this message
Graham Inggs (ginggs) wrote :

How to check if R has been built without Fortran complex functions:

$ sudo apt install --no-install-recommends r-base

$ R -e "eigen(print(cbind(c(0, 1i), c(-1i, 0))))"

Expected output:

> eigen(print(cbind(c(0, 1i), c(-1i, 0))))
     [,1] [,2]
[1,] 0+0i 0-1i
[2,] 0+1i 0+0i
eigen() decomposition
$values
[1] 1 -1

$vectors
                      [,1] [,2]
[1,] -0.7071068+0.0000000i -0.7071068+0.0000000i
[2,] 0.0000000-0.7071068i 0.0000000+0.7071068i

Output without Fortran complex functions:

> eigen(print(cbind(c(0, 1i), c(-1i, 0))))
     [,1] [,2]
[1,] 0+0i 0-1i
[2,] 0+1i 0+0i
Error in eigen(print(cbind(c(0, 0+1i), c(-(0+1i), 0)))) :
  Fortran complex functions are not available on this platform
Execution halted

Optionally, follow the instructions to download upstream's R packages from CRAN:
https://cloud.r-project.org/bin/linux/ubuntu/

Graham Inggs (ginggs)
Changed in r-cran-expm (Ubuntu):
status: Confirmed → Invalid
Changed in r-cran-irlba (Ubuntu):
status: Confirmed → Invalid
Changed in r-cran-openmx (Ubuntu):
status: Confirmed → Invalid
Changed in r-cran-pracma (Ubuntu):
status: Confirmed → Invalid
Changed in r-cran-rsvd (Ubuntu):
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.