Skip to content

libopenblas unusable when built with binutils 2.38 on Ubuntu 18.04 and 20.04 #3708

@carlocab

Description

@carlocab

Running a small test program (see below) that is linked to libopenblas results in the following error:

./test: error while loading shared libraries: libopenblas.so.0: ELF load command address/offset not properly aligned

This does not occur with binutils 2.37 or on Ubuntu 22.04.

This exercise was done with OpenBLAS v0.3.20. I haven't yet had the opportunity to try other versions.

The test program is

/* test.c */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "cblas.h"
                                                       
int main(void) {
  int i;
  double A[6] = {1.0, 2.0, 1.0, -3.0, 4.0, -1.0};
  double B[6] = {1.0, 2.0, 1.0, -3.0, 4.0, -1.0};
  double C[9] = {.5, .5, .5, .5, .5, .5, .5, .5, .5};
  cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,
              3, 3, 2, 1, A, 3, B, 3, 2, C, 3);
  for (i = 0; i < 9; i++)
    printf("%lf ", C[i]);
  printf("\\n");
  if (fabs(C[0]-11) > 1.e-5) abort();
  if (fabs(C[4]-21) > 1.e-5) abort();
  return 0;
}

Compiled and executed with

gcc-12 test.c \
  -I/home/linuxbrew/.linuxbrew/opt/openblas/include \
  -L/home/linuxbrew/.linuxbrew/opt/openblas/lib \
  -lopenblas \
  -o test

./test

The GCC version does not seem important, since I see this bug with GCC 7+. (GCC 6 fails to build.)

This was discovered with a Homebrew-built OpenBLAS, but I can reproduce it by compiling OpenBLAS v0.3.20 without using Homebrew.

This may well be a bug in binutils. However, we've compiled a lot of software with binutils 2.38 at Homebrew, and only OpenBLAS seems to produce this problem.

More details at Homebrew/homebrew-core#106978.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug in other softwareCompiler, Virtual Machine, etc. bug affecting OpenBLAS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions