cxxflags bug ?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

cxxflags bug ?

paulo.alves
Hi,

  I'm trying to use /Zc:wchat_t- but it doesn't work (using msvc-9.0).
Searching for something I found this:

# msvc.jam
toolset.flags $(toolset).compile CFLAGS $(conditions) : /Zc:forScope
/Zc:wchar_t ;

and my jamfile.jam is like this:

project foo : requirements <cxxflags>/Zc:wchar_t- ;
exe foo : main.cc ;

bjam -d+2 output this:
 /O2
 /Ob2
 /W3
 /GR
 /MT
 /Zc:forScope
 /Zc:wchar_t
 /wd4675
 /EHs
 /Zc:wchar_t
 -c

1º - I've passed /Zc:wchar_t- and the output shows 2x /Zc:wchar_t
2º - If I remove the forced flag from msvc.jam I can't (and I don't
know why) pass /Zc:wchat_t-, because the suffix '-' just disappear
3º - I've chaged this:
        toolset.flags $(toolset).compile CFLAGS $(conditions) :
/Zc:forScope /Zc:wchar_t ;
      to:
        toolset.flags $(toolset).compile CFLAGS $(conditions) :
/Zc:forScope /Zc:wchar_t- ;
      It works if I do NOT use <cxxflags>/Zc:wchar_t-

Is that a bug ? Am I doing something wrong ?
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: cxxflags bug ?

paulo.alves
It's missing some information. It just fails if I use conditional, like:
<toolset>msvc:<cxxflags>/Zc:wchar_t-

I'm sending a sample now, the expected output is:

...
main.cc(2) : error C2065: 'wchar_t' : undeclared identifier
main.cc(2) : error C2146: syntax error : missing ';' before identifier 'tmp'
main.cc(2) : error C2065: 'tmp' : undeclared identifier
...

but it does not occur.

# project-root.jam
exe cxxflags_bug : main.cc : <toolset>msvc:<cxxflags>/Zc:wchar_t- ;

# main.cc
void main() { wchar_t tmp = '\0'; }

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

cxxflags_bug.zip (648 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: cxxflags bug ?

Gevorg Voskanyan
Paulo Márcio Figueiredo Alves wrote:

> To: Boost.Build developer's and user's list <[hidden email]>
> Sent: Fri, April 8, 2011 6:33:28 PM
> Subject: Re: [Boost-build] cxxflags bug ?
>
> It's missing some information. It just fails if I use conditional,  like:
> <toolset>msvc:<cxxflags>/Zc:wchar_t-
>
> I'm sending a  sample now, the expected output is:
>
> ...
> main.cc(2) : error C2065: 'wchar_t' : undeclared  identifier
> main.cc(2) : error C2146: syntax error : missing ';' before  identifier 'tmp'
> main.cc(2) : error C2065: 'tmp' : undeclared  identifier
> ...
>
> but it does not occur.
>
> # project-root.jam
> exe  cxxflags_bug : main.cc : <toolset>msvc:<cxxflags>/Zc:wchar_t-  ;
>
> # main.cc
> void main() { wchar_t tmp = '\0'; }

A workaround is to embed the flags value in quotes and append a trailing space
inside:

exe  cxxflags_workaround : main.cc : <toolset>msvc:<cxxflags>"/Zc:wchar_t- "  ;

Didn't investigate why the original doesn't work though -- I'd ask you to open a
ticket at https://trac.lvk.cs.msu.su/boost.build/ so it isn't forgotten
(svn.boost.org seems broken at this moment).

Thanks,
Gevorg

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: cxxflags bug ?

bganesh05@gmail.com
In reply to this post by paulo.alves
Hi Friends,

I am also trying to use cxxflags with msvc for specifying optimization flags like "/Ox /Oi /GF /Gy " for release variant.
I do NOT want to use the "<optimization>speed : /O2" specified in msvc.jam.

I added:
    <target-os>windows:<variant>release:<cxxflags>"/Ox /Oi /GF /Gy "
in my project requirements section in Jamroot file.

I am not using <optimization>speed anywhere in Jamroot, still I see that compilation command line has "/O2" and not the "/Ox..." flags that I specified.

Can we not set the command "cxxflags" in project requirements section for one type of build variant?

Thanks for your time and guidance.

Best Regards.
Reply | Threaded
Open this post in threaded view
|

Re: cxxflags bug ?

Mateusz Loskot
On 25 July 2012 09:12, [hidden email] <[hidden email]> wrote:
>
> I added:
>     <target-os>windows:<variant>release:<cxxflags>"/Ox /Oi /GF /Gy "

Check thread http://lists.boost.org/boost-build/2007/11/17906.php

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
--
Mateusz Loskot, http://mateusz.loskot.net
Reply | Threaded
Open this post in threaded view
|

Re: cxxflags bug ?

bganesh05@gmail.com
Thanks this works. But "/O2" from msvc.jam still appears in the command line. How do we suppress that?
Reply | Threaded
Open this post in threaded view
|

Re: cxxflags bug ?

Mateusz Loskot
On 25 July 2012 11:03, [hidden email] <[hidden email]> wrote:
> Thanks this works. But "/O2" from msvc.jam still appears in the command line.
> How do we suppress that?

Does the /Ox appear too? If it does, what is the order?


Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
--
Mateusz Loskot, http://mateusz.loskot.net
Reply | Threaded
Open this post in threaded view
|

Re: cxxflags bug ?

bganesh05@gmail.com
like this: -TP /O2 /Z7 /Ob2 /W3 /GR /Zc:forScope /Zc:wchar_t /MT /wd4675 /EHs /Ox /Oi /GF /Gy  -c
Reply | Threaded
Open this post in threaded view
|

Re: cxxflags bug ?

Mateusz Loskot
On 26 July 2012 02:54, [hidden email] <[hidden email]> wrote:
> like this: -TP /O2 /Z7 /Ob2 /W3 /GR /Zc:forScope /Zc:wchar_t /MT /wd4675 /EHs
> /Ox /Oi /GF /Gy  -c

Then don't you worry about the appearance of /O2

"If CL encounters conflicting options, it uses the rightmost option."

http://msdn.microsoft.com/en-us/library/wf06704c%28v=vs.100%29.aspx

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
--
Mateusz Loskot, http://mateusz.loskot.net
Reply | Threaded
Open this post in threaded view
|

Re: cxxflags bug ?

bganesh05@gmail.com
Hi,

Yes, that's what is my concern. I do not want /O2 to appear again. To suppress it, I added <toolset>msvc,<variant>release:<cxxflags>"/Ox /Oi /GF /Gy " in project requirements in Jamroot, but /O2 is still coming in the command line.

I assumed that if I don't <optimization>speed, then /O2 won't come.
But seems like something is broken in bjam and so even though <optimization>speed is not given, /O2 appears in cmdline.

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: cxxflags bug ?

Mateusz Loskot
On 26 July 2012 12:32, [hidden email] <[hidden email]> wrote:
> Hi,
>
> Yes, that's what is my concern.

Please, read the MSDN. There is nothing to be concerned about.

> But t I do not want /O2 to appear again.

Just ignore it.

> To suppress it, I added <toolset>msvc,<variant>release:<cxxflags>"/Ox /Oi /GF
> /Gy " in project requirements in Jamroot, but /O2 is still coming in the
> command line.

The /Ox will override the /O2.

> I assumed that if I don't <optimization>speed, then /O2 won't come.

Don't assume. Read the docs.

> But seems like something is broken in bjam and so even though
> <optimization>speed is not given, /O2 appears in cmdline.

Nothing is broken.
You can specify the same option for cl.exe dozens of times in a single
invocation:

"If two options specify contradictory or incompatible directives, the directive
specified or implied in the option farthest to the right on the
command line is used."

http://msdn.microsoft.com/en-us/library/8k3f51f1(v=vs.100).aspx

For example:

g:\workshop\testcpp\test>cl /EHsc /MDd /MD /MDd /MDd /MT /MD test.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x8
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9025 : overriding '/MDd' with '/MD'
cl : Command line warning D9025 : overriding '/MD' with '/MDd'
cl : Command line warning D9025 : overriding '/MDd' with '/MT'
cl : Command line warning D9025 : overriding '/MT' with '/MD'
test.cpp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:test.exe
test.obj

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
--
Mateusz Loskot, http://mateusz.loskot.net
Reply | Threaded
Open this post in threaded view
|

Re: cxxflags bug ?

Mateusz Loskot
On 26 July 2012 12:51, Mateusz Loskot <[hidden email]> wrote:

> On 26 July 2012 12:32, [hidden email] <[hidden email]> wrote:
>> Hi,
>>
>> Yes, that's what is my concern.
>
> Please, read the MSDN. There is nothing to be concerned about.
>
>> But t I do not want /O2 to appear again.
>
> Just ignore it.
>
>> To suppress it, I added <toolset>msvc,<variant>release:<cxxflags>"/Ox /Oi /GF
>> /Gy " in project requirements in Jamroot, but /O2 is still coming in the
>> command line.
>
> The /Ox will override the /O2.

One more thing that may invalidate questions you might be aiming to ask now.
You realise that /Ox is identical [1] to /O2, that is why you don't
see the warning
in case of this:

cl /nologo /EHsc /O2 /Ox test.cpp
test.cpp

However, you do see the warning in other cases, for example:

cl /nologo /EHsc /O1 /Ox test.cpp
cl : Command line warning D9025 : overriding '/O1' with '/Ox'
test.cpp

Thus, lack of warning in case of specifying /O2 /Ox
does NOT mean the options overriding mechanism does not work
or Boost.Build is broken.

[1] http://blogs.msdn.com/b/branbray/archive/2005/07/08/437078.aspx
Ot: now turns on optimization, favoring speed (also throws Oi Oy Ob2 GF)
O2: has exactly the same meaning as Ot
Ox: has exactly the same meaning as Ot

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
--
Mateusz Loskot, http://mateusz.loskot.net