Skip to content
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

Fix MinGW build #2298

Closed
wants to merge 1 commit into from
Closed

Fix MinGW build #2298

wants to merge 1 commit into from

Conversation

orgads
Copy link
Contributor

@orgads orgads commented May 15, 2017

snprintf is defined as _snprintf, which doesn't exist in the std
namespace.

@orgads
Copy link
Contributor Author

orgads commented May 15, 2017

cc @tamird

Copy link
Contributor

@tamird tamird left a comment

Choose a reason for hiding this comment

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

For context, looks like this was broken by #2276.

LGTM, I think, though the commit message is pretty confusing. Should it mention that snprintfis already defined in mingw?

@adamretter
Copy link
Collaborator

@orgads @tamird Just want to check that this was tested on both MinGW and Windows with Visual Studio?

@orgads
Copy link
Contributor Author

orgads commented May 15, 2017

I didn't test msvc, but the behavior is unchanged there, since _MSC_VER is defined.

@tamird
Copy link
Contributor

tamird commented May 15, 2017 via email

@adamretter
Copy link
Collaborator

@tamird Sadly it looks like the AppVeyor build is already broken :-( https://ci.appveyor.com/project/Facebook/rocksdb/branch/master/messages

@tamird
Copy link
Contributor

tamird commented May 15, 2017

Heh, indeed. I guess this PR should wait until that's fixed.

Disappointing that #2269 was merged with failing CI.

@yiwu-arbug
Copy link
Contributor

@tamird my bad. I'll land #2287 soon.

@yiwu-arbug
Copy link
Contributor

@orgads #2287 has been landed. Please rebase. Thanks!

@facebook-github-bot
Copy link
Contributor

@orgads updated the pull request - view changes

// VS 15
#if (defined _MSC_VER) && (_MSC_VER >= 1900)
// VS 15 / MinGW
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
Copy link
Contributor

Choose a reason for hiding this comment

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

that does not sound right to me, why will we enable this if _MSC_VER is not defined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I assume that MinGW/GCC supports C++11. Why not?

Copy link
Contributor

Choose a reason for hiding this comment

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

port_win.h shouldn't enable for non-Windows. Looks like we should use __MINGW32__ macro to tell if it is MinGW?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's equivalent; this checks for MSVC. Is this change really worth more CI cycles?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you wanted to be pedantic about it, you could write this as:

#if (defined _MSC_VER) && (_MSC_VER < 1900)
<old MSVC code>
#else
<normal code>
#endif

Copy link
Contributor Author

@orgads orgads May 16, 2017

Choose a reason for hiding this comment

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

Moreover, I don't think there's a reason to exclude clang or ICC for example. Do they define __MINGW32__?

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, I misread the code. I thought without a mingw-specific macro the code will compile for non-windows.

btw. does MSVC has std::snprintf in <cstdio>? If so we can probably update all occurrence of snprintf to std::snprintf and get rid of the macro?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to the docs it was only added in MSVC2015.

Copy link
Contributor

Choose a reason for hiding this comment

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

@orgads looks like CI hasn't started on this yet (and won't for a while). Perhaps it's worth rewriting it in the style I suggested above, for clarity?

@adamretter
Copy link
Collaborator

@yiwu-arbug It looks like AppVeyor isn't enabled for PRs like Travis is. Could we enable it somehow?

@tamird
Copy link
Contributor

tamird commented May 16, 2017

@adamretter looks like it's still building them, but the status isn't being shown in GH.

https://ci.appveyor.com/project/Facebook/rocksdb/history

@adamretter
Copy link
Collaborator

adamretter commented May 16, 2017

@tamird Interesting. I think it would be good if we could get the AppVeyor "check" to show up on the PRs as well. Looks like this PR passed though, so I am happy with it.

@yiwu-arbug
Copy link
Contributor

yiwu-arbug commented May 16, 2017

@adamretter: @sdwilsh help fix an auth issue and the AppVeyor status should be back next time.

// VS 15
#if (defined _MSC_VER) && (_MSC_VER >= 1900)
// VS 15 / MinGW
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
Copy link
Contributor

Choose a reason for hiding this comment

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

port_win.h shouldn't enable for non-Windows. Looks like we should use __MINGW32__ macro to tell if it is MinGW?

@facebook-github-bot
Copy link
Contributor

@yiwu-arbug has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@orgads updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@orgads updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@orgads updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@orgads updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@orgads updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@orgads updated the pull request - view changes - changes since last import

@orgads
Copy link
Contributor Author

orgads commented May 27, 2017

Rebased.

@facebook-github-bot
Copy link
Contributor

@orgads updated the pull request - view changes - changes since last import

@orgads
Copy link
Contributor Author

orgads commented Jun 11, 2017

Rebased again.

Hello?

@facebook-github-bot
Copy link
Contributor

@orgads updated the pull request - view changes - changes since last import

snprintf is defined as _snprintf, which doesn't exist in the std
namespace.

blob_file.cc: In member function 'std::__cxx11::string
rocksdb::blob_db::BlobFile::DumpState() const':
blob_file.cc:92:3: error: '_snprintf' is not a member of 'std'
   std::snprintf(str, sizeof(str),
   ^~~
@facebook-github-bot
Copy link
Contributor

@orgads has updated the pull request.

@orgads
Copy link
Contributor Author

orgads commented Sep 14, 2017

@yiwu-arbug Rebased and fixed debug and release builds. Please review.

@yiwu-arbug
Copy link
Contributor

@orgads any idea why AppVeyor is failing?

@facebook-github-bot
Copy link
Contributor

@orgads has updated the pull request.

@orgads
Copy link
Contributor Author

orgads commented Sep 14, 2017

@yiwu-arbug commented on Sep 14, 2017, 7:25 PM GMT+3:

@orgads any idea why AppVeyor is failing?

Probably because of the second commit. I removed it for now, let's see if it passes and then I'll try to fix release build in a separate commit.

@orgads
Copy link
Contributor Author

orgads commented Sep 15, 2017

Looks good now.

@orgads
Copy link
Contributor Author

orgads commented Sep 19, 2017

@yiwu-arbug: Well?

@yiwu-arbug
Copy link
Contributor

Sorry for delay. Merging.

@facebook-github-bot
Copy link
Contributor

@yiwu-arbug has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants