Skip to content

Simplify Windows implementation of Compilation::performSimpleCommand #7422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2017
Merged

Simplify Windows implementation of Compilation::performSimpleCommand #7422

merged 2 commits into from
Feb 15, 2017

Conversation

hughbe
Copy link
Contributor

@hughbe hughbe commented Feb 13, 2017

See https://msdn.microsoft.com/en-us/library/eyw7eyfw.aspx for the docs for _putenv_s

I also get the Microsoft Code Analysis warning that

Warning C6031 Return value ignored: '_putenv'

I think that the code analysis has a point here, but I'm not sure if I've got the right fix here. Now, if we can't set the environment variable, we return the error code instead of continuing with compilation as we did before.

Perhaps there are better options

  • assert that the error code is 0, as we expect this to always work
  • print some kind of informative message that we failed (a warning?), and continue compilation

@jrose-apple as the code owner of swiftDriver what do you think?

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to say we should assert because it increases our chances of recovery. Maybe we can assert in debug builds and bail out early in release builds?

Thanks for fixing this, by the way. I guess none of us are Windowsy enough to know about _putenv_s.

@hughbe
Copy link
Contributor Author

hughbe commented Feb 14, 2017

@swift-ci please smoke test

@hughbe
Copy link
Contributor Author

hughbe commented Feb 14, 2017

@swift-ci please smoke test OS X Platform

@hughbe
Copy link
Contributor Author

hughbe commented Feb 14, 2017

Looks like it's not impossible for setenv to return anything but 0... what do you think we should do?

#endif
assert(envResult &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You got your assertion backwards. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhhh facepalm

@hughbe
Copy link
Contributor Author

hughbe commented Feb 15, 2017

@swift-ci please smoke test

@hughbe hughbe merged commit 45979e8 into swiftlang:master Feb 15, 2017
@hughbe hughbe deleted the putenv-simplify branch February 15, 2017 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants