[CDRIVER-2600] Port MONGOC_HAVE_WEAK_SYMBOLS check to CMake Created: 07/Apr/18  Updated: 28/Oct/23  Resolved: 18/Apr/18

Status: Closed
Project: C Driver
Component/s: cmake
Affects Version/s: None
Fix Version/s: 1.10.0

Type: Improvement Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Remove Autotools

 Description   

The Autotools build system checks if the compiler supports the (weak) annotation. We use it to prevent Link-Time-Optimization (LTO) in our constant-time mongoc_memcmp(), CDRIVER-815. See WeakSymbols.m4 and mongoc-memcmp.c. I'm not sure this is necessary - why would LTO violate the requirement that different SCRAM keys take the same time to compare?

Either remove the MONGOC_HAVE_WEAK_SYMBOLS preprocessor symbol, or port the check to CMake.



 Comments   
Comment by Githook User [ 18/Apr/18 ]

Author:

{'email': 'jesse@mongodb.com', 'username': 'ajdavis', 'name': 'A. Jesse Jiryu Davis'}

Message: CDRIVER-2600 don't rely on _attribute_((weak))

We had cargo-culted a constant-time comparison function from libsodium. We use
the "weak" attribute if the compiler supports it, to prevent the constant-time
comparison function from being compiled out during link-time optimization if
the program doesn't use its result. But we don't need to prevent link-time
optimization: we always use our comparison function's result.

The variables had been declared volatile to prevent an aggressive optimizer
from pre-computing the result if both input values are known at compile time.
This also does not apply to our usage.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/edc686ead99eb3c762aa606e048d16480bce627e

Generated at Wed Feb 07 21:15:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.