Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mrXdz-0005xb-CL for pgsql-committers@arkaria.postgresql.org; Mon, 29 Nov 2021 03:47:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mrXdy-0003b1-79 for pgsql-committers@arkaria.postgresql.org; Mon, 29 Nov 2021 03:47:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mrXdy-0003as-0S for pgsql-committers@lists.postgresql.org; Mon, 29 Nov 2021 03:47:54 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mrXdv-0002IO-2b for pgsql-committers@lists.postgresql.org; Mon, 29 Nov 2021 03:47:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1AT3lmL21135296; Sun, 28 Nov 2021 22:47:48 -0500 From: Tom Lane To: Andrew Dunstan cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Replace random(), pg_erand48(), etc with a better PRNG API and a In-reply-to: References: Comments: In-reply-to Tom Lane message dated "Mon, 29 Nov 2021 02:33:45 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1135294.1638157668.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 28 Nov 2021 22:47:48 -0500 Message-ID: <1135295.1638157668@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tom Lane writes: > Replace random(), pg_erand48(), etc with a better PRNG API and algorithm= . Hmm, fairywren doesn't like this [1]: gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-stateme= nt -Werror=3Dvla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fall= through=3D3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -f= wrapv -fexcess-precision=3Dstandard -Wno-format-truncation -Wno-stringop-t= runcation -g -O2 win32ver.o pg_test_fsync.o -L../../../src/port -L../../..= /src/common -Wl,--allow-multiple-definition -Wl,--disable-auto-import -L= /c/prog/3p64/lib -L/c/prog/3p64/openssl/lib -Wl,--as-needed -lpgcommon -= lpgport -lssl -lcrypto -lz -lws2_32 -lm -lws2_32 -o pg_test_fsync.exe C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../= ../x86_64-w64-mingw32/bin/ld.exe: pg_test_fsync.o: in function `main': C:/tools/msys64/home/pgrunner/bf/root/HEAD/pgsql.build/../pgsql/src/bin/pg= _test_fsync/pg_test_fsync.c:121: undefined reference to `__imp_pg_global_p= rng_state' collect2.exe: error: ld returned 1 exit status I think what is going on here is that the compilation of pg_test_fsync.c sees extern PGDLLIMPORT pg_prng_state pg_global_prng_state; and does something that's inappropriate when the variable is actually coming from elsewhere in the same program. If so, we could perhaps fix it by doing #ifdef FRONTEND extern pg_prng_state pg_global_prng_state; #else extern PGDLLIMPORT pg_prng_state pg_global_prng_state; #endif Thoughts? regards, tom lane [1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=3Dfairywren&dt= =3D2021-11-29%2003%3A04%3A24