This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: CFLAGS for Visual Studio
Type: enhancement Stage: patch review
Components: Build, Windows Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: christopher.hogan, paul.moore, r.david.murray, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2015-08-31 20:34 by christopher.hogan, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
addcflags3_5.patch christopher.hogan, 2015-08-31 20:34 Patch for 3.5
addcflags2_7.patch christopher.hogan, 2015-08-31 20:53 Patch for 2.7 review
Messages (6)
msg249427 - (view) Author: Chris Hogan (christopher.hogan) * Date: 2015-08-31 20:34
This Visual Studio project change appends to the compiler flags any values in the CFLAGS environment variable.
msg249429 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-08-31 21:44
The patch should just set it once in pyproject.props, not in each project.

Why is this necessary? Is there an option we should be exposing in some other way?
msg249430 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2015-08-31 21:46
The real driver for this is having a nice easy way to pass '/fp:strict' to icl.exe (ICC's cl.exe).  There may be other things that would be nice to be able to pass easily for customization.
msg249433 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-08-31 22:12
I assume you're referring to #24974? The default (for MSVC) is /fp:precise, which should allow fenv_access, but maybe ICL uses /fp:fast by default for the extra speed?

It's not a safe 3.5 change now, but compiling with /fp:fast by default and using #pragma float_control(precise, push)/#pragma float_control(pop) around that section may be an option for 3.6, if the benchmarks show some value in it. Either way, the pragma is probably the better way to require particular behaviour for that section of code, rather than changing a global option.

I'm not totally opposed to allowing an extra option for setting flags when building, but there'll almost always be a better fix.
msg249453 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2015-09-01 05:21
Steve Dower wrote:
> I assume you're referring to #24974?

It's somewhat related, yes, but I didn't intend for the two issues to be tightly coupled.  Both should be dealt with independently of each other.

> The default (for MSVC) is /fp:precise, which should allow
> fenv_access, but maybe ICL uses /fp:fast by default for the extra
> speed?

I believe that's correct.

> I'm not totally opposed to allowing an extra option for setting flags
> when building, but there'll almost always be a better fix.

That's probably true.  I will say though that it's really hard to pass build options to a buildbot.  I have yet to find a way to pass properties with no spaces in the value, for example, "/p:IncludeSSL=false" (if you know of a way to pass that to MSBuild correctly through Tools/buildbot/build.bat called by 2.7's subprocess module, I'm all ears :)).  To continue the floating point example, the only method (other than this) I've found to pass in a different model is to hack in another property to check and set FloatingPointModel in the ClCompile ItemDefinitionGroup, which has the same problem as the 'IncludeSSL' issue I mentioned above.  With a nice simple 'CFLAGS' property that doesn't care about extra spaces in the value, it becomes possible to pass '/fp:strict' to a buildbot easily.

Also, ICC has *a lot* of extra command line options that may be interesting to pass in, but I'm quite sure we don't want to hack any of them into the project files.

By the way, '/fp:strict' is just what we've been manually defaulting to for ICC builds since before issue21167 was committed, which made '/fp:strict' unnecessary.
msg249491 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-09-01 16:35
All environment variables are promoted to MSBuild properties, so if you "set IncludeSSL=false" before building then it will show up (which is exactly how the proposed patch is getting CFLAGS in).

Unfortunately, batch file argument parsing is pretty horrid. I'd be happy to move to PowerShell based scripts, but that'll be asking a lot of some people, and probably isn't feasible for the existing buildbots.

Another concern about using CFLAGS is people ending up with broken builds because they had something else set in there - mostly because it's near impossible to diagnose remotely.

If we call it PY_CFLAGS< move it to pyproject.props, and require "$(BuildForRelease) != 'true'", then I'm fine with it. (The last condition ensures that official release builds via Tools\msi\buildrelease.bat will never be affected, and gives a fairly strong indication not to rely on implicit settings like this. Defaults that we need for actual releases should be integrated properly.)
History
Date User Action Args
2022-04-11 14:58:20adminsetgithub: 69161
2015-09-01 16:35:09steve.dowersetmessages: + msg249491
2015-09-01 05:21:12zach.waresetmessages: + msg249453
2015-08-31 22:12:03steve.dowersetmessages: + msg249433
2015-08-31 21:47:01zach.waresetstage: patch review
type: enhancement
versions: + Python 3.6
2015-08-31 21:46:43zach.waresetmessages: + msg249430
2015-08-31 21:44:58steve.dowersetmessages: + msg249429
2015-08-31 20:53:23christopher.hogansetfiles: + addcflags2_7.patch
2015-08-31 20:34:51christopher.hogancreate