Re: random module linking problem on mingw ?
On 2018-12-16 8:29 a.m., Bruno Haible wrote: For me, with a gnulib testdir created through ./gnulib-tool --create-testdir --dir=../testdir1 --single-configure random I still get a link error in test-random. "nm" shows why: random.o defines __initstate and __setstate, where test-random.c expects initstate and setstate. But it is easy to fix, now that you have shown how. I've pushed the combined fix in your name: Thanks!
Re: random module linking problem on mingw ?
Hi Assaf, > The attached patch works for me on mingw, Thanks for the investigation. For me, with a gnulib testdir created through ./gnulib-tool --create-testdir --dir=../testdir1 --single-configure random I still get a link error in test-random. "nm" shows why: random.o defines __initstate and __setstate, where test-random.c expects initstate and setstate. But it is easy to fix, now that you have shown how. I've pushed the combined fix in your name: 2018-12-16 Assaf Gordon random: Fix build error on native Windows (regression from 2018-06-21). * lib/random.c (__srandom, __initstate, __setstate, __random, __srandom_r, __initstate_r, __setstate_r, __random_r) [!_LIBC]: Redirect to the symbols without '__' prefix. diff --git a/lib/random.c b/lib/random.c index d14b820..5e01b72 100644 --- a/lib/random.c +++ b/lib/random.c @@ -52,6 +52,14 @@ #ifndef _LIBC # include +# define __srandom srandom +# define __initstate initstate +# define __setstate setstate +# define __random random +# define __srandom_r srandom_r +# define __initstate_r initstate_r +# define __setstate_r setstate_r +# define __random_r random_r #endif /* Specification. */
Re: random module linking problem on mingw ?
Hello, On 2018-12-14 3:36 p.m., Paul Eggert wrote: This does not ring a bell with me. Presumably the "# define __random_r random_r" business in lib/random_r.c and lib/stdlib.in.h also need to be done for random and srandom in lib/random.c and lib/stdlib.in.h? Thanks for the hint. The attached patch works for me on mingw, and doesn't seem to have ill effects on other systems. However I do not know if this is sufficiently correct or not. regards, - assaf diff --git a/lib/random.c b/lib/random.c index d14b82084..a971fc864 100644 --- a/lib/random.c +++ b/lib/random.c @@ -52,6 +52,12 @@ #ifndef _LIBC # include +# define __srandom srandom +# define __random random +# define __srandom_r srandom_r +# define __initstate_r initstate_r +# define __setstate_r setstate_r +# define __random_r random_r #endif /* Specification. */
Re: random module linking problem on mingw ?
This does not ring a bell with me. Presumably the "# define __random_r random_r" business in lib/random_r.c and lib/stdlib.in.h also need to be done for random and srandom in lib/random.c and lib/stdlib.in.h?
Re: random module linking problem on mingw ?
Hi Assaf, > Around June 2018, there were few changes to the random module: > == > 6979c258b random_r: do not crash if state is unaligned > dc4b9a1f9 random_r: omit unnecessary include > 137dda358 random, random_r: merge from glibc > == > > After uprgading gnulib and re-building (towards a new release), > and when building on cygwin with a mingw compiler, I see the following > warnings and errors. I see them as well, in a testdir created through ./gnulib-tool --create-testdir --single-configure --dir=../testdir1 random > I'm still investigating things on my end, but if this rings a bell to > any one No, it does not ring a bell. Bruno
random module linking problem on mingw ?
Hello, Around June 2018, there were few changes to the random module: == 6979c258b random_r: do not crash if state is unaligned dc4b9a1f9 random_r: omit unnecessary include 137dda358 random, random_r: merge from glibc == After uprgading gnulib and re-building (towards a new release), and when building on cygwin with a mingw compiler, I see the following warnings and errors. My code calls srandom() and random() and nothing changed in the code since the previous released (which used gnulib circa March 2018, before the module changes). I'm still investigating things on my end, but if this rings a bell to any one - any comments or suggestions are welcomed. Thanks, - assaf == $ ./configure --host=x86_64-w64-mingw32 --disable-nls $ make [...] depbase=`echo lib/random.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ x86_64-w64-mingw32-gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -Ilib -I./lib -Isrc -I./src -g -O2 -MT lib/random.o -MD -MP -MF $depbase.Tpo -c -o lib/random.o lib/random.c &&\ mv -f $depbase.Tpo $depbase.Po lib/random.c: In function '__srandom': lib/random.c:221:10: warning: implicit declaration of function '__srandom_r' [-Wimplicit-function-declaration] (void) __srandom_r (x, &unsafe_state); ^~~ lib/random.c: In function '__initstate': lib/random.c:249:9: warning: implicit declaration of function '__initstate_r' [-Wimplicit-function-declaration] ret = __initstate_r (seed, arg_state, n, &unsafe_state); ^ lib/random.c: In function '__setstate': lib/random.c:275:7: warning: implicit declaration of function '__setstate_r' [-Wimplicit-function-declaration] if (__setstate_r (arg_state, &unsafe_state) < 0) ^~~~ lib/random.c: In function '__random': lib/random.c:303:10: warning: implicit declaration of function '__random_r' [-Wimplicit-function-declaration] (void) __random_r (&unsafe_state, &retval); ^~ depbase=`echo lib/random_r.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ x86_64-w64-mingw32-gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -Ilib -I./lib -Isrc -I./src -g -O2 -MT lib/random_r.o -MD -MP -MF $depbase.Tpo -c -o lib/random_r.o lib/random_r.c &&\ mv -f $depbase.Tpo $depbase.Po [...] /home/admin/pretest.2018-12-14.mR95hZ/datamash-1.3.9-62c5.gIRsqa/datamash-1.3.9-62c5/src/field-ops.c:479: undefined reference to `random' src/datamash-field-ops.o: In function `init_random': /home/admin/pretest.2018-12-14.mR95hZ/datamash-1.3.9-62c5.gIRsqa/datamash-1.3.9-62c5/src/field-ops.c:1035: undefined reference to `srandom' collect2: error: ld returned 1 exit status make[2]: *** [Makefile:2709: datamash.exe] Error 1 ==