Closed Bug 1220016 Opened 9 years ago Closed 9 years ago

Don't mix-and-match debug/non-debug MS CRT in NSS

Categories

(NSS :: Build, defect)

Unspecified
Windows
defect
Not set
normal

Tracking

(firefox45 affected)

RESOLVED FIXED
Tracking Status
firefox45 --- affected

People

(Reporter: jld, Assigned: jld)

References

Details

Attachments

(1 file)

The NSS makefiles, for reasons lost to history (or at least to hg blame), build on Windows with /D_DEBUG whenever BUILD_OPT=0, regardless of whether a debug CRT library is being used (controlled by USE_DEBUG_RTL in the NSS/NSPR makefiles). For C this appears to be tolerated, but it causes some of the C++ standard library headers to enable error-checking containing calls to _CrtDbgReportW, which exists only in the debug CRT. The current workaround is to force building gtests and the gtest library with /MTd. This isn't the best idea to begin with — https://support.microsoft.com/en-us/kb/140584 explains some of the footguns of CRT-mixing — but more immediately this prevents statically linking gtests with the code under test, to allow unit tests to cover internal interfaces. (Additional side-effect: forcing debug mode on ssl_gtest is hiding an instance of optimization warning C4800 that would otherwise break the build.) I'm not sure why we're changing the definedness of _DEBUG at all, rather than leaving that to the /M flags, but it's been like that since 2000 so I'm hesistant to touch it. One alternative would be to just filter it out for C++ files or for directories using C++.
Component: Test → Build
This is one approach; changing the flags just for the gtest directories also works.
Attachment #8681572 - Flags: review?(rrelyea)
Comment on attachment 8681572 [details] [diff] [review] Patch: remove explicit -D_DEBUG and -U_DEBUG from all compilation. (Applying suggestions I got about asking whether this patch is reasonable.)
Attachment #8681572 - Flags: review?(rrelyea)
Attachment #8681572 - Flags: feedback?(martin.thomson)
Attachment #8681572 - Flags: feedback?(kmckinley)
Attachment #8681572 - Flags: feedback?(ekr)
Comment on attachment 8681572 [details] [diff] [review] Patch: remove explicit -D_DEBUG and -U_DEBUG from all compilation. Seems fine.
Attachment #8681572 - Flags: feedback?(martin.thomson) → feedback+
Comment on attachment 8681572 [details] [diff] [review] Patch: remove explicit -D_DEBUG and -U_DEBUG from all compilation. Review of attachment 8681572 [details] [diff] [review]: ----------------------------------------------------------------- Looks good to me.
Attachment #8681572 - Flags: feedback?(kmckinley) → feedback+
Comment on attachment 8681572 [details] [diff] [review] Patch: remove explicit -D_DEBUG and -U_DEBUG from all compilation. Thanks for the feedback. It's passed all 2h20m of NSS tests and doesn't break Gecko on Windows, so r?.
Attachment #8681572 - Flags: review?(martin.thomson)
Comment on attachment 8681572 [details] [diff] [review] Patch: remove explicit -D_DEBUG and -U_DEBUG from all compilation. Review of attachment 8681572 [details] [diff] [review]: ----------------------------------------------------------------- LGTM
Attachment #8681572 - Flags: feedback?(ekr) → feedback+
Comment on attachment 8681572 [details] [diff] [review] Patch: remove explicit -D_DEBUG and -U_DEBUG from all compilation. http://hg.mozilla.org/projects/nss/rev/24d118f3c692
Attachment #8681572 - Flags: review?(martin.thomson)
Attachment #8681572 - Flags: review+
Attachment #8681572 - Flags: checked-in+
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → 3.21
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: