rurban / dieharder

A fixed version of Robert G. Brown's "dieharder" tests for random number generators.
Other
10 stars 4 forks source link

dieharder 3.31.2.111does not compile with MSYS2. #15

Open mayd opened 1 week ago

mayd commented 1 week ago

I tried compiling the source code from here https://github.com/rurban/dieharder/releases/tag/3.31.2.111. but there were several problems.

  1. According the the instructions in INSTALL the build should require configure && make. However, there was no configure script. I ran autogen.sh and it created a configure script.

  2. Configure ran without error.

  3. Make compiled libdieharder object files with a few warnings but failed to create the library due to many undefined references:

$ make
make  all-recursive
make[1]: Entering directory '/home/david/projects/dieharder-3.31.2.111'
Making all in libdieharder
make[2]: Entering directory '/home/david/projects/dieharder-3.31.2.111/libdieharder'
  CCLD     libdieharder.la
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-bits.o:bits.c:(.rdata$.refptr.rmax_bits[.refptr.rmax_bits]+0x0): undefined reference to `rmax_bits'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-dab_dct.o:dab_dct.c:(.rdata$.refptr.rmax_mask[.refptr.rmax_mask]+0x0): undefined reference to `rmax_mask'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-dab_dct.o:dab_dct.c:(.rdata$.refptr.ntuple[.refptr.ntuple]+0x0): undefined reference to `ntuple'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-diehard_operm5.o:diehard_operm5:(.rdata$.refptr.overlap[.refptr.overlap]+0x0): undefined reference to `overlap'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-histogram.o:histogram.c:(.rdata$.refptr.psamples[.refptr.psamples]+0x0): undefined reference to `psamples'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-kstest.o:kstest.c:(.rdata$.refptr.ks_test[.refptr.ks_test]+0x0): undefined reference to `ks_test'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-marsaglia_tsang_gorilla.o:marsaglia_tsang_gorilla.c:(.rdata$.refptr.x_user[.refptr.x_user]+0x0): undefined reference to `x_user'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-rgb_bitdist.o:rgb_bitdist.c:(.rdata$.refptr.tsamples[.refptr.tsamples]+0x0): undefined reference to `tsamples'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-rgb_bitdist.o:rgb_bitdist.c:(.rdata$.refptr.bits[.refptr.bits]+0x0): undefined reference to `bits'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-rgb_persist.o:rgb_persist.c:(.rdata$.refptr.seed[.refptr.seed]+0x0): undefined reference to `seed'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-rng_uvag.o:rng_uvag.c:(.rdata$.refptr.rmax[.refptr.rmax]+0x0): undefined reference to `rmax'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-rng_uvag.o:rng_uvag.c:(.rdata$.refptr.random_max[.refptr.random_max]+0x0): undefined reference to `random_max'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-rng_XOR.o:rng_XOR.c:(.rdata$.refptr.gnumbs[.refptr.gnumbs]+0x0): undefined reference to `gnumbs'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-rng_XOR.o:rng_XOR.c:(.rdata$.refptr.gvcount[.refptr.gvcount]+0x0): undefined reference to `gvcount'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-sample.o:sample.c:(.rdata$.refptr.Seed[.refptr.Seed]+0x0): undefined reference to `Seed'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-std_test.o:std_test.c:(.rdata$.refptr.Xstep[.refptr.Xstep]+0x0): undefined reference to `Xstep'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-std_test.o:std_test.c:(.rdata$.refptr.Xoff[.refptr.Xoff]+0x0): undefined reference to `Xoff'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-std_test.o:std_test.c:(.rdata$.refptr.Xtrategy[.refptr.Xtrategy]+0x0): undefined reference to `Xtrategy'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-std_test.o:std_test.c:(.rdata$.refptr.multiply_p[.refptr.multiply_p]+0x0): undefined reference to `multiply_p'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libdieharder_la-std_test.o:std_test.c:(.rdata$.refptr.all[.refptr.all]+0x0): undefined reference to `all'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [Makefile:738: libdieharder.la] Error 1
make[2]: Leaving directory '/home/david/projects/dieharder-3.31.2.111/libdieharder'
make[1]: *** [Makefile:584: all-recursive] Error 1
make[1]: Leaving directory '/home/david/projects/dieharder-3.31.2.111'
make: *** [Makefile:464: all] Error 2

Unfortunately, I am not very knowledgeable about Autoconf but it seems many of the undefined variables are defined in dieharder/set_globals.c rather than in libdieharder source files.

mayd commented 6 days ago

After a little investigation I found that this error is possibly related to GCC version 10 linker option -fno-common being set to TRUE by default: it was set to FALSE in earlier versions of GCC. I learned the the R Project for Statistical Computing has created its own refactored version of dieharder to work around this issue. And I noticed that the original dieharder project (for Linux) has not been updated for several years. So I am not optimistic this issue is going to be fixed.

mayd commented 2 days ago

However, this turned out to be simple to fix. So I created a pull request. if anyone is interested: https://github.com/rurban/dieharder/pull/16.