Thread: window build doesn't apply PG_CPPFLAGS correctly

window build doesn't apply PG_CPPFLAGS correctly

From
Pavel Stehule
Date:
Hi

I tried to write test for plpgsql debug API, where I need to access to plpgsql.h

I have line

PG_CPPFLAGS = -I$(top_srcdir)/src/pl/plpgsql/src

that is working well on unix, but it do nothing on windows

[00:05:14] Project "C:\projects\postgresql\pgsql.sln" (1) is building "C:\projects\postgresql\test_dbgapi.vcxproj" (87) on node 1 (default targets).
[00:05:14] PrepareForBuild:
[00:05:14]   Creating directory ".\Release\test_dbgapi\".
[00:05:14]   Creating directory ".\Release\test_dbgapi\test_dbgapi.tlog\".
[00:05:14] InitializeBuildStatus:
[00:05:14]   Creating ".\Release\test_dbgapi\test_dbgapi.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
[00:05:14] ClCompile:
[00:05:14]   C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\CL.exe /c /Isrc/include /Isrc/include/port/win32 /Isrc/include/port/win32_msvc /Zi /nologo /W3 /WX- /Ox /D WIN32 /D _WINDOWS /D __WINDOWS__ /D __WIN32__ /D WIN32_STACK_RLIMIT=4194304 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _WINDLL /D _MBCS /GF /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo".\Release\test_dbgapi\\" /Fd".\Release\test_dbgapi\vc120.pdb" /Gd /TC /wd4018 /wd4244 /wd4273 /wd4102 /wd4090 /wd4267 /errorReport:queue /MP src/test/modules/test_dbgapi/test_dbgapi.c
[00:05:14]   test_dbgapi.c
[00:05:16] src/test/modules/test_dbgapi/test_dbgapi.c(17): fatal error C1083: Cannot open include file: 'plpgsql.h': No such file or directory [C:\projects\postgresql\test_dbgapi.vcxproj]
[00:05:16] Done Building Project "C:\projects\postgresql\test_dbgapi.vcxproj" (default targets) -- FAILED.
[00:05:16] Project "C:\projects\postgresql\pgsql.sln" (1) is building "C:\projects\postgresql\test_ddl_deparse.vcxproj" (88) on node 1 (default targets).

looks so PG_CPPFLAGS is not propagated to CPPFLAGS there.

Regards

Pavel


Re: window build doesn't apply PG_CPPFLAGS correctly

From
Andrew Dunstan
Date:
On 7/22/21 12:06 AM, Pavel Stehule wrote:
> Hi
>
> I tried to write test for plpgsql debug API, where I need to access to
> plpgsql.h
>
> I have line
>
> PG_CPPFLAGS = -I$(top_srcdir)/src/pl/plpgsql/src
>
> that is working well on unix, but it do nothing on windows
>
> [00:05:14] Project "C:\projects\postgresql\pgsql.sln" (1) is building
> "C:\projects\postgresql\test_dbgapi.vcxproj" (87) on node 1 (default
> targets).
> [00:05:14] PrepareForBuild:
> [00:05:14]   Creating directory ".\Release\test_dbgapi\".
> [00:05:14]   Creating directory ".\Release\test_dbgapi\test_dbgapi.tlog\".
> [00:05:14] InitializeBuildStatus:
> [00:05:14]   Creating
> ".\Release\test_dbgapi\test_dbgapi.tlog\unsuccessfulbuild" because
> "AlwaysCreate" was specified.
> [00:05:14] ClCompile:
> [00:05:14]   C:\Program Files (x86)\Microsoft Visual Studio
> 12.0\VC\bin\x86_amd64\CL.exe /c /Isrc/include /Isrc/include/port/win32
> /Isrc/include/port/win32_msvc /Zi /nologo /W3 /WX- /Ox /D WIN32 /D
> _WINDOWS /D __WINDOWS__ /D __WIN32__ /D WIN32_STACK_RLIMIT=4194304 /D
> _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _WINDLL /D
> _MBCS /GF /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope
> /Fo".\Release\test_dbgapi\\" /Fd".\Release\test_dbgapi\vc120.pdb" /Gd
> /TC /wd4018 /wd4244 /wd4273 /wd4102 /wd4090 /wd4267 /errorReport:queue
> /MP src/test/modules/test_dbgapi/test_dbgapi.c
> [00:05:14]   test_dbgapi.c
> [00:05:16] src/test/modules/test_dbgapi/test_dbgapi.c(17): fatal error
> C1083: Cannot open include file: 'plpgsql.h': No such file or
> directory [C:\projects\postgresql\test_dbgapi.vcxproj]
> [00:05:16] Done Building Project
> "C:\projects\postgresql\test_dbgapi.vcxproj" (default targets) -- FAILED.
> [00:05:16] Project "C:\projects\postgresql\pgsql.sln" (1) is building
> "C:\projects\postgresql\test_ddl_deparse.vcxproj" (88) on node 1
> (default targets).
>
> looks so PG_CPPFLAGS is not propagated to CPPFLAGS there.
>
>

Almost everything in the Makefiles is not used by the MSVC buid system.
Using this one seems likely to be quite difficult, since the syntax for
the MSVC compiler command line is very different, and furthermore the
MSVC build system doesn't know anything about how to use this setting.

AFAICT PG_CPPFLAGS is only used by pgxs.

You would need to tell us more about how your build process is working.


cheers


andrew



--
Andrew Dunstan
EDB: https://www.enterprisedb.com




Re: window build doesn't apply PG_CPPFLAGS correctly

From
Pavel Stehule
Date:


čt 22. 7. 2021 v 14:04 odesílatel Andrew Dunstan <andrew@dunslane.net> napsal:

On 7/22/21 12:06 AM, Pavel Stehule wrote:
> Hi
>
> I tried to write test for plpgsql debug API, where I need to access to
> plpgsql.h
>
> I have line
>
> PG_CPPFLAGS = -I$(top_srcdir)/src/pl/plpgsql/src
>
> that is working well on unix, but it do nothing on windows
>
> [00:05:14] Project "C:\projects\postgresql\pgsql.sln" (1) is building
> "C:\projects\postgresql\test_dbgapi.vcxproj" (87) on node 1 (default
> targets).
> [00:05:14] PrepareForBuild:
> [00:05:14]   Creating directory ".\Release\test_dbgapi\".
> [00:05:14]   Creating directory ".\Release\test_dbgapi\test_dbgapi.tlog\".
> [00:05:14] InitializeBuildStatus:
> [00:05:14]   Creating
> ".\Release\test_dbgapi\test_dbgapi.tlog\unsuccessfulbuild" because
> "AlwaysCreate" was specified.
> [00:05:14] ClCompile:
> [00:05:14]   C:\Program Files (x86)\Microsoft Visual Studio
> 12.0\VC\bin\x86_amd64\CL.exe /c /Isrc/include /Isrc/include/port/win32
> /Isrc/include/port/win32_msvc /Zi /nologo /W3 /WX- /Ox /D WIN32 /D
> _WINDOWS /D __WINDOWS__ /D __WIN32__ /D WIN32_STACK_RLIMIT=4194304 /D
> _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _WINDLL /D
> _MBCS /GF /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope
> /Fo".\Release\test_dbgapi\\" /Fd".\Release\test_dbgapi\vc120.pdb" /Gd
> /TC /wd4018 /wd4244 /wd4273 /wd4102 /wd4090 /wd4267 /errorReport:queue
> /MP src/test/modules/test_dbgapi/test_dbgapi.c
> [00:05:14]   test_dbgapi.c
> [00:05:16] src/test/modules/test_dbgapi/test_dbgapi.c(17): fatal error
> C1083: Cannot open include file: 'plpgsql.h': No such file or
> directory [C:\projects\postgresql\test_dbgapi.vcxproj]
> [00:05:16] Done Building Project
> "C:\projects\postgresql\test_dbgapi.vcxproj" (default targets) -- FAILED.
> [00:05:16] Project "C:\projects\postgresql\pgsql.sln" (1) is building
> "C:\projects\postgresql\test_ddl_deparse.vcxproj" (88) on node 1
> (default targets).
>
> looks so PG_CPPFLAGS is not propagated to CPPFLAGS there.
>
>

Almost everything in the Makefiles is not used by the MSVC buid system.
Using this one seems likely to be quite difficult, since the syntax for
the MSVC compiler command line is very different, and furthermore the
MSVC build system doesn't know anything about how to use this setting.

AFAICT PG_CPPFLAGS is only used by pgxs.

You would need to tell us more about how your build process is working.

I need access to plpgsql.h in build time. This is only one dependency. When I build an extension, then plpgsql.h is in a shared directory. But when I build a module for a test, the header files are not installed yet. For build it requires an include dir -I$(top_srcdir)/src/pl/plpgsql/src

Regards

Pavel




cheers


andrew



--
Andrew Dunstan
EDB: https://www.enterprisedb.com

Re: window build doesn't apply PG_CPPFLAGS correctly

From
Andrew Dunstan
Date:
On 7/22/21 8:11 AM, Pavel Stehule wrote:
>
>
> čt 22. 7. 2021 v 14:04 odesílatel Andrew Dunstan <andrew@dunslane.net
> <mailto:andrew@dunslane.net>> napsal:
>
>
>     On 7/22/21 12:06 AM, Pavel Stehule wrote:
>     > Hi
>     >
>     > I tried to write test for plpgsql debug API, where I need to
>     access to
>     > plpgsql.h
>     >
>     > I have line
>     >
>     > PG_CPPFLAGS = -I$(top_srcdir)/src/pl/plpgsql/src
>     >
>     > that is working well on unix, but it do nothing on windows
>     >
>     > [00:05:14] Project "C:\projects\postgresql\pgsql.sln" (1) is
>     building
>     > "C:\projects\postgresql\test_dbgapi.vcxproj" (87) on node 1 (default
>     > targets).
>     > [00:05:14] PrepareForBuild:
>     > [00:05:14]   Creating directory ".\Release\test_dbgapi\".
>     > [00:05:14]   Creating directory
>     ".\Release\test_dbgapi\test_dbgapi.tlog\".
>     > [00:05:14] InitializeBuildStatus:
>     > [00:05:14]   Creating
>     > ".\Release\test_dbgapi\test_dbgapi.tlog\unsuccessfulbuild" because
>     > "AlwaysCreate" was specified.
>     > [00:05:14] ClCompile:
>     > [00:05:14]   C:\Program Files (x86)\Microsoft Visual Studio
>     > 12.0\VC\bin\x86_amd64\CL.exe /c /Isrc/include
>     /Isrc/include/port/win32
>     > /Isrc/include/port/win32_msvc /Zi /nologo /W3 /WX- /Ox /D WIN32 /D
>     > _WINDOWS /D __WINDOWS__ /D __WIN32__ /D
>     WIN32_STACK_RLIMIT=4194304 /D
>     > _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _WINDLL /D
>     > _MBCS /GF /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope
>     > /Fo".\Release\test_dbgapi\\"
>     /Fd".\Release\test_dbgapi\vc120.pdb" /Gd
>     > /TC /wd4018 /wd4244 /wd4273 /wd4102 /wd4090 /wd4267
>     /errorReport:queue
>     > /MP src/test/modules/test_dbgapi/test_dbgapi.c
>     > [00:05:14]   test_dbgapi.c
>     > [00:05:16] src/test/modules/test_dbgapi/test_dbgapi.c(17): fatal
>     error
>     > C1083: Cannot open include file: 'plpgsql.h': No such file or
>     > directory [C:\projects\postgresql\test_dbgapi.vcxproj]
>     > [00:05:16] Done Building Project
>     > "C:\projects\postgresql\test_dbgapi.vcxproj" (default targets)
>     -- FAILED.
>     > [00:05:16] Project "C:\projects\postgresql\pgsql.sln" (1) is
>     building
>     > "C:\projects\postgresql\test_ddl_deparse.vcxproj" (88) on node 1
>     > (default targets).
>     >
>     > looks so PG_CPPFLAGS is not propagated to CPPFLAGS there.
>     >
>     >
>
>     Almost everything in the Makefiles is not used by the MSVC buid
>     system.
>     Using this one seems likely to be quite difficult, since the
>     syntax for
>     the MSVC compiler command line is very different, and furthermore the
>     MSVC build system doesn't know anything about how to use this setting.
>
>     AFAICT PG_CPPFLAGS is only used by pgxs.
>
>     You would need to tell us more about how your build process is
>     working.
>
>
> I need access to plpgsql.h in build time. This is only one dependency.
> When I build an extension, then plpgsql.h is in a shared directory.
> But when I build a module for a test, the header files are not
> installed yet. For build it requires an include dir
> -I$(top_srcdir)/src/pl/plpgsql/src
>
>

If I understand correctly what you're doing, you probably need to add an
entry for your module to $contrib_extraincludes in
src/tools/msvc/Mkvcbuild.pm, e.g.


my $contrib_extraincludes = { 'dblink'         => ['src/backend'] ,

                              'test_dbgapi'    => [ 'src/pl/plpgsql/src'
] };


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com




Re: window build doesn't apply PG_CPPFLAGS correctly

From
Alvaro Herrera
Date:
On 2021-Jul-22, Pavel Stehule wrote:

> čt 22. 7. 2021 v 14:04 odesílatel Andrew Dunstan <andrew@dunslane.net>
> napsal:

> > Almost everything in the Makefiles is not used by the MSVC buid system.
> > Using this one seems likely to be quite difficult, since the syntax for
> > the MSVC compiler command line is very different, and furthermore the
> > MSVC build system doesn't know anything about how to use this setting.
> >
> > AFAICT PG_CPPFLAGS is only used by pgxs.
> >
> > You would need to tell us more about how your build process is working.
> 
> I need access to plpgsql.h in build time. This is only one dependency. When
> I build an extension, then plpgsql.h is in a shared directory. But when I
> build a module for a test, the header files are not installed yet. For
> build it requires an include dir -I$(top_srcdir)/src/pl/plpgsql/src

But Project.pm parses Makefiles and puts stuff into the MSVC buildsystem
file format; note David Rowley's patch that (among other things) removes
a bunch of ->AddIncludeDir calls by parsing PG_CPPFLAGS
https://postgr.es/m/CAApHDvpXoav0aZnsji-ZNdo=9TXqAwnwmSh44gyn8K7i2PRwJg@mail.gmail.com
which is probably apropos.

-- 
Álvaro Herrera           39°49'30"S 73°17'W  —  https://www.EnterpriseDB.com/
"I must say, I am absolutely impressed with what pgsql's implementation of
VALUES allows me to do. It's kind of ridiculous how much "work" goes away in
my code.  Too bad I can't do this at work (Oracle 8/9)."       (Tom Allison)
           http://archives.postgresql.org/pgsql-general/2007-06/msg00016.php



Re: window build doesn't apply PG_CPPFLAGS correctly

From
Andrew Dunstan
Date:
On 7/22/21 9:41 AM, Alvaro Herrera wrote:
> On 2021-Jul-22, Pavel Stehule wrote:
>
>> čt 22. 7. 2021 v 14:04 odesílatel Andrew Dunstan <andrew@dunslane.net>
>> napsal:
>>> Almost everything in the Makefiles is not used by the MSVC buid system.
>>> Using this one seems likely to be quite difficult, since the syntax for
>>> the MSVC compiler command line is very different, and furthermore the
>>> MSVC build system doesn't know anything about how to use this setting.
>>>
>>> AFAICT PG_CPPFLAGS is only used by pgxs.
>>>
>>> You would need to tell us more about how your build process is working.
>> I need access to plpgsql.h in build time. This is only one dependency. When
>> I build an extension, then plpgsql.h is in a shared directory. But when I
>> build a module for a test, the header files are not installed yet. For
>> build it requires an include dir -I$(top_srcdir)/src/pl/plpgsql/src
> But Project.pm parses Makefiles and puts stuff into the MSVC buildsystem
> file format; note David Rowley's patch that (among other things) removes
> a bunch of ->AddIncludeDir calls by parsing PG_CPPFLAGS
> https://postgr.es/m/CAApHDvpXoav0aZnsji-ZNdo=9TXqAwnwmSh44gyn8K7i2PRwJg@mail.gmail.com
> which is probably apropos.
>


Yeah, but that hasn't been applied yet. Pavel should be able to use what
I gave him today, I think.


cheers


andrew


--
Andrew Dunstan
EDB: https://www.enterprisedb.com




Re: window build doesn't apply PG_CPPFLAGS correctly

From
Pavel Stehule
Date:


čt 22. 7. 2021 v 20:52 odesílatel Andrew Dunstan <andrew@dunslane.net> napsal:

On 7/22/21 9:41 AM, Alvaro Herrera wrote:
> On 2021-Jul-22, Pavel Stehule wrote:
>
>> čt 22. 7. 2021 v 14:04 odesílatel Andrew Dunstan <andrew@dunslane.net>
>> napsal:
>>> Almost everything in the Makefiles is not used by the MSVC buid system.
>>> Using this one seems likely to be quite difficult, since the syntax for
>>> the MSVC compiler command line is very different, and furthermore the
>>> MSVC build system doesn't know anything about how to use this setting.
>>>
>>> AFAICT PG_CPPFLAGS is only used by pgxs.
>>>
>>> You would need to tell us more about how your build process is working.
>> I need access to plpgsql.h in build time. This is only one dependency. When
>> I build an extension, then plpgsql.h is in a shared directory. But when I
>> build a module for a test, the header files are not installed yet. For
>> build it requires an include dir -I$(top_srcdir)/src/pl/plpgsql/src
> But Project.pm parses Makefiles and puts stuff into the MSVC buildsystem
> file format; note David Rowley's patch that (among other things) removes
> a bunch of ->AddIncludeDir calls by parsing PG_CPPFLAGS
> https://postgr.es/m/CAApHDvpXoav0aZnsji-ZNdo=9TXqAwnwmSh44gyn8K7i2PRwJg@mail.gmail.com
> which is probably apropos.
>


Yeah, but that hasn't been applied yet. Pavel should be able to use what
I gave him today, I think.

yes, and it is working

Thank you very much

Pavel



cheers


andrew


--
Andrew Dunstan
EDB: https://www.enterprisedb.com