postgresql/src/tools/msvc
Tom Lane 02a6a54ecd Make use of compiler builtins and/or assembly for CLZ, CTZ, POPCNT.
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
2019-02-15 23:22:33 -05:00
..
dummylib perltidy run prior to branching 2018-06-30 12:28:55 -04:00
.gitignore Ignore config.pl and buildenv.pl in src/tools/msvc. 2014-05-12 14:24:18 -04:00
build.bat Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
build.pl Unify searchpath and do file logic in MSVC build scripts. 2019-02-06 07:36:02 -05:00
clean.bat Replace the data structure used for keyword lookup. 2019-01-06 17:02:57 -05:00
config_default.pl Fix typo in comment 2017-11-27 09:24:14 +01:00
ecpg_regression.proj Fix msvc/ecpg_regression.proj for recent ECPG test additions. 2018-03-15 22:36:19 -04:00
gendef.pl Don't fall off the end of perl functions 2018-05-27 09:08:42 -04:00
install.bat Turn install.bat into a pure one line wrapper fort he perl script. 2015-07-06 22:18:26 +03:00
install.pl Fix included file path for modern perl 2019-02-05 19:27:47 -05:00
Install.pm Fix included file path for modern perl 2019-02-05 19:27:47 -05:00
mkvcbuild.pl Fix included file path for modern perl 2019-02-05 19:27:47 -05:00
Mkvcbuild.pm Make use of compiler builtins and/or assembly for CLZ, CTZ, POPCNT. 2019-02-15 23:22:33 -05:00
MSBuildProject.pm Require C99 (and thus MSCV 2013 upwards). 2018-08-23 18:33:57 -07:00
pgbison.bat Fix comments over eagerly c&p'd. 2011-07-07 03:53:49 -04:00
pgbison.pl Fix included file path for modern perl 2019-02-05 19:27:47 -05:00
pgflex.bat Fix comments over eagerly c&p'd. 2011-07-07 03:53:49 -04:00
pgflex.pl Fix included file path for modern perl 2019-02-05 19:27:47 -05:00
Project.pm Fix compile-time warnings on all perl code 2018-05-31 08:13:02 -04:00
README Require C99 (and thus MSCV 2013 upwards). 2018-08-23 18:33:57 -07:00
Solution.pm Blind attempt at fixing Windows build 2019-02-12 18:29:26 -03:00
vcregress.bat Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
vcregress.pl Fix included file path for modern perl 2019-02-05 19:27:47 -05:00
VSObjectFactory.pm Require C99 (and thus MSCV 2013 upwards). 2018-08-23 18:33:57 -07:00

src/tools/msvc/README

MSVC build
==========

This directory contains the tools required to build PostgreSQL using
Microsoft Visual Studio 2013 - 2017. This builds the whole backend, not just
the libpq frontend library. For more information, see the documentation
chapter "Installation on Windows" and the description below.


Notes about Visual Studio Express
---------------------------------
To build PostgreSQL using Visual Studio Express, the Microsoft Windows SDK
has to be installed. Since this is not included in the product
originally, extra steps are needed to make it work.

First, download and install a supported version of the Microsoft Windows SDK
from www.microsoft.com (v6.0 or greater).

Locate the files vcprojectengine.dll.express.config and
vcprojectengine.dll.config in the vc\vcpackages directory of
the Visual C++ Express installation. In these files, add the paths
to the Platform SDK to the Include, Library and Path tags. Be sure
to add them to the beginning of the list.

This should work for both GUI and commandline builds, but a restart
may be necessary.

If you are using a recent version of the Microsoft Windows SDK that includes
the compilers and build tools you probably don't even need Visual Studio
Express to build PostgreSQL.


Structure of the build tools
----------------------------
The tools for building PostgreSQL using Microsoft Visual Studio currently
consist of the following files:

- Configuration files -
config_default.pl      default configuration arguments

A typical build environment has two more files, buildenv.pl and config.pl
that contain the user's build environment settings and configuration
arguments.


- User tools -
build.pl               tool to build the binaries
clean.bat              batch file for cleaning up generated files
install.pl             tool to install the generated files
mkvcbuild.pl           tool to generate the Visual Studio build files
vcregress.pl           tool to run the regression tests


- Internal tools -
gendef.pl              internal tool to generate .DEF files
pgbison.pl             internal tool to process .y files using bison
pgflex.pl              internal tool to process .l files using flex

Many of those .pl files also have a corresponding .bat-wrapper that doesn't
contain any additional logic.


- Internal modules -
Install.pm             module containing the install logic
Mkvcbuild.pm           module containing the code to generate the Visual
                       Studio build (project/solution) files
MSBuildProject.pm      module containing the code to generate MSBuild based
                       project files (Visual Studio 2013 or greater)
Project.pm             module containing the common code to generate the
                       Visual Studio project files. Also provides the
                       common interface of all project file generators
Solution.pm            module containing the code to generate the Visual
                       Studio solution files.
VSObjectFactory.pm     factory module providing the code to create the
                       appropriate project/solution files for the current
                       environment


Description of the internals of the Visual Studio build process
---------------------------------------------------------------
By typing 'build' the user starts the build.bat wrapper which simply passes
it's arguments to build.pl.
In build.pl the user's buildenv.pl is used to set up the build environment
(i. e. path to bison and flex). In addition his config.pl file is merged into
config_default.pl to create the configuration arguments.
These configuration arguments are passed over to Mkvcbuild::mkvcbuild
(Mkvcbuild.pm) which creates the Visual Studio project and solution files.
It does this by using VSObjectFactory::CreateSolution to create an object
implementing the Solution interface (this could be either a VS2013Solution,
or a VS2015Solution or a VS2017Solution, all in Solution.pm, depending on
the user's build environment) and adding objects implementing the corresponding
Project interface (VC2013Project or VC2015Project or VC2017Project from
MSBuildProject.pm) to it.
When Solution::Save is called, the implementations of Solution and Project
save their content in the appropriate format.
The final step of starting the appropriate build program (msbuild) is
performed in build.pl again.