1. 22 Nov, 2021 2 commits
    • Tom Lane's avatar
      Pacify perlcritic. · 72842a57
      Tom Lane authored
      Per buildfarm.
      72842a57
    • Tom Lane's avatar
      Probe $PROVE not $PERL while checking for modules needed by TAP tests. · e9af18c6
      Tom Lane authored
      Normally "prove" and "perl" come from the same Perl installation,
      but we support the case where they don't (mainly because the MSys
      buildfarm animals need this).  In that case, AX_PROG_PERL_MODULES
      is completely the wrong thing to use, because it's checking what
      "perl" has.  Instead, make a little TAP test script including the
      required modules, and run that under "prove".
      
      We don't need ax_prog_perl_modules.m4 at all after this change,
      so remove it.
      
      Back-patch to all supported branches, for the buildfarm's benefit.
      (In v10, this also back-patches the effects of commit 264eb03a.)
      
      Andrew Dunstan and Tom Lane, per an observation by Noah Misch
      
      Discussion: https://postgr.es/m/E1moZHS-0002Cu-Ei@gemulon.postgresql.org
      e9af18c6
  2. 24 Jul, 2021 1 commit
  3. 21 Apr, 2021 1 commit
  4. 02 Jan, 2021 1 commit
  5. 08 Dec, 2020 1 commit
  6. 30 Nov, 2020 1 commit
    • Tom Lane's avatar
      Remove configure-time probe for DocBook DTD. · 4823c4f6
      Tom Lane authored
      Checking for DocBook being installed was valuable when we were on the
      OpenSP docs toolchain, because that was rather hard to get installed
      fully.  Nowadays, as long as you have xmllint and xsltproc installed,
      you're good, because those programs will fetch the DocBook files off
      the net at need.  Moreover, testing this at configure time means that
      a network access may well occur whether or not you have any interest
      in building the docs later.  That can be slow (typically 2 or 3
      seconds, though much higher delays have been reported), and it seems
      not very nice to be doing an off-machine access without warning, too.
      
      Hence, drop the PGAC_CHECK_DOCBOOK probe, and adjust related
      documentation.  Without that macro, there's not much left of
      config/docbook.m4 at all, so I just removed it.
      
      Back-patch to v11, where we started to use xmllint in the
      PGAC_CHECK_DOCBOOK probe.
      
      Discussion: https://postgr.es/m/E2EE6B76-2D96-408A-B961-CAE47D1A86F0@yesql.se
      Discussion: https://postgr.es/m/A55A7FC9-FA60-47FE-98B5-139CDC57CE6E@gmail.com
      4823c4f6
  7. 21 Oct, 2020 1 commit
    • Tom Lane's avatar
      Remove the option to build thread_test.c outside configure. · 8a212118
      Tom Lane authored
      Theoretically one could go into src/test/thread and build/run this
      program there.  In practice, that hasn't worked since 96bf88d5,
      and probably much longer on some platforms (likely including just
      the sort of hoary leftovers where this test might be of interest).
      While it wouldn't be too hard to repair the breakage, the fact that
      nobody has noticed for two years shows that there is zero usefulness
      in maintaining this build pathway.  Let's get rid of it and decree
      that thread_test.c is *only* meant to be built/used in configure.
      
      Given that decision, it makes sense to put thread_test.c under config/
      and get rid of src/test/thread altogether, so that's what I did.
      
      In passing, update src/test/README, which had been ignored by some
      not-so-recent additions of subdirectories.
      
      Discussion: https://postgr.es/m/227659.1603041612@sss.pgh.pa.us
      8a212118
  8. 24 Jul, 2020 1 commit
  9. 30 Apr, 2020 1 commit
  10. 22 Apr, 2020 1 commit
    • Tom Lane's avatar
      Sync up some inconsistent comments in config/c-compiler.m4. · 748507c7
      Tom Lane authored
      Make header/trailer comments agree with the actual names of some macros.
      These seem like legit names in earlier iterations of respective patches
      (commit b779168f "Detect PG_PRINTF_ATTRIBUTE automatically." and
      commit 6869b4f2 "Add C++ support to configure.") but the macro had
      been renamed out of sync with the header / trailer comment in the final
      committed patch.
      
      Even more nitpickily, make the dashed underlines agree with the lengths
      of the macro names everyplace.  There doesn't seem to have been any
      meeting of the minds previously on whether those should match or not,
      but at least some people have been trying to make 'em match.
      
      Jesse Zhang, Tom Lane
      
      Discussion: https://postgr.es/m/CAGf+fX7DDyq6WfCy6X_KtD28MkbNBE6NkRi26fSf25dfUwX0zw@mail.gmail.com
      748507c7
  11. 28 Mar, 2020 1 commit
    • Peter Eisentraut's avatar
      Enable Unix-domain sockets support on Windows · 8f3ec75d
      Peter Eisentraut authored
      As of Windows 10 version 1803, Unix-domain sockets are supported on
      Windows.  But it's not automatically detected by configure because it
      looks for struct sockaddr_un and Windows doesn't define that.  So we
      just make our own definition on Windows and override the configure
      result.
      
      Set DEFAULT_PGSOCKET_DIR to empty on Windows so by default no
      Unix-domain socket is used, because there is no good standard
      location.
      
      In pg_upgrade, we have to do some extra tweaking to preserve the
      existing behavior of not using Unix-domain sockets on Windows.  Adding
      support would be desirable, but it needs further work, in particular a
      way to select whether to use Unix-domain sockets from the command-line
      or with a run-time test.
      
      The pg_upgrade test script needs a fix.  The previous code passed
      "localhost" to postgres -k, which only happened to work because
      Windows used to ignore the -k argument value altogether.  We instead
      need to pass an empty string to get the desired effect.
      
      The test suites will continue to not use Unix-domain sockets on
      Windows.  This requires a small tweak in pg_regress.c.  The TAP tests
      don't need to be changed because they decide by the operating system
      rather than HAVE_UNIX_SOCKETS.
      Reviewed-by: default avatarAndrew Dunstan <andrew.dunstan@2ndquadrant.com>
      Discussion: https://www.postgresql.org/message-id/flat/54bde68c-d134-4eb8-5bd3-8af33b72a010@2ndquadrant.com
      8f3ec75d
  12. 21 Feb, 2020 1 commit
  13. 23 Jan, 2020 2 commits
    • Tom Lane's avatar
      Add configure probe for rl_completion_suppress_quote. · c3270444
      Tom Lane authored
      I had supposed that all versions of Readline that have filename
      quoting hooks also have the rl_completion_suppress_quote variable.
      But it seems OpenBSD managed to find a version someplace that does
      not, so we'll have to expend a separate configure probe for that.
      
      (Light testing suggests that this version also lacks the bugs that
      make it necessary to frob that variable.  Hooray!)
      
      Per buildfarm.
      c3270444
    • Tom Lane's avatar
      Improve psql's tab completion for filenames. · cd69ec66
      Tom Lane authored
      The Readline library contains a fair amount of knowledge about how to
      tab-complete filenames, but it turns out that that doesn't work too well
      unless we follow its expectation that we use its filename quoting hooks
      to quote and de-quote filenames.  We were trying to do such quote handling
      within complete_from_files(), and that's still what we have to do if we're
      using libedit, which lacks those hooks.  But for Readline, it works a lot
      better if we tell Readline that single-quote is a quoting character and
      then provide hooks that know the details of the quoting rules for SQL
      and psql meta-commands.
      
      Hence, resurrect the quoting hook functions that existed in the original
      version of tab-complete.c (and were disabled by commit f6689a32 because
      they "didn't work so well yet"), and whack on them until they do seem to
      work well.
      
      Notably, this fixes bug #16059 from Steven Winfield, who pointed out
      that the previous coding would strip quote marks from filenames in SQL
      COPY commands, even though they're syntactically necessary there.
      Now, we not only don't do that, but we'll add a quote mark when you
      tab-complete, even if you didn't type one.
      
      Getting this to work across a range of libedit versions (and, to a
      lesser extent, libreadline versions) was depressingly difficult.
      It will be interesting to see whether the new regression test cases
      pass everywhere in the buildfarm.
      
      Some future patch might try to handle quoted SQL identifiers with
      similar explicit quoting/dequoting logic, but that's for another day.
      
      Patch by me, reviewed by Peter Eisentraut.
      
      Discussion: https://postgr.es/m/16059-8836946734c02b84@postgresql.org
      cd69ec66
  14. 08 Jan, 2020 1 commit
  15. 07 Oct, 2019 1 commit
  16. 18 Aug, 2019 1 commit
  17. 27 Apr, 2019 1 commit
  18. 27 Mar, 2019 1 commit
  19. 04 Mar, 2019 1 commit
    • Andrew Dunstan's avatar
      Reorder configure tests for accept() in Windows · 6ad94e4d
      Andrew Dunstan authored
      Currently only frogmouth in the buildfarm uses the 32bit params, and
      it's not able to build past release 10, so put those last, saving
      substantial configure time on more modern systems. Even if we get a
      modern 32 bit Windows system at some stage we should probably prefer the
      64 bit interface here these days.
      6ad94e4d
  20. 16 Feb, 2019 1 commit
    • Tom Lane's avatar
      Make use of compiler builtins and/or assembly for CLZ, CTZ, POPCNT. · 02a6a54e
      Tom Lane authored
      Test for the compiler builtins __builtin_clz, __builtin_ctz, and
      __builtin_popcount, and make use of these in preference to
      handwritten C code if they're available.  Create src/port
      infrastructure for "leftmost one", "rightmost one", and "popcount"
      so as to centralize these decisions.
      
      On x86_64, __builtin_popcount generally won't make use of the POPCNT
      opcode because that's not universally supported yet.  Provide code
      that checks CPUID and then calls POPCNT via asm() if available.
      This requires indirecting through a function pointer, which is
      an annoying amount of overhead for a one-instruction operation,
      but it's probably not worth working harder than this for our
      current use-cases.
      
      I'm not sure we've found all the existing places that could profit
      from this new infrastructure; but we at least touched all the
      ones that used copied-and-pasted versions of the bitmapset.c code,
      and got rid of multiple copies of the associated constant arrays.
      
      While at it, replace c-compiler.m4's one-per-builtin-function
      macros with a single one that can handle all the cases we need
      to worry about so far.  Also, because I'm paranoid, make those
      checks into AC_LINK checks rather than just AC_COMPILE; the
      former coding failed to verify that libgcc has support for the
      builtin, in cases where it's not inline code.
      
      David Rowley, Thomas Munro, Alvaro Herrera, Tom Lane
      
      Discussion: https://postgr.es/m/CAKJS1f9WTAGG1tPeJnD18hiQW5gAk59fQ6WK-vfdAKEHyRg2RA@mail.gmail.com
      02a6a54e
  21. 15 Feb, 2019 2 commits
    • Alvaro Herrera's avatar
      Revert attempts to use POPCNT etc instructions · 457aef0f
      Alvaro Herrera authored
      This reverts commits fc6c7274, 109de05c, d0b4663c and
      711bab1e.
      
      Somebody will have to try harder before submitting this patch again.
      I've spent entirely too much time on it already, and the #ifdef maze yet
      to be written in order for it to build at all got on my nerves.  The
      amount of work needed to get a platform-specific performance improvement
      that's barely above the noise level is not worth it.
      457aef0f
    • Alvaro Herrera's avatar
      Fix compiler builtin usage in new pg_bitutils.c · fc6c7274
      Alvaro Herrera authored
      Split out these new functions in three parts: one in a new file that
      uses the compiler builtin and gets compiled with the -mpopcnt compiler
      option if it exists; another one that uses the compiler builtin but not
      the compiler option; and finally the fallback with open-coded
      algorithms.
      
      Split out the configure logic: in the original commit, it was selecting
      to use the -mpopcnt compiler switch together with deciding whether to
      use the compiler builtin, but those two things are really separate.
      Split them out.  Also, expose whether the builtin exists to
      Makefile.global, so that src/port's Makefile can decide whether to
      compile the hw-optimized file.
      
      Remove CPUID test for CTZ/CLZ.  Make pg_{right,left}most_ones use either
      the compiler intrinsic or open-coded algo; trying to use the
      HW-optimized version is a waste of time.  Make them static inline
      functions.
      
      Discussion: https://postgr.es/m/20190213221719.GA15976@alvherre.pgsql
      fc6c7274
  22. 13 Feb, 2019 2 commits
    • Alvaro Herrera's avatar
      Fix portability issues in pg_bitutils · 109de05c
      Alvaro Herrera authored
      We were using uint64 function arguments as "long int" arguments to
      compiler builtins, which fails on machines where long ints are 32 bits:
      the upper half of the uint64 was being ignored.  Fix by using the "ll"
      builtin variants instead, which on those machines take 64 bit arguments.
      
      Also, remove configure tests for __builtin_popcountl() (as well as
      "long" variants for ctz and clz): the theory here is that any compiler
      version will provide all widths or none, so one test suffices.  Were
      this theory to be wrong, we'd have to add tests for
      __builtin_popcountll() and friends, which would be tedious.
      
      Per failures in buildfarm member lapwing and ensuing discussion.
      109de05c
    • Alvaro Herrera's avatar
      Add basic support for using the POPCNT and SSE4.2s LZCNT opcodes · 711bab1e
      Alvaro Herrera authored
      These opcodes have been around in the AMD world since 2007, and 2008 in
      the case of intel.  They're supported in GCC and Clang via some __builtin
      macros.  The opcodes may be unavailable during runtime, in which case we
      fall back on a C-based implementation of the code.  In order to get the
      POPCNT instruction we must pass the -mpopcnt option to the compiler.  We
      do this only for the pg_bitutils.c file.
      
      David Rowley (with fragments taken from a patch by Thomas Munro)
      
      Discussion: https://postgr.es/m/CAKJS1f9WTAGG1tPeJnD18hiQW5gAk59fQ6WK-vfdAKEHyRg2RA@mail.gmail.com
      711bab1e
  23. 09 Feb, 2019 1 commit
  24. 18 Jan, 2019 1 commit
  25. 13 Jan, 2019 1 commit
  26. 19 Nov, 2018 3 commits
    • Tom Lane's avatar
      Update config/ax_pthread.m4 to latest upstream version. · df303aff
      Tom Lane authored
      This change doesn't fix any bugs that we've heard about, but it seems
      like a good idea on general principles to track upstream occasionally.
      
      Discussion: https://postgr.es/m/3320.1542647565@sss.pgh.pa.us
      df303aff
    • Tom Lane's avatar
      Postpone LLVM-related uses of AC_CHECK_DECLS. · 640a4ba0
      Tom Lane authored
      Calling AC_CHECK_DECLS before we've finished setting up the compiler's
      CFLAGS seems like a pretty risky proposition, especially now that the
      first use of that macro will result in a test to see whether the compiler
      gives warning or error for undeclared built-in functions.  That answer
      could very easily get changed later than where PGAC_LLVM_SUPPORT is
      called; furthermore, it's hardly unlikely that flags such as -D_GNU_SOURCE
      could change visibility of declarations.  Hence, be a little less cavalier
      about where to do LLVM-related tests.  This results in v11 and HEAD doing
      the warning-or-error check at the same place in the script as older
      branches are doing it, which seems like a good thing.
      
      Per further thought about commits 0b59b0e8 and 16fbac39.
      640a4ba0
    • Tom Lane's avatar
      Fix configure's AC_CHECK_DECLS tests to work correctly with clang. · 16fbac39
      Tom Lane authored
      The test case that Autoconf uses to discover whether a function has
      been declared doesn't work reliably with clang, because clang reports
      a warning not an error if the name is a known built-in function.
      On some platforms, this results in a lot of compile-time warnings about
      strlcpy and related functions not having been declared.
      
      There is a fix for this (by Noah Misch) in the upstream Autoconf sources,
      but since they've not made a release in years and show no indication of
      doing so anytime soon, let's just absorb their fix directly.  We can
      revert this when and if we update to a newer Autoconf release.
      
      Back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/26819.1542515567@sss.pgh.pa.us
      16fbac39
  27. 09 Oct, 2018 1 commit
    • Tom Lane's avatar
      Select appropriate PG_PRINTF_ATTRIBUTE for recent NetBSD. · aed9fa0b
      Tom Lane authored
      NetBSD-current generates a large number of warnings about "%m" not
      being appropriate to use with *printf functions.  While that's true
      for their native printf, it's surely not true for snprintf.c, so I
      think they have misunderstood gcc's definition of the "gnu_printf"
      archetype.  Nonetheless, choosing "__syslog__" instead silences the
      warnings; so teach configure about that.
      
      Since this is only a cosmetic warning issue (and anyway it depends
      on previous hacking to be self-consistent), no back-patch.
      
      Discussion: https://postgr.es/m/16785.1539046036@sss.pgh.pa.us
      aed9fa0b
  28. 26 Sep, 2018 2 commits
    • Tom Lane's avatar
      Try another way to detect the result type of strerror_r(). · 751f532b
      Tom Lane authored
      The method we've traditionally used, of redeclaring strerror_r() to
      see if the compiler complains of inconsistent declarations, turns out
      not to work reliably because some compilers only report a warning,
      not an error.  Amazingly, this has gone undetected for years, even
      though it certainly breaks our detection of whether strerror_r
      succeeded.
      
      Let's instead test whether the compiler will take the result of
      strerror_r() as a switch() argument.  It's possible this won't
      work universally either, but it's the best idea I could come up with
      on the spur of the moment.
      
      We should probably back-patch this once the dust settles, but
      first let's see what the buildfarm thinks of it.
      
      Discussion: https://postgr.es/m/10877.1537993279@sss.pgh.pa.us
      751f532b
    • Tom Lane's avatar
      Always use our own versions of *printf(). · 96bf88d5
      Tom Lane authored
      We've spent an awful lot of effort over the years in coping with
      platform-specific vagaries of the *printf family of functions.  Let's just
      forget all that mess and standardize on always using src/port/snprintf.c.
      This gets rid of a lot of configure logic, and it will allow a saner
      approach to dealing with %m (though actually changing that is left for
      a follow-on patch).
      
      Preliminary performance testing suggests that as it stands, snprintf.c is
      faster than the native printf functions for some tasks on some platforms,
      and slower for other cases.  A pending patch will improve that, though
      cases with floating-point conversions will doubtless remain slower unless
      we want to put a *lot* of effort into that.  Still, we've not observed
      that *printf is really a performance bottleneck for most workloads, so
      I doubt this matters much.
      
      Patch by me, reviewed by Michael Paquier
      
      Discussion: https://postgr.es/m/2975.1526862605@sss.pgh.pa.us
      96bf88d5
  29. 25 Sep, 2018 1 commit
    • Tom Lane's avatar
      Make some fixes to allow building Postgres on macOS 10.14 ("Mojave"). · 5e221713
      Tom Lane authored
      Apple's latest rearrangements of the system-supplied headers have broken
      building of PL/Perl and PL/Tcl.  The only practical way to fix PL/Tcl is to
      start using the "-isysroot" compiler flag to point to SDK-supplied headers,
      as Apple expects.  We must also start distinguishing where to find Perl's
      headers from where to find its shared library; but that seems like good
      cleanup anyway.
      
      Extensions that formerly did something like -I$(perl_archlibexp)/CORE
      should now do -I$(perl_includedir)/CORE instead.  perl_archlibexp
      is still the place to look for libperl.so, though.
      
      If for some reason you don't like the default -isysroot setting, you can
      override that by setting PG_SYSROOT in configure's arguments.  I don't
      currently think people would need to do so, unless maybe for cross-version
      build purposes.
      
      In addition, teach configure where to find tclConfig.sh.  Our traditional
      method of searching $auto_path hasn't worked for the last couple of macOS
      releases, and it now seems clear that Apple's not going to change that.
      The workaround of manually specifying --with-tclconfig was annoying
      already, but Mojave's made it a lot more so because the sysroot path now
      has to be included as well.  Let's just wire the knowledge into configure
      instead.  To avoid breaking builds against non-default Tcl installations
      (e.g. MacPorts) wherein the $auto_path method probably still works,
      arrange to try the additional case only after all else has failed.
      
      Back-patch to all supported versions, since at least the buildfarm
      cares about that.  The changes are set up to not do anything on macOS
      releases that are old enough to not have functional sysroot trees.
      5e221713
  30. 13 Sep, 2018 1 commit
  31. 24 Aug, 2018 2 commits
  32. 17 Aug, 2018 1 commit
    • Tom Lane's avatar
      Fix configure's snprintf test so it exposes HP-UX bug. · 9bed827b
      Tom Lane authored
      Since commit e1d19c90, buildfarm member gharial has been failing with
      symptoms indicating that snprintf sometimes returns -1 for buffer
      overrun, even though it passes the added configure check.  Some
      google research suggests that this happens only in limited cases,
      such as when the overrun happens partway through a %d item.  Adjust
      the configure check to exercise it that way.  Since I'm now feeling
      more paranoid than I was before, also make the test explicitly verify
      that the buffer doesn't get physically overrun.
      9bed827b