fi
+
+# Error out if the compiler does not support C99, as the codebase
+# relies on that.
+if test "$ac_cv_prog_cc_c99" = no; then
+ as_fn_error $? "C compiler \"$CC\" does not support C99" "$LINENO" 5
+fi
+
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
# -Wdeclaration-after-statement isn't applicable for C++
+ # Really don't want VLAs to be used in our dialect of C
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Werror=vla, for CFLAGS" >&5
+$as_echo_n "checking whether ${CC} supports -Werror=vla, for CFLAGS... " >&6; }
+if ${pgac_cv_prog_CC_cflags__Werror_vla+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ pgac_save_CFLAGS=$CFLAGS
+pgac_save_CC=$CC
+CC=${CC}
+CFLAGS="${CFLAGS} -Werror=vla"
+ac_save_c_werror_flag=$ac_c_werror_flag
+ac_c_werror_flag=yes
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ pgac_cv_prog_CC_cflags__Werror_vla=yes
+else
+ pgac_cv_prog_CC_cflags__Werror_vla=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_c_werror_flag=$ac_save_c_werror_flag
+CFLAGS="$pgac_save_CFLAGS"
+CC="$pgac_save_CC"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__Werror_vla" >&5
+$as_echo "$pgac_cv_prog_CC_cflags__Werror_vla" >&6; }
+if test x"$pgac_cv_prog_CC_cflags__Werror_vla" = x"yes"; then
+ CFLAGS="${CFLAGS} -Werror=vla"
+fi
+
+
+ # -Wvla is not applicable for C++
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wendif-labels, for CFLAGS" >&5
$as_echo_n "checking whether ${CC} supports -Wendif-labels, for CFLAGS... " >&6; }
AC_PROG_CC([$pgac_cc_list])
AC_PROG_CC_C99()
+
+# Error out if the compiler does not support C99, as the codebase
+# relies on that.
+if test "$ac_cv_prog_cc_c99" = no; then
+ AC_MSG_ERROR([C compiler "$CC" does not support C99])
+fi
+
AC_PROG_CXX([$pgac_cxx_list])
# Check if it's Intel's compiler, which (usually) pretends to be gcc,
# These work in some but not all gcc versions
PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
# -Wdeclaration-after-statement isn't applicable for C++
+ # Really don't want VLAs to be used in our dialect of C
+ PGAC_PROG_CC_CFLAGS_OPT([-Werror=vla])
+ # -Wvla is not applicable for C++
PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
PGAC_PROG_CXX_CFLAGS_OPT([-Wendif-labels])
PGAC_PROG_CC_CFLAGS_OPT([-Wmissing-format-attribute])
C Standard
Code in
PostgreSQL should only rely on language
- features available in the C89 standard. That means a conforming
- C89 compiler has to be able to compile postgres, at least aside
- from a few platform dependent pieces. Features from later
- revision of the C standard or compiler specific features can be
- used, if a fallback is provided.
-
- For example static inline and
- _StaticAssert() are currently used, even
- though they are from newer revisions of the C standard. If not
- available we respectively fall back to defining the functions
- without inline, and to using a C89 compatible replacement that
- performs the same checks, but emits rather cryptic messages.
+ features available in the C99 standard. That means a conforming
+ C99 compiler has to be able to compile postgres, at least aside
+ from a few platform dependent pieces.
+
+ A few features included in the C99 standard are, at this time, not be
+ permitted to be used in core
PostgreSQL
+ code. This currently includes variable length arrays, intermingled
+ declarations and code, // comments, universal
+ character names. Reasons for that include portability and historical
+ practices.
+
+ Features from later revision of the C standard or compiler specific
+ features can be used, if a fallback is provided.
+
+ For example _StaticAssert() and
+ __builtin_constant_p are currently used, even though
+ they are from newer revisions of the C standard and a
+
GCC extension respectively. If not available
+ we respectively fall back to using a C99 compatible replacement that
+ performs the same checks, but emits rather cryptic messages and do not
+ use __builtin_constant_p.
package MSBuildProject;
#
-# Package that encapsulates a MSBuild project file (Visual C++ 2010 or greater)
+# Package that encapsulates a MSBuild project file (Visual C++ 2013 or greater)
#
# src/tools/msvc/MSBuildProject.pm
#
false
MultiByte
$p->{wholeopt}
+
$self->{PlatformToolset}
EOF
return;
return;
}
-package VC2010Project;
-
-#
-# Package that encapsulates a Visual C++ 2010 project file
-#
-
-use strict;
-use warnings;
-use base qw(MSBuildProject);
-
-no warnings qw(redefine); ## no critic
-
-sub new
-{
- my $classname = shift;
- my $self = $classname->SUPER::_new(@_);
- bless($self, $classname);
-
- $self->{vcver} = '10.00';
-
- return $self;
-}
-
-package VC2012Project;
-
-#
-# Package that encapsulates a Visual C++ 2012 project file
-#
-
-use strict;
-use warnings;
-use base qw(MSBuildProject);
-
-no warnings qw(redefine); ## no critic
-
-sub new
-{
- my $classname = shift;
- my $self = $classname->SUPER::_new(@_);
- bless($self, $classname);
-
- $self->{vcver} = '11.00';
- $self->{PlatformToolset} = 'v110';
-
- return $self;
-}
-
-# This override adds the
element
-# to the PropertyGroup labeled "Configuration"
-sub WriteConfigurationPropertyGroup
-{
- my ($self, $f, $cfgname, $p) = @_;
- my $cfgtype =
- ($self->{type} eq "exe")
- ? 'Application'
- : ($self->{type} eq "dll" ? 'DynamicLibrary' : 'StaticLibrary');
-
- print $f <
-
{platform}'" Label="Configuration">
- $cfgtype
- false
- MultiByte
- $p->{wholeopt}
-
$self->{PlatformToolset}
-
-EOF
- return;
-}
-
package VC2013Project;
#
use strict;
use warnings;
-use base qw(VC2012Project);
+use base qw(MSBuildProject);
no warnings qw(redefine); ## no critic
use strict;
use warnings;
-use base qw(VC2012Project);
+use base qw(MSBuildProject);
no warnings qw(redefine); ## no critic
use strict;
use warnings;
-use base qw(VC2012Project);
+use base qw(MSBuildProject);
no warnings qw(redefine); ## no critic
==========
This directory contains the tools required to build PostgreSQL using
-Microsoft Visual Studio 2005 - 2017. This builds the whole backend, not just
+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.
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 2010 or greater)
+ 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.
-VCBuildProject.pm module containing the code to generate VCBuild based
- project files (Visual Studio 2005/2008)
VSObjectFactory.pm factory module providing the code to create the
appropriate project/solution files for the current
environment
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 VS2005Solution,
-a VS2008Solution, a VS2010Solution or a VS2012Solution or a VS2013Solution,
+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 (VC2005Project or VC2008Project from VCBuildProject.pm or
-VC2010Project or VC2012Project or VC2013Project or VC2015Project or VC2017Project
-from MSBuildProject.pm) to it.
+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 or vcbuild)
-is performed in build.pl again.
+The final step of starting the appropriate build program (msbuild) is
+performed in build.pl again.
return $cfg;
}
-package VS2005Solution;
-
-#
-# Package that encapsulates a Visual Studio 2005 solution file
-#
-
-use strict;
-use warnings;
-use base qw(Solution);
-
-no warnings qw(redefine); ## no critic
-
-sub new
-{
- my $classname = shift;
- my $self = $classname->SUPER::_new(@_);
- bless($self, $classname);
-
- $self->{solutionFileVersion} = '9.00';
- $self->{vcver} = '8.00';
- $self->{visualStudioName} = 'Visual Studio 2005';
-
- return $self;
-}
-
-package VS2008Solution;
-
-#
-# Package that encapsulates a Visual Studio 2008 solution file
-#
-
-use strict;
-use warnings;
-use base qw(Solution);
-
-no warnings qw(redefine); ## no critic
-
-sub new
-{
- my $classname = shift;
- my $self = $classname->SUPER::_new(@_);
- bless($self, $classname);
-
- $self->{solutionFileVersion} = '10.00';
- $self->{vcver} = '9.00';
- $self->{visualStudioName} = 'Visual Studio 2008';
-
- return $self;
-}
-
-package VS2010Solution;
-
-#
-# Package that encapsulates a Visual Studio 2010 solution file
-#
-
-use Carp;
-use strict;
-use warnings;
-use base qw(Solution);
-
-no warnings qw(redefine); ## no critic
-
-sub new
-{
- my $classname = shift;
- my $self = $classname->SUPER::_new(@_);
- bless($self, $classname);
-
- $self->{solutionFileVersion} = '11.00';
- $self->{vcver} = '10.00';
- $self->{visualStudioName} = 'Visual Studio 2010';
-
- return $self;
-}
-
-package VS2012Solution;
-
-#
-# Package that encapsulates a Visual Studio 2012 solution file
-#
-
-use Carp;
-use strict;
-use warnings;
-use base qw(Solution);
-
-no warnings qw(redefine); ## no critic
-
-sub new
-{
- my $classname = shift;
- my $self = $classname->SUPER::_new(@_);
- bless($self, $classname);
-
- $self->{solutionFileVersion} = '12.00';
- $self->{vcver} = '11.00';
- $self->{visualStudioName} = 'Visual Studio 2012';
-
- return $self;
-}
-
package VS2013Solution;
#
+++ /dev/null
-package VCBuildProject;
-
-#
-# Package that encapsulates a VCBuild (Visual C++ 2005/2008) project file
-#
-# src/tools/msvc/VCBuildProject.pm
-#
-
-use Carp;
-use strict;
-use warnings;
-use base qw(Project);
-
-no warnings qw(redefine); ## no critic
-
-sub _new
-{
- my $classname = shift;
- my $self = $classname->SUPER::_new(@_);
- bless($self, $classname);
-
- $self->{filenameExtension} = '.vcproj';
-
- return $self;
-}
-
-sub WriteHeader
-{
- my ($self, $f) = @_;
-
- print $f <
-
-{vcver}" Name="$self->{name}" ProjectGUID="$self->{guid}">
-
-EOF
-
- $self->WriteConfiguration(
- $f, 'Debug',
- {
- defs => "_DEBUG;DEBUG=1",
- wholeopt => 0,
- opt => 0,
- strpool => 'false',
- runtime => 3
- });
- $self->WriteConfiguration(
- $f,
- 'Release',
- {
- defs => "",
- wholeopt => 0,
- opt => 3,
- strpool => 'true',
- runtime => 2
- });
- print $f <
-
-EOF
- $self->WriteReferences($f);
- return;
-}
-
-sub WriteFiles
-{
- my ($self, $f) = @_;
- print $f <
-
-EOF
- my @dirstack = ();
- my %uniquefiles;
- foreach my $fileNameWithPath (sort keys %{ $self->{files} })
- {
- confess "Bad format filename '$fileNameWithPath'\n"
- unless ($fileNameWithPath =~ m!^(.*)/([^/]+)\.(c|cpp|y|l|rc)$!);
- my $dir = $1;
- my $file = $2;
-
- # Walk backwards down the directory stack and close any dirs
- # we're done with.
- while ($#dirstack >= 0)
- {
- if (join('/', @dirstack) eq
- substr($dir, 0, length(join('/', @dirstack))))
- {
- last if (length($dir) == length(join('/', @dirstack)));
- last
- if (substr($dir, length(join('/', @dirstack)), 1) eq '/');
- }
- print $f ' ' x $#dirstack . " \n";
- pop @dirstack;
- }
-
- # Now walk forwards and create whatever directories are needed
- while (join('/', @dirstack) ne $dir)
- {
- my $left = substr($dir, length(join('/', @dirstack)));
- $left =~ s/^\///;
- my @pieces = split /\//, $left;
- push @dirstack, $pieces[0];
- print $f ' ' x $#dirstack
- . " \n";
- }
-
- # VC builds do not like file paths with forward slashes.
- my $fileNameWithPathFormatted = $fileNameWithPath;
- $fileNameWithPathFormatted =~ s/\//\\/g;
-
- print $f ' ' x $#dirstack
- . "
- if ($fileNameWithPath =~ /\.y$/)
- {
- my $of = $fileNameWithPath;
- $of =~ s/\.y$/.c/;
- $of =~
- s{^src/pl/plpgsql/src/gram.c$}{src/pl/plpgsql/src/pl_gram.c};
- print $f '>'
- . $self->GenerateCustomTool(
- 'Running bison on ' . $fileNameWithPath,
- "perl src/tools/msvc/pgbison.pl $fileNameWithPath", $of)
- . '' . "\n";
- }
- elsif ($fileNameWithPath =~ /\.l$/)
- {
- my $of = $fileNameWithPath;
- $of =~ s/\.l$/.c/;
- print $f '>'
- . $self->GenerateCustomTool(
- 'Running flex on ' . $fileNameWithPath,
- "perl src/tools/msvc/pgflex.pl $fileNameWithPath", $of)
- . '' . "\n";
- }
- elsif (defined($uniquefiles{$file}))
- {
-
- # File already exists, so fake a new name
- my $obj = $dir;
- $obj =~ s!/!_!g;
- print $f
- ">{platform}\">{name}\\$obj"
- . "_$file.obj\" />{platform}\">{name}\\$obj"
- . "_$file.obj\" />\n";
- }
- else
- {
- $uniquefiles{$file} = 1;
- print $f " />\n";
- }
- }
- while ($#dirstack >= 0)
- {
- print $f ' ' x $#dirstack . " \n";
- pop @dirstack;
- }
- print $f <
-
-EOF
- return;
-}
-
-sub Footer
-{
- my ($self, $f) = @_;
-
- print $f <
-
-
-EOF
- return;
-}
-
-sub WriteConfiguration
-{
- my ($self, $f, $cfgname, $p) = @_;
- my $cfgtype =
- ($self->{type} eq "exe") ? 1 : ($self->{type} eq "dll" ? 2 : 4);
- my $libs = $self->GetAdditionalLinkerDependencies($cfgname, ' ');
-
- my $targetmachine = $self->{platform} eq 'Win32' ? 1 : 17;
-
- print $f <
- {platform}" OutputDirectory=".\\$cfgname\\$self->{name}" IntermediateDirectory=".\\$cfgname\\$self->{name}"
- ConfigurationType="$cfgtype" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2" WholeProgramOptimization="$p->{wholeopt}">
- {opt}"
- AdditionalIncludeDirectories="$self->{prefixincludes}src/include;src/include/port/win32;src/include/port/win32_msvc;$self->{includes}"
- PreprocessorDefinitions="WIN32;_WINDOWS;__WINDOWS__;__WIN32__;EXEC_BACKEND;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE$self->{defines}$p->{defs}"
- StringPooling="$p->{strpool}"
- RuntimeLibrary="$p->{runtime}" DisableSpecificWarnings="$self->{disablewarnings}"
- AdditionalOptions="/MP"
-EOF
- print $f <
- AssemblerOutput="0" AssemblerListingLocation=".\\$cfgname\\$self->{name}\\" ObjectFile=".\\$cfgname\\$self->{name}\\"
- ProgramDataBaseFileName=".\\$cfgname\\$self->{name}\\" BrowseInformation="0"
- WarningLevel="3" SuppressStartupBanner="TRUE" DebugInformationFormat="3" CompileAs="0"/>
- {name}\\$self->{name}.$self->{type}"
- AdditionalDependencies="$libs"
- LinkIncremental="0" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="" IgnoreDefaultLibraryNames="libc"
- StackReserveSize="4194304" DisableSpecificWarnings="$self->{disablewarnings}"
- GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\\$cfgname\\$self->{name}\\$self->{name}.pdb"
- GenerateMapFile="FALSE" MapFileName=".\\$cfgname\\$self->{name}\\$self->{name}.map"
- RandomizedBaseAddress="FALSE"
- SubSystem="1" TargetMachine="$targetmachine"
-EOF
- if ($self->{disablelinkerwarnings})
- {
- print $f
- "\t\tAdditionalOptions=\"/ignore:$self->{disablelinkerwarnings}\"\n";
- }
- if ($self->{implib})
- {
- my $l = $self->{implib};
- $l =~ s/__CFGNAME__/$cfgname/g;
- print $f "\t\tImportLibrary=\"$l\"\n";
- }
- if ($self->{def})
- {
- my $d = $self->{def};
- $d =~ s/__CFGNAME__/$cfgname/g;
- print $f "\t\tModuleDefinitionFile=\"$d\"\n";
- }
-
- print $f "\t/>\n";
- print $f
- "\t{name}\\$self->{name}.lib\" IgnoreDefaultLibraryNames=\"libc\" />\n";
- print $f
- "\t\n";
- if ($self->{builddef})
- {
- print $f
- "\t{name} $self->{platform}\" />\n";
- }
- print $f <
-
-EOF
- return;
-}
-
-sub WriteReferences
-{
- my ($self, $f) = @_;
- print $f " \n";
- foreach my $ref (@{ $self->{references} })
- {
- print $f
- "
{guid}\" Name=\"$ref->{name}\" />\n";
- }
- print $f " \n";
- return;
-}
-
-sub GenerateCustomTool
-{
- my ($self, $desc, $tool, $output, $cfg) = @_;
- if (!defined($cfg))
- {
- return $self->GenerateCustomTool($desc, $tool, $output, 'Debug')
- . $self->GenerateCustomTool($desc, $tool, $output, 'Release');
- }
- return
- "{platform}\">";
-}
-
-package VC2005Project;
-
-#
-# Package that encapsulates a Visual C++ 2005 project file
-#
-
-use strict;
-use warnings;
-use base qw(VCBuildProject);
-
-no warnings qw(redefine); ## no critic
-
-sub new
-{
- my $classname = shift;
- my $self = $classname->SUPER::_new(@_);
- bless($self, $classname);
-
- $self->{vcver} = '8.00';
-
- return $self;
-}
-
-package VC2008Project;
-
-#
-# Package that encapsulates a Visual C++ 2008 project file
-#
-
-use strict;
-use warnings;
-use base qw(VCBuildProject);
-
-no warnings qw(redefine); ## no critic
-
-sub new
-{
- my $classname = shift;
- my $self = $classname->SUPER::_new(@_);
- bless($self, $classname);
-
- $self->{vcver} = '9.00';
-
- return $self;
-}
-
-1;
use Exporter;
use Project;
use Solution;
-use VCBuildProject;
use MSBuildProject;
our (@ISA, @EXPORT);
$visualStudioVersion = DetermineVisualStudioVersion();
}
- if ($visualStudioVersion eq '8.00')
- {
- return new VS2005Solution(@_);
- }
- elsif ($visualStudioVersion eq '9.00')
- {
- return new VS2008Solution(@_);
- }
- elsif ($visualStudioVersion eq '10.00')
- {
- return new VS2010Solution(@_);
- }
- elsif ($visualStudioVersion eq '11.00')
- {
- return new VS2012Solution(@_);
- }
- elsif ($visualStudioVersion eq '12.00')
+ if ($visualStudioVersion eq '12.00')
{
return new VS2013Solution(@_);
}
$visualStudioVersion = DetermineVisualStudioVersion();
}
- if ($visualStudioVersion eq '8.00')
- {
- return new VC2005Project(@_);
- }
- elsif ($visualStudioVersion eq '9.00')
- {
- return new VC2008Project(@_);
- }
- elsif ($visualStudioVersion eq '10.00')
- {
- return new VC2010Project(@_);
- }
- elsif ($visualStudioVersion eq '11.00')
- {
- return new VC2012Project(@_);
- }
- elsif ($visualStudioVersion eq '12.00')
+ if ($visualStudioVersion eq '12.00')
{
return new VC2013Project(@_);
}
# ... and do it
-if ($buildwhat and $vcver >= 10.00)
+if ($buildwhat)
{
system(
"msbuild $buildwhat.vcxproj /verbosity:normal $msbflags /p:Configuration=$bconf"
);
}
-elsif ($buildwhat)
-{
- system("vcbuild $msbflags $buildwhat.vcproj $bconf");
-}
else
{
system(