Skip to content

CDRIVER-4264 Address build failures on VS 2013 variants on Evergreen #932

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 5 commits into from
Jan 24, 2022

Conversation

eramongodb
Copy link
Contributor

Per CDRIVER-4264, there are three compilation errors preventing successful compilation on VS 2013 variants. This PR addresses each of these warnings:

  • '_Exit' undefined; assuming extern returning int

VS 2013 only provides partial support for the C99 standard. This support apparently does not extend to providing the _Exit function, which is a C99 feature. Given that its use in the test suite (to report the type of signal triggering failure) is not strictly necessary, I have opted for its removal.

  • 'snprintf' undefined; assuming extern returning int

snprintf is also a C99 feature. Some files in libmongoc were directly invoking snprintf despite libbson providing bson_snprintf to address standard / platform compatibility issues. These instances were substituted with bson_snprintf.

  • '_InterlockedExchangePointer': identifier not found

This issue only manifested when building with VS 2013 targeting x86 (i686). I do not yet fully understand the reason behind this issue. According to a Boost patch (note, "MSVC-12" == "VS 2013") in response to a report of similar build failures, the issue is apparently due to a conflict between the <intrin.h> and <winnt.h> libraries when targeting x86 with VS 2013. This is in spite of Microsoft documentation indicating support for the intrinsic when targeting x86. Consequently, I have opted to emulating the intrinsic given VS 2013 and x86.

@eramongodb eramongodb self-assigned this Jan 21, 2022
Copy link
Contributor

@vector-of-bool vector-of-bool left a comment

Choose a reason for hiding this comment

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

LGTM. Do we not have VS 2013 set as a default build task?

@eramongodb
Copy link
Contributor Author

It appears not. A patch build verifying these changes (with minor discrepancies in the diff compared to this PR) are available here for reference.

Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -48,7 +48,7 @@ bson_memory_barrier (void)
}

/**
* Some platforms do not support compiler intrinsics for atomic operations.
* Some platforms do not support compiler ics for atomic operations.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Thank you for the catch.

@@ -73,6 +73,12 @@ enum bson_memory_order {
#define BSON_EMULATE_INT
#endif

/* CDRIVER-4264 Contrary to documentation, VS 2013 targeting x86 does not
* correctly/consistently provide _IntrinsicPointerExchange. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* correctly/consistently provide _IntrinsicPointerExchange. */
* correctly/consistently provide _InterlockedExchangePointer. */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I keep mistakening "Interlocked" as "Intrinsic". Will fix. 😑

@eramongodb eramongodb merged commit ec13e0b into mongodb:master Jan 24, 2022
@eramongodb eramongodb deleted the cdriver-4264 branch January 24, 2022 15:32
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.

3 participants