Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails with -flto #50

Open
nalimilan opened this issue Aug 21, 2021 · 1 comment
Open

Build fails with -flto #50

nalimilan opened this issue Aug 21, 2021 · 1 comment

Comments

@nalimilan
Copy link
Contributor

The build fails when the -flto build flag is passed. This is annoying to build RPM packages as that flag is included in default Fedora flags.

$ make CFLAGS="-O2 -flto -fPIC -DLIBRARY_EXPORTS -DF2C_AUTODETECTION" LDFLAGS="-shared"
cc -o build/libblastrampoline.o -O2 -flto -fPIC -DLIBRARY_EXPORTS -DF2C_AUTODETECTION -c libblastrampoline.c
cc -o build/dl_utils.o -O2 -flto -fPIC -DLIBRARY_EXPORTS -DF2C_AUTODETECTION -c dl_utils.c
cc -o build/config.o -O2 -flto -fPIC -DLIBRARY_EXPORTS -DF2C_AUTODETECTION -c config.c
cc -o build/autodetection.o -O2 -flto -fPIC -DLIBRARY_EXPORTS -DF2C_AUTODETECTION -c autodetection.c
cc -o build/threading.o -O2 -flto -fPIC -DLIBRARY_EXPORTS -DF2C_AUTODETECTION -c threading.c
cc -o build/deepbindless_surrogates.o -O2 -flto -fPIC -DLIBRARY_EXPORTS -DF2C_AUTODETECTION -c deepbindless_surrogates.c
cc -o build/trampolines/trampolines_x86_64.o -O2 -flto -fPIC -DLIBRARY_EXPORTS -DF2C_AUTODETECTION -c trampolines/trampolines_x86_64.S
cc -o build/f2c_adapters.o -O2 -flto -fPIC -DLIBRARY_EXPORTS -DF2C_AUTODETECTION -c f2c_adapters.c
cc -o build/libblastrampoline.so -O2 -flto -fPIC -DLIBRARY_EXPORTS -DF2C_AUTODETECTION build/libblastrampoline.o build/dl_utils.o build/config.o build/autodetection.o build/threading.o build/deepbindless_surrogates.o build/trampolines/trampolines_x86_64.o build/f2c_adapters.o -shared
libblastrampoline_f2cdata.h:31:1: error: function 'f2c_zdotc_' redeclared as variable
   31 | COMPLEX128_FUNCS(XX)
      | ^
f2c_adapters.c:198:27: note: previously declared here
  198 | LBT_HIDDEN double complex f2c_zdotc_(const int32_t *n, const double complex *x, const int32_t * ix, const double complex *y, const int32_t *iy) {
      |                           ^
libblastrampoline_f2cdata.h:31:1: error: function 'f2c_zdotu_' redeclared as variable
   31 | COMPLEX128_FUNCS(XX)
      | ^
f2c_adapters.c:212:16: note: previously declared here
  212 | double complex f2c_zdotu_(const int32_t* n, const double complex* x, const int32_t* ix, const double complex *y, const int32_t *iy)
      |                ^
libblastrampoline_f2cdata.h:29:1: error: function 'f2c_cdotc_' redeclared as variable
   29 | COMPLEX64_FUNCS(XX)
      | ^
f2c_adapters.c:168:26: note: previously declared here
  168 | LBT_HIDDEN float complex f2c_cdotc_(const int32_t *n, const float complex *x, const int32_t * ix, const float complex *y, const int32_t *iy) {
      |                          ^
libblastrampoline_f2cdata.h:29:1: error: function 'f2c_cdotu_' redeclared as variable
   29 | COMPLEX64_FUNCS(XX)
      | ^
f2c_adapters.c:182:15: note: previously declared here
  182 | float complex f2c_cdotu_(const int32_t* n, const float complex* x, const int32_t* ix, const float complex *y, const int32_t *iy)
      |               ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_slamc3_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:157:18: note: previously declared here
  157 | LBT_HIDDEN float f2c_slamc3_(const float * x, const float * y) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_slamch_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:147:18: note: previously declared here
  147 | LBT_HIDDEN float f2c_slamch_(const char * input) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_scnrm2_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:137:18: note: previously declared here
  137 | LBT_HIDDEN float f2c_scnrm2_(const int32_t* n, const float complex* x, const int32_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_snrm2_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:127:18: note: previously declared here
  127 | LBT_HIDDEN float f2c_snrm2_(const int32_t* n, const float* x, const int32_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_smin_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:17:18: note: previously declared here
   17 | LBT_HIDDEN float f2c_smin_(const int32_t* n, const float* x, const int32_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_smax_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:7:18: note: previously declared here
    7 | LBT_HIDDEN float f2c_smax_(const int32_t* n, const float* x, const int32_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_scamin_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:57:18: note: previously declared here
   57 | LBT_HIDDEN float f2c_scamin_(const int32_t* n, const float complex* x, const int32_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_samin_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:37:18: note: previously declared here
   37 | LBT_HIDDEN float f2c_samin_(const int32_t* n, const float* x, const int32_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_scamax_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:47:18: note: previously declared here
   47 | LBT_HIDDEN float f2c_scamax_(const int32_t* n, const float complex* x, const int32_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_samax_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:27:18: note: previously declared here
   27 | LBT_HIDDEN float f2c_samax_(const int32_t* n, const float* x, const int32_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_scsum_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:107:18: note: previously declared here
  107 | LBT_HIDDEN float f2c_scsum_(const int32_t* n, const float complex* x, const int32_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_ssum_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:87:18: note: previously declared here
   87 | LBT_HIDDEN float f2c_ssum_(const int32_t* n, const float* x, const int32_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_scasum_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:117:18: note: previously declared here
  117 | LBT_HIDDEN float f2c_scasum_(const int32_t* n, const float complex* x, const int32_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_sasum_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:97:18: note: previously declared here
   97 | LBT_HIDDEN float f2c_sasum_(const int32_t* n, const float* x, const int32_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_sdsdot_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:77:18: note: previously declared here
   77 | LBT_HIDDEN float f2c_sdsdot_(const int32_t* n, const float* a, const float* x, const int32_t* ix, const float *y, const int32_t* iy) {
      |                  ^
libblastrampoline_f2cdata.h:27:1: error: function 'f2c_sdot_' redeclared as variable
   27 | FLOAT32_FUNCS(XX)
      | ^
f2c_adapters.c:67:18: note: previously declared here
   67 | LBT_HIDDEN float f2c_sdot_(const int32_t* n, const float* x, const int32_t* ix, const float *y, const int32_t* iy) {
      |                  ^
libblastrampoline_f2cdata.h:32:1: error: function 'f2c_zdotc_64_' redeclared as variable
   32 | COMPLEX128_FUNCS(XX_64)
      | ^
f2c_adapters.c:204:27: note: previously declared here
  204 | LBT_HIDDEN double complex f2c_zdotc_64_(const int64_t *n, const double complex *x, const int64_t * ix, const double complex *y, const int64_t *iy) {
      |                           ^
libblastrampoline_f2cdata.h:32:1: error: function 'f2c_zdotu_64_' redeclared as variable
   32 | COMPLEX128_FUNCS(XX_64)
      | ^
f2c_adapters.c:219:16: note: previously declared here
  219 | double complex f2c_zdotu_64_(const int64_t* n, const double complex* x, const int64_t* ix, const double complex *y, const int64_t *iy)
      |                ^
libblastrampoline_f2cdata.h:30:1: error: function 'f2c_cdotc_64_' redeclared as variable
   30 | COMPLEX64_FUNCS(XX_64)
      | ^
f2c_adapters.c:174:26: note: previously declared here
  174 | LBT_HIDDEN float complex f2c_cdotc_64_(const int64_t *n, const float complex *x, const int64_t * ix, const float complex *y, const int64_t *iy) {
      |                          ^
libblastrampoline_f2cdata.h:30:1: error: function 'f2c_cdotu_64_' redeclared as variable
   30 | COMPLEX64_FUNCS(XX_64)
      | ^
f2c_adapters.c:189:15: note: previously declared here
  189 | float complex f2c_cdotu_64_(const int64_t* n, const float complex* x, const int64_t* ix, const float complex *y, const int64_t *iy)
      |               ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_slamc3_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:161:18: note: previously declared here
  161 | LBT_HIDDEN float f2c_slamc3_64_(const float * x, const float * y) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_slamch_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:151:18: note: previously declared here
  151 | LBT_HIDDEN float f2c_slamch_64_(const char * input) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_scnrm2_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:141:18: note: previously declared here
  141 | LBT_HIDDEN float f2c_scnrm2_64_(const int64_t* n, const float complex* x, const int64_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_snrm2_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:131:18: note: previously declared here
  131 | LBT_HIDDEN float f2c_snrm2_64_(const int64_t* n, const float* x, const int64_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_smin_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:21:18: note: previously declared here
   21 | LBT_HIDDEN float f2c_smin_64_(const int64_t* n, const float* x, const int64_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_smax_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:11:18: note: previously declared here
   11 | LBT_HIDDEN float f2c_smax_64_(const int64_t* n, const float* x, const int64_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_scamin_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:61:18: note: previously declared here
   61 | LBT_HIDDEN float f2c_scamin_64_(const int64_t* n, const float complex* x, const int64_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_samin_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:41:18: note: previously declared here
   41 | LBT_HIDDEN float f2c_samin_64_(const int64_t* n, const float* x, const int64_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_scamax_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:51:18: note: previously declared here
   51 | LBT_HIDDEN float f2c_scamax_64_(const int64_t* n, const float complex* x, const int64_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_samax_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:31:18: note: previously declared here
   31 | LBT_HIDDEN float f2c_samax_64_(const int64_t* n, const float* x, const int64_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_scsum_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:111:18: note: previously declared here
  111 | LBT_HIDDEN float f2c_scsum_64_(const int64_t* n, const float complex* x, const int64_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_ssum_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:91:18: note: previously declared here
   91 | LBT_HIDDEN float f2c_ssum_64_(const int64_t* n, const float* x, const int64_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_scasum_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:121:18: note: previously declared here
  121 | LBT_HIDDEN float f2c_scasum_64_(const int64_t* n, const float complex* x, const int64_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_sasum_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:101:18: note: previously declared here
  101 | LBT_HIDDEN float f2c_sasum_64_(const int64_t* n, const float* x, const int64_t* ix) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_sdsdot_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:81:18: note: previously declared here
   81 | LBT_HIDDEN float f2c_sdsdot_64_(const int64_t* n, const float* a, const float* x, const int64_t* ix, const float *y, const int64_t* iy) {
      |                  ^
libblastrampoline_f2cdata.h:28:1: error: function 'f2c_sdot_64_' redeclared as variable
   28 | FLOAT32_FUNCS(XX_64)
      | ^
f2c_adapters.c:71:18: note: previously declared here
   71 | LBT_HIDDEN float f2c_sdot_64_(const int64_t* n, const float* x, const int64_t* ix, const float *y, const int64_t* iy) {
      |                  ^
lto1: fatal error: errors during merging of translation units
compilation terminated.
lto-wrapper: fatal error: /usr/bin/cc returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make: *** [Makefile:35 : build/libblastrampoline.so] Erreur 1
@staticfloat
Copy link
Member

This is happening because we forward-declare functions as a const void *, and that's fine because the ABI interface for a void * and a function are the same once you're merging translation units, but with LTO, the compiler wants the types to match, so it gets mad at us.

We could fix that by forward-declaring the functions "properly", e.g. instead of auto-generating the list of function names, we could write out all the function prototypes from this file. I don't think this would have have any real benefit except that the LTO flag might work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants