Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eKGFP-0007fw-Jv for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Nov 2017 04:14:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eKGFO-0002oJ-W4 for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Nov 2017 04:14:50 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eKGFO-0002o9-Eg for pgsql-hackers@lists.postgresql.org; Thu, 30 Nov 2017 04:14:50 +0000 Received: from mail-qk0-x22f.google.com ([2607:f8b0:400d:c09::22f]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eKGFK-0005nL-Lh for pgsql-hackers@postgresql.org; Thu, 30 Nov 2017 04:14:48 +0000 Received: by mail-qk0-x22f.google.com with SMTP id c13so7342098qke.2 for ; Wed, 29 Nov 2017 20:14:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=KCMxh57MYYwduoAaCzsINBt5Uo6QE5/egQ1lQ5jc8Tw=; b=f1K7ESN2ZKUqg5J25T8apcngJ95CVSTaxMDg9sLWJbdKU2CkDhk/n/LgrZFVd6u7ts wPkW2P7y21dkQe60znRkc422nv/NzwTQj/AIWtFDw34Okm680G29WqJ3MAUElnctvzZ7 0SRd07mCgn3CzNAWYc+3C52+T3QfLej/FtjcY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=KCMxh57MYYwduoAaCzsINBt5Uo6QE5/egQ1lQ5jc8Tw=; b=nYtxUOOAGi3woeMHKkSgQD38Oq59pJf6a+fJSdaXcnfdQsYWIpYGV4s3E30e/MU+FF 5H0tHRuLJrRZoed9iT8RE/Kz1oAQG1RbPifS2wJEia6qTjFTdkGSVqKEFY6BSsQkzv8G sPkuMbPLZJ2gYPGtiaq5Fa72f20Rik9dpq6x8RLlrI/dFoYdszoy7jtamieUq7snMwQw pV9SwCgyVn9xpL6jLmG54L57ZPWHDfcVLeVimZXZ01wUsYsMhBvI9kYHb4wFBrm0oo5+ V53kZtPb4ISIGnOINsLPPEI+mao2R5Jb6oDkmv8XqPd9KUJfc5choUf7Yz+wFFMFvQ0l 5L+w== X-Gm-Message-State: AKGB3mLOo+QNbrgyc+7t/POVbHIyhf3Ijf6ToHLiUHavBz3ttfLWQ8EC 2RvuZyki/WW1PSGqcCAWYLAZFw== X-Google-Smtp-Source: AGs4zMZ/Uc7q45vZyE0f9XPU6JMX4RAY+AynB8cXPb6xs5e1sH/x2L8fL8t4skkAdnsevXlmoMNklQ== X-Received: by 10.55.42.129 with SMTP id q1mr998571qkq.3.1512015285317; Wed, 29 Nov 2017 20:14:45 -0800 (PST) Received: from rfd.leadboat.com (c-73-158-248-138.hsd1.ca.comcast.net. [73.158.248.138]) by smtp.gmail.com with ESMTPSA id o65sm2295401qka.86.2017.11.29.20.14.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 20:14:44 -0800 (PST) Date: Wed, 29 Nov 2017 20:14:41 -0800 From: Noah Misch To: Tom Lane Cc: Dave Page , Sandeep Thakkar , Ashutosh Sharma , Robert Haas , pgsql-hackers Subject: Re: pl/perl extension fails on Windows Message-ID: <20171130041441.GA3161526@rfd.leadboat.com> References: <12588.1502375771@sss.pgh.pa.us> <14838.1502379286@sss.pgh.pa.us> <1708!2.1502718166@sss.pgh.pa.us> <10406.1502743029@sss.pgh.pa.us> <1914.1502978317@sss.pgh.pa.us> <4515.1502981857@sss.pgh.pa.us> <17646.1502983856@sss.pgh.pa.us> <19438.1502986558@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <19438.1502986558@sss.pgh.pa.us> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Aug 17, 2017 at 12:15:58PM -0400, Tom Lane wrote: > I wrote: > > Short of declaring this version of Perl unsupported, the only answer > > I can think of is to put a kluge into the MSVC build scripts along > > the lines of "if it's 32-bit Windows, and the Perl version is before X, > > assume we need _USE_32BIT_TIME_T even if $Config{ccflags} doesn't > > say so". It would be nice to have some hard evidence about what X > > should be, but we don't know when ActiveState fixed this. (I poked > > around in their bugzilla, without success.) > > Ah-hah: it wasn't ActiveState that fixed this at all; it was upstream > Perl. The stanza that Ashutosh found about defining _USE_32BIT_TIME_T > originated in Perl 5.13.4; older Perls simply don't provide it, no > matter how they were built. > > We can now isolate the exact reason we're having trouble on baiji: > it's building Postgres with MSVC 2005, which by default will think > time_t is 64 bits, but it must be using a copy of Perl that was > built with an older Microsoft compiler that doesn't think that. > (Dave's "perl -V" output says ccversion='12.00.8804', but I don't > know how to translate that to the marketing version.) And since it's > pre-5.13.4, Perl itself doesn't know it should advertise this fact. > > So it's now looking to me like we should do the above with X = 5.13.4. > That won't be a perfect solution, but it's about the best we can > readily do. Realistically, nobody out in the wider world is likely > to care about building current PG releases against such old Perl > versions on Windows; if we satisfy our older buildfarm critters, > it's enough for me. MinGW default behavior matches "cl -D_USE_32BIT_TIME_T", and MSVC >= 2005 default behavior matches "gcc -D__MINGW_USE_VC2005_COMPAT"[1]. MinGW-built Perl[2] does not mention _USE_32BIT_TIME_T in $Config{ccflags}, so we typically must add _USE_32BIT_TIME_T when using MSVC to build 32-bit against MinGW-built Perl. I'm considering two ways to achieve this: 1. If $Config{gccversion} is nonempty, add _USE_32BIT_TIME_T. This will do the wrong thing if MinGW changes its default to match modern MSVC. It will do the wrong thing for a Perl built with "gcc -D__MINGW_USE_VC2005_COMPAT". 2. When configuring the build, determine whether to add _USE_32BIT_TIME_T by running a test program built with and without that symbol. Perhaps have the test program store and retrieve a PL_modglobal value. (PL_modglobal maps to a PerlInterpreter field that follows the fields sensitive to _USE_32BIT_TIME_T, and perlapi documents it since 5.8.0 or earlier.) This is more principled than (1), but it will be more code and may have weird interactions with rare Perl build options. I am inclined toward (2) if it takes no more than roughly a hundred lines of code, else (1). Opinions? I regret investing in 32-bit Windows. If there's any OS where a 32-bit PostgreSQL server makes sense today, it's not Windows. Ideally, $Config{ccflags} would include -D_USE_32BIT_TIME_T for MinGW-built Perl, like it does for VC6-built Perl. Considering Perl versions already in the field, fixing Perl won't change this need to patch PostgreSQL. Using MinGW to build a PostgreSQL that links to an MSVC-built Perl probably requires -D__MINGW_USE_VC2005_COMPAT. I may not bother for now. We're less likely to experience that, because Perl binaries advertised on perl.org or in the PostgreSQL documentation are MinGW-built. [1] https://gnunet.org/sorting-out-stat-thing [2] ActivePerl has been MinGW-built for more than five years, and Strawberry Perl has always been MinGW-built. I'm guessing Ashutosh tested with an MSVC-built Perl like http://get.enterprisedb.com/languagepacks/edb-languagepack-10-3-windows.exe.