1
2PostgreSQL Installation from Source Code
3
4------------------------------------------------------------------------
5
6This document describes the installation of PostgreSQL using this source
7code distribution.
8
9If you are building PostgreSQL for Microsoft Windows, read this document
10if you intend to build with MinGW or Cygwin; but if you intend to build
11with Microsoft's Visual C++, see the main documentation instead.
12
13------------------------------------------------------------------------
14
15
16Short Version
17
18    ./configure
19    make
20    su
21    make install
22    adduser postgres
23    mkdir /usr/local/pgsql/data
24    chown postgres /usr/local/pgsql/data
25    su - postgres
26    /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
27    /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
28    /usr/local/pgsql/bin/createdb test
29    /usr/local/pgsql/bin/psql test
30
31The long version is the rest of this document.
32
33------------------------------------------------------------------------
34
35
36Requirements
37
38In general, a modern Unix-compatible platform should be able to run
39PostgreSQL. The platforms that had received specific testing at the time
40of release are described in the section called "Supported Platforms"
41below.
42
43The following software packages are required for building PostgreSQL:
44
45-   GNU make version 3.80 or newer is required; other make programs or
46    older GNU make versions will *not* work. (GNU make is sometimes
47    installed under the name "gmake".) To test for GNU make enter:
48
49        make --version
50
51-   You need an ISO/ANSI C compiler (at least C99-compliant). Recent
52    versions of GCC are recommended, but PostgreSQL is known to build
53    using a wide variety of compilers from different vendors.
54
55-   tar is required to unpack the source distribution, in addition to
56    either gzip or bzip2.
57
58-   The GNU Readline library is used by default. It allows psql (the
59    PostgreSQL command line SQL interpreter) to remember each command
60    you type, and allows you to use arrow keys to recall and edit
61    previous commands. This is very helpful and is strongly recommended.
62    If you don't want to use it then you must specify the
63    "--without-readline" option to "configure". As an alternative, you
64    can often use the BSD-licensed "libedit" library, originally
65    developed on NetBSD. The "libedit" library is GNU
66    Readline-compatible and is used if "libreadline" is not found, or if
67    "--with-libedit-preferred" is used as an option to "configure". If
68    you are using a package-based Linux distribution, be aware that you
69    need both the readline and readline-devel packages, if those are
70    separate in your distribution.
71
72-   The zlib compression library is used by default. If you don't want
73    to use it then you must specify the "--without-zlib" option to
74    "configure". Using this option disables support for compressed
75    archives in pg_dump and pg_restore.
76
77The following packages are optional. They are not required in the
78default configuration, but they are needed when certain build options
79are enabled, as explained below:
80
81-   To build the server programming language PL/Perl you need a full
82    Perl installation, including the "libperl" library and the header
83    files. The minimum required version is Perl 5.8.3. Since PL/Perl
84    will be a shared library, the "libperl" library must be a shared
85    library also on most platforms. This appears to be the default in
86    recent Perl versions, but it was not in earlier versions, and in any
87    case it is the choice of whomever installed Perl at your site.
88    "configure" will fail if building PL/Perl is selected but it cannot
89    find a shared "libperl". In that case, you will have to rebuild and
90    install Perl manually to be able to build PL/Perl. During the
91    configuration process for Perl, request a shared library.
92
93    If you intend to make more than incidental use of PL/Perl, you
94    should ensure that the Perl installation was built with the
95    usemultiplicity option enabled (perl -V will show whether this is
96    the case).
97
98-   To build the PL/Python server programming language, you need a
99    Python installation with the header files and the distutils module.
100    The minimum required version is Python 2.4. Python 3 is supported if
101    it's version 3.1 or later; but see the PL/Python documentation when
102    using Python 3.
103
104    Since PL/Python will be a shared library, the "libpython" library
105    must be a shared library also on most platforms. This is not the
106    case in a default Python installation built from source, but a
107    shared library is available in many operating system distributions.
108    "configure" will fail if building PL/Python is selected but it
109    cannot find a shared "libpython". That might mean that you either
110    have to install additional packages or rebuild (part of) your Python
111    installation to provide this shared library. When building from
112    source, run Python's configure with the --enable-shared flag.
113
114-   To build the PL/Tcl procedural language, you of course need a Tcl
115    installation. The minimum required version is Tcl 8.4.
116
117-   To enable Native Language Support (NLS), that is, the ability to
118    display a program's messages in a language other than English, you
119    need an implementation of the Gettext API. Some operating systems
120    have this built-in (e.g., Linux, NetBSD, Solaris), for other systems
121    you can download an add-on package from
122    http://www.gnu.org/software/gettext/. If you are using the Gettext
123    implementation in the GNU C library then you will additionally need
124    the GNU Gettext package for some utility programs. For any of the
125    other implementations you will not need it.
126
127-   You need OpenSSL, if you want to support encrypted client
128    connections. OpenSSL is also required for random number generation
129    on platforms that do not have "/dev/urandom" (except Windows). The
130    minimum version required is 0.9.8.
131
132-   You need Kerberos, OpenLDAP, and/or PAM, if you want to support
133    authentication using those services.
134
135-   To build the PostgreSQL documentation, there is a separate set of
136    requirements; see the main documentation's appendix on
137    documentation.
138
139If you are building from a Git tree instead of using a released source
140package, or if you want to do server development, you also need the
141following packages:
142
143-   Flex and Bison are needed to build from a Git checkout, or if you
144    changed the actual scanner and parser definition files. If you need
145    them, be sure to get Flex 2.5.31 or later and Bison 1.875 or later.
146    Other lex and yacc programs cannot be used.
147
148-   Perl 5.8.3 or later is needed to build from a Git checkout, or if
149    you changed the input files for any of the build steps that use Perl
150    scripts. If building on Windows you will need Perl in any case. Perl
151    is also required to run some test suites.
152
153If you need to get a GNU package, you can find it at your local GNU
154mirror site (see https://www.gnu.org/prep/ftp for a list) or at
155ftp://ftp.gnu.org/gnu/.
156
157Also check that you have sufficient disk space. You will need about 100
158MB for the source tree during compilation and about 20 MB for the
159installation directory. An empty database cluster takes about 35 MB;
160databases take about five times the amount of space that a flat text
161file with the same data would take. If you are going to run the
162regression tests you will temporarily need up to an extra 150 MB. Use
163the "df" command to check free disk space.
164
165------------------------------------------------------------------------
166
167
168Installation Procedure
169
1701.  CONFIGURATION
171
172    The first step of the installation procedure is to configure the
173    source tree for your system and choose the options you would like.
174    This is done by running the "configure" script. For a default
175    installation simply enter:
176
177        ./configure
178
179    This script will run a number of tests to determine values for
180    various system dependent variables and detect any quirks of your
181    operating system, and finally will create several files in the build
182    tree to record what it found. You can also run "configure" in a
183    directory outside the source tree, if you want to keep the build
184    directory separate. This procedure is also called a VPATH build.
185    Here's how:
186
187        mkdir build_dir
188        cd build_dir
189        /path/to/source/tree/configure [options go here]
190        make
191
192    The default configuration will build the server and utilities, as
193    well as all client applications and interfaces that require only a C
194    compiler. All files will be installed under "/usr/local/pgsql" by
195    default.
196
197    You can customize the build and installation process by supplying
198    one or more of the following command line options to "configure":
199
200    --prefix=PREFIX
201
202        Install all files under the directory "PREFIX" instead of
203        "/usr/local/pgsql". The actual files will be installed into
204        various subdirectories; no files will ever be installed directly
205        into the "PREFIX" directory.
206
207        If you have special needs, you can also customize the individual
208        subdirectories with the following options. However, if you leave
209        these with their defaults, the installation will be relocatable,
210        meaning you can move the directory after installation. (The man
211        and doc locations are not affected by this.)
212
213        For relocatable installs, you might want to use "configure"'s
214        --disable-rpath option. Also, you will need to tell the
215        operating system how to find the shared libraries.
216
217    --exec-prefix=EXEC-PREFIX
218
219        You can install architecture-dependent files under a different
220        prefix, "EXEC-PREFIX", than what "PREFIX" was set to. This can
221        be useful to share architecture-independent files between hosts.
222        If you omit this, then "EXEC-PREFIX" is set equal to "PREFIX"
223        and both architecture-dependent and independent files will be
224        installed under the same tree, which is probably what you want.
225
226    --bindir=DIRECTORY
227
228        Specifies the directory for executable programs. The default is
229        "EXEC-PREFIX/bin", which normally means "/usr/local/pgsql/bin".
230
231    --sysconfdir=DIRECTORY
232
233        Sets the directory for various configuration files, "PREFIX/etc"
234        by default.
235
236    --libdir=DIRECTORY
237
238        Sets the location to install libraries and dynamically loadable
239        modules. The default is "EXEC-PREFIX/lib".
240
241    --includedir=DIRECTORY
242
243        Sets the directory for installing C and C++ header files. The
244        default is "PREFIX/include".
245
246    --datarootdir=DIRECTORY
247
248        Sets the root directory for various types of read-only data
249        files. This only sets the default for some of the following
250        options. The default is "PREFIX/share".
251
252    --datadir=DIRECTORY
253
254        Sets the directory for read-only data files used by the
255        installed programs. The default is "DATAROOTDIR". Note that this
256        has nothing to do with where your database files will be placed.
257
258    --localedir=DIRECTORY
259
260        Sets the directory for installing locale data, in particular
261        message translation catalog files. The default is
262        "DATAROOTDIR/locale".
263
264    --mandir=DIRECTORY
265
266        The man pages that come with PostgreSQL will be installed under
267        this directory, in their respective "manx" subdirectories. The
268        default is "DATAROOTDIR/man".
269
270    --docdir=DIRECTORY
271
272        Sets the root directory for installing documentation files,
273        except "man" pages. This only sets the default for the following
274        options. The default value for this option is
275        "DATAROOTDIR/doc/postgresql".
276
277    --htmldir=DIRECTORY
278
279        The HTML-formatted documentation for PostgreSQL will be
280        installed under this directory. The default is "DATAROOTDIR".
281
282    NOTE:
283
284    Care has been taken to make it possible to install PostgreSQL into
285    shared installation locations (such as "/usr/local/include") without
286    interfering with the namespace of the rest of the system. First, the
287    string "/postgresql" is automatically appended to datadir,
288    sysconfdir, and docdir, unless the fully expanded directory name
289    already contains the string "postgres" or "pgsql". For example, if
290    you choose "/usr/local" as prefix, the documentation will be
291    installed in "/usr/local/doc/postgresql", but if the prefix is
292    "/opt/postgres", then it will be in "/opt/postgres/doc". The public
293    C header files of the client interfaces are installed into
294    includedir and are namespace-clean. The internal header files and
295    the server header files are installed into private directories under
296    includedir. See the documentation of each interface for information
297    about how to access its header files. Finally, a private
298    subdirectory will also be created, if appropriate, under libdir for
299    dynamically loadable modules.
300
301    --with-extra-version=STRING
302
303        Append "STRING" to the PostgreSQL version number. You can use
304        this, for example, to mark binaries built from unreleased Git
305        snapshots or containing custom patches with an extra version
306        string such as a "git describe" identifier or a distribution
307        package release number.
308
309    --with-includes=DIRECTORIES
310
311        "DIRECTORIES" is a colon-separated list of directories that will
312        be added to the list the compiler searches for header files. If
313        you have optional packages (such as GNU Readline) installed in a
314        non-standard location, you have to use this option and probably
315        also the corresponding "--with-libraries" option.
316
317        Example: --with-includes=/opt/gnu/include:/usr/sup/include.
318
319    --with-libraries=DIRECTORIES
320
321        "DIRECTORIES" is a colon-separated list of directories to search
322        for libraries. You will probably have to use this option (and
323        the corresponding "--with-includes" option) if you have packages
324        installed in non-standard locations.
325
326        Example: --with-libraries=/opt/gnu/lib:/usr/sup/lib.
327
328    --enable-nls[=LANGUAGES]
329
330        Enables Native Language Support (NLS), that is, the ability to
331        display a program's messages in a language other than English.
332        "LANGUAGES" is an optional space-separated list of codes of the
333        languages that you want supported, for example
334        --enable-nls='de fr'. (The intersection between your list and
335        the set of actually provided translations will be computed
336        automatically.) If you do not specify a list, then all available
337        translations are installed.
338
339        To use this option, you will need an implementation of the
340        Gettext API; see above.
341
342    --with-pgport=NUMBER
343
344        Set "NUMBER" as the default port number for server and clients.
345        The default is 5432. The port can always be changed later on,
346        but if you specify it here then both server and clients will
347        have the same default compiled in, which can be very convenient.
348        Usually the only good reason to select a non-default value is if
349        you intend to run multiple PostgreSQL servers on the same
350        machine.
351
352    --with-perl
353
354        Build the PL/Perl server-side language.
355
356    --with-python
357
358        Build the PL/Python server-side language.
359
360    --with-tcl
361
362        Build the PL/Tcl server-side language.
363
364    --with-tclconfig=DIRECTORY
365
366        Tcl installs the file "tclConfig.sh", which contains
367        configuration information needed to build modules interfacing to
368        Tcl. This file is normally found automatically at a well-known
369        location, but if you want to use a different version of Tcl you
370        can specify the directory in which to look for it.
371
372    --with-gssapi
373
374        Build with support for GSSAPI authentication. On many systems,
375        the GSSAPI (usually a part of the Kerberos installation) system
376        is not installed in a location that is searched by default
377        (e.g., "/usr/include", "/usr/lib"), so you must use the options
378        "--with-includes" and "--with-libraries" in addition to this
379        option. "configure" will check for the required header files and
380        libraries to make sure that your GSSAPI installation is
381        sufficient before proceeding.
382
383    --with-krb-srvnam=NAME
384
385        The default name of the Kerberos service principal used by
386        GSSAPI. postgres is the default. There's usually no reason to
387        change this unless you have a Windows environment, in which case
388        it must be set to upper case POSTGRES.
389
390    --with-llvm
391
392        Build with support for LLVM based JIT compilation. This requires
393        the LLVM library to be installed. The minimum required version
394        of LLVM is currently 3.9.
395
396        "llvm-config" will be used to find the required compilation
397        options. "llvm-config", and then "llvm-config-$major-$minor" for
398        all supported versions, will be searched on PATH. If that would
399        not yield the correct binary, use LLVM_CONFIG to specify a path
400        to the correct "llvm-config". For example
401
402            ./configure ... --with-llvm LLVM_CONFIG='/path/to/llvm/bin/llvm-config'
403
404        LLVM support requires a compatible "clang" compiler (specified,
405        if necessary, using the CLANG environment variable), and a
406        working C++ compiler (specified, if necessary, using the CXX
407        environment variable).
408
409    --with-icu
410
411        Build with support for the ICU library. This requires the ICU4C
412        package to be installed. The minimum required version of ICU4C
413        is currently 4.2.
414
415        By default, pkg-config will be used to find the required
416        compilation options. This is supported for ICU4C version 4.6 and
417        later. For older versions, or if pkg-config is not available,
418        the variables ICU_CFLAGS and ICU_LIBS can be specified to
419        "configure", like in this example:
420
421            ./configure ... --with-icu ICU_CFLAGS='-I/some/where/include' ICU_LIBS='-L/some/where/lib -licui18n -licuuc -licudata'
422
423        (If ICU4C is in the default search path for the compiler, then
424        you still need to specify a nonempty string in order to avoid
425        use of pkg-config, for example, ICU_CFLAGS=' '.)
426
427    --with-openssl
428
429        Build with support for SSL (encrypted) connections. This
430        requires the OpenSSL package to be installed. "configure" will
431        check for the required header files and libraries to make sure
432        that your OpenSSL installation is sufficient before proceeding.
433
434    --with-pam
435
436        Build with PAM (Pluggable Authentication Modules) support.
437
438    --with-bsd-auth
439
440        Build with BSD Authentication support. (The BSD Authentication
441        framework is currently only available on OpenBSD.)
442
443    --with-ldap
444
445        Build with LDAP support for authentication and connection
446        parameter lookup (see the documentation about client
447        authentication and libpq for more information). On Unix, this
448        requires the OpenLDAP package to be installed. On Windows, the
449        default WinLDAP library is used. "configure" will check for the
450        required header files and libraries to make sure that your
451        OpenLDAP installation is sufficient before proceeding.
452
453    --with-systemd
454
455        Build with support for systemd service notifications. This
456        improves integration if the server binary is started under
457        systemd but has no impact otherwise. libsystemd and the
458        associated header files need to be installed to be able to use
459        this option.
460
461    --without-readline
462
463        Prevents use of the Readline library (and libedit as well). This
464        option disables command-line editing and history in psql, so it
465        is not recommended.
466
467    --with-libedit-preferred
468
469        Favors the use of the BSD-licensed libedit library rather than
470        GPL-licensed Readline. This option is significant only if you
471        have both libraries installed; the default in that case is to
472        use Readline.
473
474    --with-bonjour
475
476        Build with Bonjour support. This requires Bonjour support in
477        your operating system. Recommended on macOS.
478
479    --with-uuid=LIBRARY
480
481        Build the uuid-ossp module (which provides functions to generate
482        UUIDs), using the specified UUID library. "LIBRARY" must be one
483        of:
484
485        -   "bsd" to use the UUID functions found in FreeBSD, NetBSD,
486            and some other BSD-derived systems
487
488        -   "e2fs" to use the UUID library created by the e2fsprogs
489            project; this library is present in most Linux systems and
490            in macOS, and can be obtained for other platforms as well
491
492        -   "ossp" to use the OSSP UUID library
493
494    --with-ossp-uuid
495
496        Obsolete equivalent of --with-uuid=ossp.
497
498    --with-libxml
499
500        Build with libxml2, enabling SQL/XML support. Libxml2 version
501        2.6.23 or later is required for this feature.
502
503        To detect the required compiler and linker options, PostgreSQL
504        will query "pkg-config", if that is installed and knows about
505        libxml2. Otherwise the program "xml2-config", which is installed
506        by libxml2, will be used if it is found. Use of "pkg-config" is
507        preferred, because it can deal with multi-architecture
508        installations better.
509
510        To use a libxml2 installation that is in an unusual location,
511        you can set "pkg-config"-related environment variables (see its
512        documentation), or set the environment variable XML2_CONFIG to
513        point to the "xml2-config" program belonging to the libxml2
514        installation, or set the variables XML2_CFLAGS and XML2_LIBS.
515        (If "pkg-config" is installed, then to override its idea of
516        where libxml2 is you must either set XML2_CONFIG or set both
517        XML2_CFLAGS and XML2_LIBS to nonempty strings.)
518
519    --with-libxslt
520
521        Use libxslt when building the xml2 module. xml2 relies on this
522        library to perform XSL transformations of XML.
523
524    --disable-float4-byval
525
526        Disable passing float4 values "by value", causing them to be
527        passed "by reference" instead. This option costs performance,
528        but may be needed for compatibility with old user-defined
529        functions that are written in C and use the "version 0" calling
530        convention. A better long-term solution is to update any such
531        functions to use the "version 1" calling convention.
532
533    --disable-float8-byval
534
535        Disable passing float8 values "by value", causing them to be
536        passed "by reference" instead. This option costs performance,
537        but may be needed for compatibility with old user-defined
538        functions that are written in C and use the "version 0" calling
539        convention. A better long-term solution is to update any such
540        functions to use the "version 1" calling convention. Note that
541        this option affects not only float8, but also int8 and some
542        related types such as timestamp. On 32-bit platforms,
543        "--disable-float8-byval" is the default and it is not allowed to
544        select "--enable-float8-byval".
545
546    --with-segsize=SEGSIZE
547
548        Set the segment size, in gigabytes. Large tables are divided
549        into multiple operating-system files, each of size equal to the
550        segment size. This avoids problems with file size limits that
551        exist on many platforms. The default segment size, 1 gigabyte,
552        is safe on all supported platforms. If your operating system has
553        "largefile" support (which most do, nowadays), you can use a
554        larger segment size. This can be helpful to reduce the number of
555        file descriptors consumed when working with very large tables.
556        But be careful not to select a value larger than is supported by
557        your platform and the file systems you intend to use. Other
558        tools you might wish to use, such as tar, could also set limits
559        on the usable file size. It is recommended, though not
560        absolutely required, that this value be a power of 2. Note that
561        changing this value requires an initdb.
562
563    --with-blocksize=BLOCKSIZE
564
565        Set the block size, in kilobytes. This is the unit of storage
566        and I/O within tables. The default, 8 kilobytes, is suitable for
567        most situations; but other values may be useful in special
568        cases. The value must be a power of 2 between 1 and 32
569        (kilobytes). Note that changing this value requires an initdb.
570
571    --with-wal-blocksize=BLOCKSIZE
572
573        Set the WAL block size, in kilobytes. This is the unit of
574        storage and I/O within the WAL log. The default, 8 kilobytes, is
575        suitable for most situations; but other values may be useful in
576        special cases. The value must be a power of 2 between 1 and 64
577        (kilobytes). Note that changing this value requires an initdb.
578
579    --disable-spinlocks
580
581        Allow the build to succeed even if PostgreSQL has no CPU
582        spinlock support for the platform. The lack of spinlock support
583        will result in poor performance; therefore, this option should
584        only be used if the build aborts and informs you that the
585        platform lacks spinlock support. If this option is required to
586        build PostgreSQL on your platform, please report the problem to
587        the PostgreSQL developers.
588
589    --disable-thread-safety
590
591        Disable the thread-safety of client libraries. This prevents
592        concurrent threads in libpq and ECPG programs from safely
593        controlling their private connection handles.
594
595    --with-system-tzdata=DIRECTORY
596
597        PostgreSQL includes its own time zone database, which it
598        requires for date and time operations. This time zone database
599        is in fact compatible with the IANA time zone database provided
600        by many operating systems such as FreeBSD, Linux, and Solaris,
601        so it would be redundant to install it again. When this option
602        is used, the system-supplied time zone database in "DIRECTORY"
603        is used instead of the one included in the PostgreSQL source
604        distribution. "DIRECTORY" must be specified as an absolute path.
605        "/usr/share/zoneinfo" is a likely directory on some operating
606        systems. Note that the installation routine will not detect
607        mismatching or erroneous time zone data. If you use this option,
608        you are advised to run the regression tests to verify that the
609        time zone data you have pointed to works correctly with
610        PostgreSQL.
611
612        This option is mainly aimed at binary package distributors who
613        know their target operating system well. The main advantage of
614        using this option is that the PostgreSQL package won't need to
615        be upgraded whenever any of the many local daylight-saving time
616        rules change. Another advantage is that PostgreSQL can be
617        cross-compiled more straightforwardly if the time zone database
618        files do not need to be built during the installation.
619
620    --without-zlib
621
622        Prevents use of the Zlib library. This disables support for
623        compressed archives in pg_dump and pg_restore. This option is
624        only intended for those rare systems where this library is not
625        available.
626
627    --enable-debug
628
629        Compiles all programs and libraries with debugging symbols. This
630        means that you can run the programs in a debugger to analyze
631        problems. This enlarges the size of the installed executables
632        considerably, and on non-GCC compilers it usually also disables
633        compiler optimization, causing slowdowns. However, having the
634        symbols available is extremely helpful for dealing with any
635        problems that might arise. Currently, this option is recommended
636        for production installations only if you use GCC. But you should
637        always have it on if you are doing development work or running a
638        beta version.
639
640    --enable-coverage
641
642        If using GCC, all programs and libraries are compiled with code
643        coverage testing instrumentation. When run, they generate files
644        in the build directory with code coverage metrics. This option
645        is for use only with GCC and when doing development work.
646
647    --enable-profiling
648
649        If using GCC, all programs and libraries are compiled so they
650        can be profiled. On backend exit, a subdirectory will be created
651        that contains the "gmon.out" file for use in profiling. This
652        option is for use only with GCC and when doing development work.
653
654    --enable-cassert
655
656        Enables assertion checks in the server, which test for many
657        "cannot happen" conditions. This is invaluable for code
658        development purposes, but the tests can slow down the server
659        significantly. Also, having the tests turned on won't
660        necessarily enhance the stability of your server! The assertion
661        checks are not categorized for severity, and so what might be a
662        relatively harmless bug will still lead to server restarts if it
663        triggers an assertion failure. This option is not recommended
664        for production use, but you should have it on for development
665        work or when running a beta version.
666
667    --enable-depend
668
669        Enables automatic dependency tracking. With this option, the
670        makefiles are set up so that all affected object files will be
671        rebuilt when any header file is changed. This is useful if you
672        are doing development work, but is just wasted overhead if you
673        intend only to compile once and install. At present, this option
674        only works with GCC.
675
676    --enable-dtrace
677
678        Compiles PostgreSQL with support for the dynamic tracing tool
679        DTrace.
680
681        To point to the "dtrace" program, the environment variable
682        DTRACE can be set. This will often be necessary because "dtrace"
683        is typically installed under "/usr/sbin", which might not be in
684        the path.
685
686        Extra command-line options for the "dtrace" program can be
687        specified in the environment variable DTRACEFLAGS. On Solaris,
688        to include DTrace support in a 64-bit binary, you must specify
689        DTRACEFLAGS="-64" to configure. For example, using the GCC
690        compiler:
691
692            ./configure CC='gcc -m64' --enable-dtrace DTRACEFLAGS='-64' ...
693
694        Using Sun's compiler:
695
696            ./configure CC='/opt/SUNWspro/bin/cc -xtarget=native64' --enable-dtrace DTRACEFLAGS='-64' ...
697
698    --enable-tap-tests
699
700        Enable tests using the Perl TAP tools. This requires a Perl
701        installation and the Perl module IPC::Run.
702
703    If you prefer a C compiler different from the one "configure" picks,
704    you can set the environment variable CC to the program of your
705    choice. By default, "configure" will pick "gcc" if available, else
706    the platform's default (usually "cc"). Similarly, you can override
707    the default compiler flags if needed with the CFLAGS variable.
708
709    You can specify environment variables on the "configure" command
710    line, for example:
711
712        ./configure CC=/opt/bin/gcc CFLAGS='-O2 -pipe'
713
714    Here is a list of the significant variables that can be set in this
715    manner:
716
717    BISON
718
719        Bison program
720
721    CC
722
723        C compiler
724
725    CFLAGS
726
727        options to pass to the C compiler
728
729    CLANG
730
731        path to "clang" program used to process source code for inlining
732        when compiling with --with-llvm
733
734    CPP
735
736        C preprocessor
737
738    CPPFLAGS
739
740        options to pass to the C preprocessor
741
742    CXX
743
744        C++ compiler
745
746    CXXFLAGS
747
748        options to pass to the C++ compiler
749
750    DTRACE
751
752        location of the "dtrace" program
753
754    DTRACEFLAGS
755
756        options to pass to the "dtrace" program
757
758    FLEX
759
760        Flex program
761
762    LDFLAGS
763
764        options to use when linking either executables or shared
765        libraries
766
767    LDFLAGS_EX
768
769        additional options for linking executables only
770
771    LDFLAGS_SL
772
773        additional options for linking shared libraries only
774
775    LLVM_CONFIG
776
777        "llvm-config" program used to locate the LLVM installation.
778
779    MSGFMT
780
781        "msgfmt" program for native language support
782
783    PERL
784
785        Perl interpreter program. This will be used to determine the
786        dependencies for building PL/Perl. The default is "perl".
787
788    PYTHON
789
790        Python interpreter program. This will be used to determine the
791        dependencies for building PL/Python. Also, whether Python 2 or 3
792        is specified here (or otherwise implicitly chosen) determines
793        which variant of the PL/Python language becomes available. See
794        the PL/Python documentation for more information. If this is not
795        set, the following are probed in this order:
796        python python3 python2.
797
798    TCLSH
799
800        Tcl interpreter program. This will be used to determine the
801        dependencies for building PL/Tcl, and it will be substituted
802        into Tcl scripts.
803
804    XML2_CONFIG
805
806        "xml2-config" program used to locate the libxml2 installation
807
808    Sometimes it is useful to add compiler flags after-the-fact to the
809    set that were chosen by "configure". An important example is that
810    gcc's "-Werror" option cannot be included in the CFLAGS passed to
811    "configure", because it will break many of "configure"'s built-in
812    tests. To add such flags, include them in the COPT environment
813    variable while running "make". The contents of COPT are added to
814    both the CFLAGS and LDFLAGS options set up by "configure". For
815    example, you could do
816
817        make COPT='-Werror'
818
819    or
820
821        export COPT='-Werror'
822        make
823
824    NOTE:
825
826    When developing code inside the server, it is recommended to use the
827    configure options "--enable-cassert" (which turns on many run-time
828    error checks) and "--enable-debug" (which improves the usefulness of
829    debugging tools).
830
831    If using GCC, it is best to build with an optimization level of at
832    least "-O1", because using no optimization ("-O0") disables some
833    important compiler warnings (such as the use of uninitialized
834    variables). However, non-zero optimization levels can complicate
835    debugging because stepping through compiled code will usually not
836    match up one-to-one with source code lines. If you get confused
837    while trying to debug optimized code, recompile the specific files
838    of interest with "-O0". An easy way to do this is by passing an
839    option to make: "make PROFILE=-O0 file.o".
840
841    The COPT and PROFILE environment variables are actually handled
842    identically by the PostgreSQL makefiles. Which to use is a matter of
843    preference, but a common habit among developers is to use PROFILE
844    for one-time flag adjustments, while COPT might be kept set all the
845    time.
846
8472.  BUILD
848
849    To start the build, type either of:
850
851        make
852        make all
853
854    (Remember to use GNU make.) The build will take a few minutes
855    depending on your hardware. The last line displayed should be:
856
857        All of PostgreSQL successfully made. Ready to install.
858
859    If you want to build everything that can be built, including the
860    documentation (HTML and man pages), and the additional modules
861    ("contrib"), type instead:
862
863        make world
864
865    The last line displayed should be:
866
867        PostgreSQL, contrib, and documentation successfully made. Ready to install.
868
869    If you want to build everything that can be built, including the
870    additional modules ("contrib"), but without the documentation, type
871    instead:
872
873        make world-bin
874
875    If you want to invoke the build from another makefile rather than
876    manually, you must unset MAKELEVEL or set it to zero, for instance
877    like this:
878
879        build-postgresql:
880                $(MAKE) -C postgresql MAKELEVEL=0 all
881
882    Failure to do that can lead to strange error messages, typically
883    about missing header files.
884
8853.  REGRESSION TESTS
886
887    If you want to test the newly built server before you install it,
888    you can run the regression tests at this point. The regression tests
889    are a test suite to verify that PostgreSQL runs on your machine in
890    the way the developers expected it to. Type:
891
892        make check
893
894    (This won't work as root; do it as an unprivileged user.) See the
895    file "src/test/regress/README" and the documentation for detailed
896    information about interpreting the test results. You can repeat this
897    test at any later time by issuing the same command.
898
8994.  INSTALLING THE FILES
900
901    NOTE:
902
903    If you are upgrading an existing system be sure to read the
904    documentation, which has instructions about upgrading a cluster.
905
906    To install PostgreSQL enter:
907
908        make install
909
910    This will install files into the directories that were specified in
911    Step 1. Make sure that you have appropriate permissions to write
912    into that area. Normally you need to do this step as root.
913    Alternatively, you can create the target directories in advance and
914    arrange for appropriate permissions to be granted.
915
916    To install the documentation (HTML and man pages), enter:
917
918        make install-docs
919
920    If you built the world above, type instead:
921
922        make install-world
923
924    This also installs the documentation.
925
926    If you built the world without the documentation above, type
927    instead:
928
929        make install-world-bin
930
931    You can use make install-strip instead of make install to strip the
932    executable files and libraries as they are installed. This will save
933    some space. If you built with debugging support, stripping will
934    effectively remove the debugging support, so it should only be done
935    if debugging is no longer needed. install-strip tries to do a
936    reasonable job saving space, but it does not have perfect knowledge
937    of how to strip every unneeded byte from an executable file, so if
938    you want to save all the disk space you possibly can, you will have
939    to do manual work.
940
941    The standard installation provides all the header files needed for
942    client application development as well as for server-side program
943    development, such as custom functions or data types written in C.
944    (Prior to PostgreSQL 8.0, a separate make     install-all-headers
945    command was needed for the latter, but this step has been folded
946    into the standard install.)
947
948    CLIENT-ONLY INSTALLATION:  If you want to install only the client
949    applications and interface libraries, then you can use these
950    commands:
951
952        make -C src/bin install
953        make -C src/include install
954        make -C src/interfaces install
955        make -C doc install
956
957    "src/bin" has a few binaries for server-only use, but they are
958    small.
959
960UNINSTALLATION:  To undo the installation use the command "make
961uninstall". However, this will not remove any created directories.
962
963CLEANING:  After the installation you can free disk space by removing
964the built files from the source tree with the command "make clean". This
965will preserve the files made by the "configure" program, so that you can
966rebuild everything with "make" later on. To reset the source tree to the
967state in which it was distributed, use "make distclean". If you are
968going to build for several platforms within the same source tree you
969must do this and re-configure for each platform. (Alternatively, use a
970separate build tree for each platform, so that the source tree remains
971unmodified.)
972
973If you perform a build and then discover that your "configure" options
974were wrong, or if you change anything that "configure" investigates (for
975example, software upgrades), then it's a good idea to do "make
976distclean" before reconfiguring and rebuilding. Without this, your
977changes in configuration choices might not propagate everywhere they
978need to.
979
980------------------------------------------------------------------------
981
982
983Post-Installation Setup
984
985------------------------------------------------------------------------
986
987Shared Libraries
988
989On some systems with shared libraries you need to tell the system how to
990find the newly installed shared libraries. The systems on which this is
991*not* necessary include FreeBSD, HP-UX, Linux, NetBSD, OpenBSD, and
992Solaris.
993
994The method to set the shared library search path varies between
995platforms, but the most widely-used method is to set the environment
996variable LD_LIBRARY_PATH like so: In Bourne shells ("sh", "ksh", "bash",
997"zsh"):
998
999    LD_LIBRARY_PATH=/usr/local/pgsql/lib
1000    export LD_LIBRARY_PATH
1001
1002or in "csh" or "tcsh":
1003
1004    setenv LD_LIBRARY_PATH /usr/local/pgsql/lib
1005
1006Replace /usr/local/pgsql/lib with whatever you set "--libdir" to in Step
10071. You should put these commands into a shell start-up file such as
1008"/etc/profile" or "~/.bash_profile". Some good information about the
1009caveats associated with this method can be found at
1010http://xahlee.info/UnixResource_dir/_/ldpath.html.
1011
1012On some systems it might be preferable to set the environment variable
1013LD_RUN_PATH *before* building.
1014
1015On Cygwin, put the library directory in the PATH or move the ".dll"
1016files into the "bin" directory.
1017
1018If in doubt, refer to the manual pages of your system (perhaps "ld.so"
1019or "rld"). If you later get a message like:
1020
1021    psql: error in loading shared libraries
1022    libpq.so.2.1: cannot open shared object file: No such file or directory
1023
1024then this step was necessary. Simply take care of it then.
1025
1026If you are on Linux and you have root access, you can run:
1027
1028    /sbin/ldconfig /usr/local/pgsql/lib
1029
1030(or equivalent directory) after installation to enable the run-time
1031linker to find the shared libraries faster. Refer to the manual page of
1032"ldconfig" for more information. On FreeBSD, NetBSD, and OpenBSD the
1033command is:
1034
1035    /sbin/ldconfig -m /usr/local/pgsql/lib
1036
1037instead. Other systems are not known to have an equivalent command.
1038
1039------------------------------------------------------------------------
1040
1041Environment Variables
1042
1043If you installed into "/usr/local/pgsql" or some other location that is
1044not searched for programs by default, you should add
1045"/usr/local/pgsql/bin" (or whatever you set "--bindir" to in Step 1)
1046into your PATH. Strictly speaking, this is not necessary, but it will
1047make the use of PostgreSQL much more convenient.
1048
1049To do this, add the following to your shell start-up file, such as
1050"~/.bash_profile" (or "/etc/profile", if you want it to affect all
1051users):
1052
1053    PATH=/usr/local/pgsql/bin:$PATH
1054    export PATH
1055
1056If you are using "csh" or "tcsh", then use this command:
1057
1058    set path = ( /usr/local/pgsql/bin $path )
1059
1060To enable your system to find the man documentation, you need to add
1061lines like the following to a shell start-up file unless you installed
1062into a location that is searched by default:
1063
1064    MANPATH=/usr/local/pgsql/share/man:$MANPATH
1065    export MANPATH
1066
1067The environment variables PGHOST and PGPORT specify to client
1068applications the host and port of the database server, overriding the
1069compiled-in defaults. If you are going to run client applications
1070remotely then it is convenient if every user that plans to use the
1071database sets PGHOST. This is not required, however; the settings can be
1072communicated via command line options to most client programs.
1073
1074------------------------------------------------------------------------
1075
1076
1077Getting Started
1078
1079The following is a quick summary of how to get PostgreSQL up and running
1080once installed. The main documentation contains more information.
1081
10821.  Create a user account for the PostgreSQL server. This is the user
1083    the server will run as. For production use you should create a
1084    separate, unprivileged account ("postgres" is commonly used). If you
1085    do not have root access or just want to play around, your own user
1086    account is enough, but running the server as root is a security risk
1087    and will not work.
1088
1089        adduser postgres
1090
10912.  Create a database installation with the "initdb" command. To run
1092    "initdb" you must be logged in to your PostgreSQL server account. It
1093    will not work as root.
1094
1095        root# mkdir /usr/local/pgsql/data
1096        root# chown postgres /usr/local/pgsql/data
1097        root# su - postgres
1098        postgres$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
1099
1100    The "-D" option specifies the location where the data will be
1101    stored. You can use any path you want, it does not have to be under
1102    the installation directory. Just make sure that the server account
1103    can write to the directory (or create it, if it doesn't already
1104    exist) before starting "initdb", as illustrated here.
1105
11063.  At this point, if you did not use the "initdb" -A option, you might
1107    want to modify "pg_hba.conf" to control local access to the server
1108    before you start it. The default is to trust all local users.
1109
11104.  The previous "initdb" step should have told you how to start up the
1111    database server. Do so now. The command should look something like:
1112
1113        /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data start
1114
1115    To stop a server running in the background you can type:
1116
1117        /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data stop
1118
11195.  Create a database:
1120
1121        /usr/local/pgsql/bin/createdb testdb
1122
1123    Then enter:
1124
1125        /usr/local/pgsql/bin/psql testdb
1126
1127    to connect to that database. At the prompt you can enter SQL
1128    commands and start experimenting.
1129
1130------------------------------------------------------------------------
1131
1132
1133What Now?
1134
1135-   The PostgreSQL distribution contains a comprehensive documentation
1136    set, which you should read sometime. After installation, the
1137    documentation can be accessed by pointing your browser to
1138    "/usr/local/pgsql/doc/html/index.html", unless you changed the
1139    installation directories.
1140
1141    The first few chapters of the main documentation are the Tutorial,
1142    which should be your first reading if you are completely new to SQL
1143    databases. If you are familiar with database concepts then you want
1144    to proceed with part on server administration, which contains
1145    information about how to set up the database server, database users,
1146    and authentication.
1147
1148-   Usually, you will want to modify your computer so that it will
1149    automatically start the database server whenever it boots. Some
1150    suggestions for this are in the documentation.
1151
1152-   Run the regression tests against the installed server (using "make
1153    installcheck"). If you didn't run the tests before installation, you
1154    should definitely do it now. This is also explained in the
1155    documentation.
1156
1157-   By default, PostgreSQL is configured to run on minimal hardware.
1158    This allows it to start up with almost any hardware configuration.
1159    The default configuration is, however, not designed for optimum
1160    performance. To achieve optimum performance, several server
1161    parameters must be adjusted, the two most common being
1162    shared_buffers and work_mem. Other parameters mentioned in the
1163    documentation also affect performance.
1164
1165------------------------------------------------------------------------
1166
1167
1168Supported Platforms
1169
1170A platform (that is, a CPU architecture and operating system
1171combination) is considered supported by the PostgreSQL development
1172community if the code contains provisions to work on that platform and
1173it has recently been verified to build and pass its regression tests on
1174that platform. Currently, most testing of platform compatibility is done
1175automatically by test machines in the PostgreSQL Build Farm. If you are
1176interested in using PostgreSQL on a platform that is not represented in
1177the build farm, but on which the code works or can be made to work, you
1178are strongly encouraged to set up a build farm member machine so that
1179continued compatibility can be assured.
1180
1181In general, PostgreSQL can be expected to work on these CPU
1182architectures: x86, x86_64, IA64, PowerPC, PowerPC 64, S/390, S/390x,
1183Sparc, Sparc 64, ARM, MIPS, MIPSEL, and PA-RISC. Code support exists for
1184M68K, M32R, and VAX, but these architectures are not known to have been
1185tested recently. It is often possible to build on an unsupported CPU
1186type by configuring with "--disable-spinlocks", but performance will be
1187poor.
1188
1189PostgreSQL can be expected to work on these operating systems: Linux
1190(all recent distributions), Windows (Win2000 SP4 and later), FreeBSD,
1191OpenBSD, NetBSD, macOS, AIX, HP/UX, and Solaris. Other Unix-like systems
1192may also work but are not currently being tested. In most cases, all CPU
1193architectures supported by a given operating system will work. Look in
1194the section called "Platform-Specific Notes" below to see if there is
1195information specific to your operating system, particularly if using an
1196older system.
1197
1198If you have installation problems on a platform that is known to be
1199supported according to recent build farm results, please report it to
1200<pgsql-bugs@lists.postgresql.org>. If you are interested in porting
1201PostgreSQL to a new platform, <pgsql-hackers@lists.postgresql.org> is
1202the appropriate place to discuss that.
1203
1204------------------------------------------------------------------------
1205
1206
1207Platform-Specific Notes
1208
1209This section documents additional platform-specific issues regarding the
1210installation and setup of PostgreSQL. Be sure to read the installation
1211instructions, and in particular the section called "Requirements" as
1212well. Also, check the file "src/test/regress/README" and the
1213documentation regarding the interpretation of regression test results.
1214
1215Platforms that are not covered here have no known platform-specific
1216installation issues.
1217
1218------------------------------------------------------------------------
1219
1220AIX
1221
1222PostgreSQL works on AIX, but AIX versions before about 6.1 have various
1223issues and are not recommended. You can use GCC or the native IBM
1224compiler "xlc".
1225
1226------------------------------------------------------------------------
1227
1228Memory Management
1229
1230AIX can be somewhat peculiar with regards to the way it does memory
1231management. You can have a server with many multiples of gigabytes of
1232RAM free, but still get out of memory or address space errors when
1233running applications. One example is loading of extensions failing with
1234unusual errors. For example, running as the owner of the PostgreSQL
1235installation:
1236
1237    =# CREATE EXTENSION plperl;
1238    ERROR:  could not load library "/opt/dbs/pgsql/lib/plperl.so": A memory address is not in the address space for the process.
1239
1240Running as a non-owner in the group possessing the PostgreSQL
1241installation:
1242
1243    =# CREATE EXTENSION plperl;
1244    ERROR:  could not load library "/opt/dbs/pgsql/lib/plperl.so": Bad address
1245
1246Another example is out of memory errors in the PostgreSQL server logs,
1247with every memory allocation near or greater than 256 MB failing.
1248
1249The overall cause of all these problems is the default bittedness and
1250memory model used by the server process. By default, all binaries built
1251on AIX are 32-bit. This does not depend upon hardware type or kernel in
1252use. These 32-bit processes are limited to 4 GB of memory laid out in
1253256 MB segments using one of a few models. The default allows for less
1254than 256 MB in the heap as it shares a single segment with the stack.
1255
1256In the case of the plperl example, above, check your umask and the
1257permissions of the binaries in your PostgreSQL installation. The
1258binaries involved in that example were 32-bit and installed as mode 750
1259instead of 755. Due to the permissions being set in this fashion, only
1260the owner or a member of the possessing group can load the library.
1261Since it isn't world-readable, the loader places the object into the
1262process' heap instead of the shared library segments where it would
1263otherwise be placed.
1264
1265The "ideal" solution for this is to use a 64-bit build of PostgreSQL,
1266but that is not always practical, because systems with 32-bit processors
1267can build, but not run, 64-bit binaries.
1268
1269If a 32-bit binary is desired, set LDR_CNTRL to MAXDATA=0xn0000000,
1270where 1 <= n <= 8, before starting the PostgreSQL server, and try
1271different values and "postgresql.conf" settings to find a configuration
1272that works satisfactorily. This use of LDR_CNTRL tells AIX that you want
1273the server to have MAXDATA bytes set aside for the heap, allocated in
1274256 MB segments. When you find a workable configuration, "ldedit" can be
1275used to modify the binaries so that they default to using the desired
1276heap size. PostgreSQL can also be rebuilt, passing
1277configure      LDFLAGS="-Wl,-bmaxdata:0xn0000000" to achieve the same
1278effect.
1279
1280For a 64-bit build, set OBJECT_MODE to 64 and pass CC="gcc -maix64" and
1281LDFLAGS="-Wl,-bbigtoc" to "configure". (Options for "xlc" might differ.)
1282If you omit the export of OBJECT_MODE, your build may fail with linker
1283errors. When OBJECT_MODE is set, it tells AIX's build utilities such as
1284"ar", "as", and "ld" what type of objects to default to handling.
1285
1286By default, overcommit of paging space can happen. While we have not
1287seen this occur, AIX will kill processes when it runs out of memory and
1288the overcommit is accessed. The closest to this that we have seen is
1289fork failing because the system decided that there was not enough memory
1290for another process. Like many other parts of AIX, the paging space
1291allocation method and out-of-memory kill is configurable on a system- or
1292process-wide basis if this becomes a problem.
1293
1294------------------------------------------------------------------------
1295
1296Cygwin
1297
1298PostgreSQL can be built using Cygwin, a Linux-like environment for
1299Windows, but that method is inferior to the native Windows build and
1300running a server under Cygwin is no longer recommended.
1301
1302When building from source, proceed according to the Unix-style
1303installation procedure (i.e., ./configure;     make; etc.), noting the
1304following Cygwin-specific differences:
1305
1306-   Set your path to use the Cygwin bin directory before the Windows
1307    utilities. This will help prevent problems with compilation.
1308
1309-   The "adduser" command is not supported; use the appropriate user
1310    management application on Windows NT, 2000, or XP. Otherwise, skip
1311    this step.
1312
1313-   The "su" command is not supported; use ssh to simulate su on Windows
1314    NT, 2000, or XP. Otherwise, skip this step.
1315
1316-   OpenSSL is not supported.
1317
1318-   Start "cygserver" for shared memory support. To do this, enter the
1319    command /usr/sbin/cygserver        &. This program needs to be
1320    running anytime you start the PostgreSQL server or initialize a
1321    database cluster ("initdb"). The default "cygserver" configuration
1322    may need to be changed (e.g., increase SEMMNS) to prevent PostgreSQL
1323    from failing due to a lack of system resources.
1324
1325-   Building might fail on some systems where a locale other than C is
1326    in use. To fix this, set the locale to C by doing "export
1327    LANG=C.utf8" before building, and then setting it back to the
1328    previous setting after you have installed PostgreSQL.
1329
1330-   The parallel regression tests (make check) can generate spurious
1331    regression test failures due to overflowing the listen() backlog
1332    queue which causes connection refused errors or hangs. You can limit
1333    the number of connections using the make variable MAX_CONNECTIONS
1334    thus:
1335
1336        make MAX_CONNECTIONS=5 check
1337
1338    (On some systems you can have up to about 10 simultaneous
1339    connections.)
1340
1341It is possible to install "cygserver" and the PostgreSQL server as
1342Windows NT services. For information on how to do this, please refer to
1343the "README" document included with the PostgreSQL binary package on
1344Cygwin. It is installed in the directory "/usr/share/doc/Cygwin".
1345
1346------------------------------------------------------------------------
1347
1348macOS
1349
1350To build PostgreSQL from source on macOS, you will need to install
1351Apple's command line developer tools, which can be done by issuing
1352
1353    xcode-select --install
1354
1355(note that this will pop up a GUI dialog window for confirmation). You
1356may or may not wish to also install Xcode.
1357
1358On recent macOS releases, it's necessary to embed the "sysroot" path in
1359the include switches used to find some system header files. This results
1360in the outputs of the configure script varying depending on which SDK
1361version was used during configure. That shouldn't pose any problem in
1362simple scenarios, but if you are trying to do something like building an
1363extension on a different machine than the server code was built on, you
1364may need to force use of a different sysroot path. To do that, set
1365PG_SYSROOT, for example
1366
1367    make PG_SYSROOT=/desired/path all
1368
1369To find out the appropriate path on your machine, run
1370
1371    xcrun --show-sdk-path
1372
1373Note that building an extension using a different sysroot version than
1374was used to build the core server is not really recommended; in the
1375worst case it could result in hard-to-debug ABI inconsistencies.
1376
1377You can also select a non-default sysroot path when configuring, by
1378specifying PG_SYSROOT to configure:
1379
1380    ./configure ... PG_SYSROOT=/desired/path
1381
1382This would primarily be useful to cross-compile for some other macOS
1383version. There is no guarantee that the resulting executables will run
1384on the current host.
1385
1386To suppress the "-isysroot" options altogether, use
1387
1388    ./configure ... PG_SYSROOT=none
1389
1390(any nonexistent pathname will work). This might be useful if you wish
1391to build with a non-Apple compiler, but beware that that case is not
1392tested or supported by the PostgreSQL developers.
1393
1394macOS's "System Integrity Protection" (SIP) feature breaks make check,
1395because it prevents passing the needed setting of DYLD_LIBRARY_PATH down
1396to the executables being tested. You can work around that by doing
1397make     install before make check. Most PostgreSQL developers just turn
1398off SIP, though.
1399
1400------------------------------------------------------------------------
1401
1402MinGW/Native Windows
1403
1404PostgreSQL for Windows can be built using MinGW, a Unix-like build
1405environment for Microsoft operating systems, or using Microsoft's Visual
1406C++ compiler suite. The MinGW build procedure uses the normal build
1407system described in this chapter; the Visual C++ build works completely
1408differently and is described in the documentation.
1409
1410The native Windows port requires a 32 or 64-bit version of Windows 2000
1411or later. Earlier operating systems do not have sufficient
1412infrastructure (but Cygwin may be used on those). MinGW, the Unix-like
1413build tools, and MSYS, a collection of Unix tools required to run shell
1414scripts like "configure", can be downloaded from http://www.mingw.org/.
1415Neither is required to run the resulting binaries; they are needed only
1416for creating the binaries.
1417
1418To build 64 bit binaries using MinGW, install the 64 bit tool set from
1419https://mingw-w64.org/, put its bin directory in the PATH, and run
1420"configure" with the "--host=x86_64-w64-mingw32" option.
1421
1422After you have everything installed, it is suggested that you run psql
1423under "CMD.EXE", as the MSYS console has buffering issues.
1424
1425------------------------------------------------------------------------
1426
1427Collecting Crash Dumps on Windows
1428
1429If PostgreSQL on Windows crashes, it has the ability to generate
1430minidumps that can be used to track down the cause for the crash,
1431similar to core dumps on Unix. These dumps can be read using the Windows
1432Debugger Tools or using Visual Studio. To enable the generation of dumps
1433on Windows, create a subdirectory named "crashdumps" inside the cluster
1434data directory. The dumps will then be written into this directory with
1435a unique name based on the identifier of the crashing process and the
1436current time of the crash.
1437
1438------------------------------------------------------------------------
1439
1440Solaris
1441
1442PostgreSQL is well-supported on Solaris. The more up to date your
1443operating system, the fewer issues you will experience.
1444
1445------------------------------------------------------------------------
1446
1447Required Tools
1448
1449You can build with either GCC or Sun's compiler suite. For better code
1450optimization, Sun's compiler is strongly recommended on the SPARC
1451architecture. If you are using Sun's compiler, be careful not to select
1452"/usr/ucb/cc"; use "/opt/SUNWspro/bin/cc".
1453
1454You can download Sun Studio from
1455https://www.oracle.com/technetwork/server-storage/solarisstudio/downloads/.
1456Many GNU tools are integrated into Solaris 10, or they are present on
1457the Solaris companion CD. If you need packages for older versions of
1458Solaris, you can find these tools at http://www.sunfreeware.com. If you
1459prefer sources, look at https://www.gnu.org/prep/ftp.
1460
1461------------------------------------------------------------------------
1462
1463configure Complains About a Failed Test Program
1464
1465If "configure" complains about a failed test program, this is probably a
1466case of the run-time linker being unable to find some library, probably
1467libz, libreadline or some other non-standard library such as libssl. To
1468point it to the right location, set the LDFLAGS environment variable on
1469the "configure" command line, e.g.,
1470
1471    configure ... LDFLAGS="-R /usr/sfw/lib:/opt/sfw/lib:/usr/local/lib"
1472
1473See the ld man page for more information.
1474
1475------------------------------------------------------------------------
1476
1477Compiling for Optimal Performance
1478
1479On the SPARC architecture, Sun Studio is strongly recommended for
1480compilation. Try using the "-xO5" optimization flag to generate
1481significantly faster binaries. Do not use any flags that modify behavior
1482of floating-point operations and errno processing (e.g., "-fast").
1483
1484If you do not have a reason to use 64-bit binaries on SPARC, prefer the
148532-bit version. The 64-bit operations are slower and 64-bit binaries are
1486slower than the 32-bit variants. On the other hand, 32-bit code on the
1487AMD64 CPU family is not native, so 32-bit code is significantly slower
1488on that CPU family.
1489
1490------------------------------------------------------------------------
1491
1492Using DTrace for Tracing PostgreSQL
1493
1494Yes, using DTrace is possible. See the documentation for further
1495information.
1496
1497If you see the linking of the "postgres" executable abort with an error
1498message like:
1499
1500    Undefined                       first referenced
1501     symbol                             in file
1502    AbortTransaction                    utils/probes.o
1503    CommitTransaction                   utils/probes.o
1504    ld: fatal: Symbol referencing errors. No output written to postgres
1505    collect2: ld returned 1 exit status
1506    make: *** [postgres] Error 1
1507
1508your DTrace installation is too old to handle probes in static
1509functions. You need Solaris 10u4 or newer to use DTrace.
1510