Closed
Bug 1189891
Opened 9 years ago
Closed 9 years ago
STL wrappers break VS 2015 (type_traits errors)
Categories
(Firefox Build System :: General, defect)
Firefox Build System
General
Tracking
(firefox43 fixed)
RESOLVED
FIXED
mozilla43
Tracking | Status | |
---|---|---|
firefox43 | --- | fixed |
People
(Reporter: bas.schouten, Assigned: bas.schouten)
References
Details
Attachments
(2 files, 2 obsolete files)
1.63 KB,
patch
|
glandium
:
review+
|
Details | Diff | Splinter Review |
3.40 KB,
patch
|
briansmith
:
review+
|
Details | Diff | Splinter Review |
From https://bugzilla.mozilla.org/show_bug.cgi?id=1120793#c7:
'The next issue I found in the VS 2015 rabbit hole:
<xstddef> includes <cstdlib>, but the mozilla build arranges for its own wrapper file 'cstdlib' to get loaded instead. The wrapper 'cstdlib' has a number of layering violations, carefully #defined and ordered so everything works.
By 'layering violation', I mean that <cstdlib> just includes bits of the 'C' standard library, and typically gets pulled in before the C++ std library headers. So it doesn't/shouldn't assume the presence of C++ std library definitions.
Our 'cstdlib' wrapper and its header dependency tree, however, does pull in C++ std library definitions. These C++ headers try to pull in <xstddef>, which gets skipped because the compiler doesn't like infinite loops. Then the C++ headers try to use the content from <xstddef>, leading to errors like this:
type_traits(104): error C3646: '_Bool_type': unknown override specifier
So, I can probably hack the #defines and the order of includes to make it work again, but perhaps a more robust approach would be to move the C++ content out of the 'cstdlib' wrapper into some more layer-appropriate headers.
Either way risks other build targets and environments, since the changes mess with core header files. Option 1 (hack it to work) seems easier but more fragile, while option 2 is a larger change, more likely to disrupt years of carefully arranged header files.
I'm hoping that more experienced Mozilla contributors will point out options 3 and 4 - I'd love some feedback at this point.
Also, let me know if I should go with side-option A: open a new bug for this issue.'
This can be worked around by making sure we only attempt to include C++ headers the first time we include a wrapper.
Attachment #8641800 -
Flags: feedback?(mh+mozilla)
Assignee | ||
Updated•9 years ago
|
Attachment #8641800 -
Attachment is patch: true
Comment 1•9 years ago
|
||
Comment on attachment 8641800 [details] [diff] [review]
Only include STL stuff on the first include
Review of attachment 8641800 [details] [diff] [review]:
-----------------------------------------------------------------
::: config/msvc-stl-wrapper.template.h
@@ +11,5 @@
> #if _HAS_EXCEPTIONS
> # error "STL code can only be used with -fno-exceptions"
> #endif
>
> +#ifndef HAVE_INCLUDED_ALLOC
You can also wrap the _HAS_EXCEPTIONS above.
a mozilla_ or MOZ_ or __MOZ_ prefix would be better.
Attachment #8641800 -
Flags: feedback?(mh+mozilla) → feedback+
Assignee | ||
Comment 2•9 years ago
|
||
Assignee: nobody → bas
Attachment #8641800 -
Attachment is obsolete: true
Attachment #8644162 -
Flags: review?(mh+mozilla)
Comment 3•9 years ago
|
||
Comment on attachment 8644162 [details] [diff] [review]
Only include STL stuff on the first include v2
Review of attachment 8644162 [details] [diff] [review]:
-----------------------------------------------------------------
Sorry I didn't look at this one earlier, I thought it was the tricky one.
::: config/msvc-stl-wrapper.template.h
@@ +34,5 @@
> # include "mozilla/mozalloc.h"
> #else
> # error "STL code can only be used with infallible ::operator new()"
> #endif
> +#endif
/* MOZ_HAVE_INCLUDED_ALLOC */
Attachment #8644162 -
Flags: review?(mh+mozilla) → review+
Backed out in https://hg.mozilla.org/integration/mozilla-inbound/rev/d50e07c09227 for windows build bustage:
https://treeherder.mozilla.org/logviewer.html#?job_id=13104958&repo=mozilla-inbound
Flags: needinfo?(bas)
Comment 7•9 years ago
|
||
This fixes the error seen when the first patch landed. This also happens to be required for bug 1189967.
Flags: needinfo?(bas)
Attachment #8650764 -
Flags: review?(dkeeler)
Comment 8•9 years ago
|
||
Comment on attachment 8650764 [details] [diff] [review]
Include <string> from pkix/Input.h
Review of attachment 8650764 [details] [diff] [review]:
-----------------------------------------------------------------
::: security/pkix/include/pkix/Input.h
@@ +30,5 @@
> +// That also triggers C4350 warnings on MSVC 2013, which we simply ignore.
> +// https://connect.microsoft.com/VisualStudio/feedback/details/767960/warning-c4350-behavior-change-when-including-string-and-no-precompiled-header
> +#pragma warning(push)
> +#pragma warning(disable:4350)
> +#include <string>
First, this should all be guarded with `#if defined(_MSC_VER) && _MSC_VER >= 1900`
We should not include <string> in this header file, because mozilla::pkix is not supposed to use <string> (except in code under test/), and this would just make that confusing.
I would rather have the include of <cstring> removed, if the include of <cstring> is the problem. e.g. we can maybe use <algorithms> to deal with the std::memcmp calls, or just reimplement memcmp in the header file using a for loop.
RE: warning C4350: It is best to disable this warning in security/pkix/warnings.mozbuild and anywhere else that it needs to be disabled. These "behavior change" warnings are not helpful to us.
Comment 9•9 years ago
|
||
(In reply to Brian Smith (:briansmith, :bsmith, use NEEDINFO?) from comment #8)
> Comment on attachment 8650764 [details] [diff] [review]
> Include <string> from pkix/Input.h
>
> Review of attachment 8650764 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> ::: security/pkix/include/pkix/Input.h
> @@ +30,5 @@
> > +// That also triggers C4350 warnings on MSVC 2013, which we simply ignore.
> > +// https://connect.microsoft.com/VisualStudio/feedback/details/767960/warning-c4350-behavior-change-when-including-string-and-no-precompiled-header
> > +#pragma warning(push)
> > +#pragma warning(disable:4350)
> > +#include <string>
>
> First, this should all be guarded with `#if defined(_MSC_VER) && _MSC_VER >=
> 1900`
No, because it affects 2013 as well. This is why the other patch in this bug was backed out.
> We should not include <string> in this header file, because mozilla::pkix is
> not supposed to use <string> (except in code under test/), and this would
> just make that confusing.
>
> I would rather have the include of <cstring> removed, if the include of
> <cstring> is the problem. e.g. we can maybe use <algorithms> to deal with
> the std::memcmp calls, or just reimplement memcmp in the header file using a
> for loop.
>
> RE: warning C4350: It is best to disable this warning in
> security/pkix/warnings.mozbuild and anywhere else that it needs to be
> disabled. These "behavior change" warnings are not helpful to us.
IMHO, it's best to disable it exactly where it's being caused. Or globally, like we disable many others.
Comment 10•9 years ago
|
||
So, for something interesting:
- There are three calls to memcmp in that header. Two are namespaced, one is not.
- Removing the cstring include on Windows just works, it doesn't complain.
- On Linux, doing the same doesn't work, but replacing the two std::memcmp with memcmp does (without a warning), because string.h ends up being included from mozalloc.h, which is included from our STL wrappers.
Comment 11•9 years ago
|
||
Attachment #8650764 -
Attachment is obsolete: true
Attachment #8650764 -
Flags: review?(dkeeler)
Attachment #8650795 -
Flags: review?(brian)
Updated•9 years ago
|
Attachment #8650795 -
Flags: review?(brian) → review+
Comment 12•9 years ago
|
||
Comment 13•9 years ago
|
||
Can't have nice things. This broke pkix tests, so backed out.
https://hg.mozilla.org/integration/mozilla-inbound/rev/eaa9d14c60af
Comment 14•9 years ago
|
||
Comment 15•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/491c4ae1ea4a
https://hg.mozilla.org/mozilla-central/rev/97207786c908
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox43:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
Updated•7 years ago
|
Product: Core → Firefox Build System
You need to log in
before you can comment on or make changes to this bug.
Description
•