Skip to content

Fixups for libstdc++-10 support - #133

Merged
Brian Kroth (bpkroth) merged 2 commits into
microsoft:mainfrom
bpkroth:fixup-cpp-ci-errors
Oct 12, 2020
Merged

Brian Kroth (bpkroth) merged 2 commits into
microsoft:mainfrom
bpkroth:fixup-cpp-ci-errors

Conversation

@bpkroth

Copy link
Copy Markdown
Contributor

Recently we discovered the following error in CI for Linux builds:

Scanning dependencies of target Mlos.Core
make[3]: Leaving directory '/home/runner/work/MLOS/MLOS/out/cmake/Debug'
make[3]: Entering directory '/home/runner/work/MLOS/MLOS/out/cmake/Debug'
[ 20%] Building CXX object source/Mlos.Core/CMakeFiles/Mlos.Core.dir/ArenaAllocator.cpp.o
In file included from /home/runner/work/MLOS/MLOS/source/Mlos.Core/ArenaAllocator.cpp:16:
In file included from /home/runner/work/MLOS/MLOS/source/Mlos.Core/Mlos.Core.h:90:
In file included from /home/runner/work/MLOS/MLOS/source/Mlos.Core/PropertyProxy.h:18:
In file included from /home/runner/work/MLOS/MLOS/source/Mlos.Core/ObjectSerialization.h:19:
/home/runner/work/MLOS/MLOS/source/Mlos.Core/StringTypes.h:89:38: error: use of undeclared identifier 'wcslen'
        Length = string != nullptr ? wcslen(string) : 0;
                                     ^
/home/runner/work/MLOS/MLOS/source/Mlos.Core/StringTypes.h:105:61: error: use of undeclared identifier 'wcsncmp'
    return lhs.Length == rhs.Length && (lhs.Length == 0 || (wcsncmp(lhs.Data, rhs.Data, lhs.Length) == 0));
                                                            ^
2 errors generated.

Not entirely sure how this snuck in since I can't find anything on the C++ side which has changed recently and tests were passing a few days ago, but here we are.

It seems that we weren't including the wide character string functions in the standard libs previously. This small change should fix that.

@bpkroth

Copy link
Copy Markdown
Contributor Author

Discussing with Greg Lapinski (@grlap), this one-line fix isn't going to work due to the fact that wchar_t is of different lengths for Windows/Linux.

Some options to consider to use an explicit lengthed type (e.g. char16_t) or force it to a particular length with a compile flag (e.g. -fshort-wchar).

Still unclear what changed however. None of the C++ code referencing this has changed since August. I suspect something in the Github Ubuntu runners config has changed but I haven't seen what yet. Can't reproduce the issue locally either.

@bpkroth
Brian Kroth (bpkroth) marked this pull request as draft October 12, 2020 17:23
@bpkroth

Copy link
Copy Markdown
Contributor Author

Figured it out: Github added libstdc++-10-dev to the runners:

actions/runner-images@207f49e#diff-29b87ca86e8166171be2d4cf761d6e8f

…0 issues

GNU libstdc++ 10 uses the token `__in` in some generated code, so we need to avoid it.
@bpkroth Brian Kroth (bpkroth) changed the title Make sure to include the wide character string functions Fixups for libstdc++-10 support Oct 12, 2020
@bpkroth

Copy link
Copy Markdown
Contributor Author

With the first fix we were getting type of errors.

/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/basic_string.tcc:1501:63: error: expected expression
              const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());

This was because we had cases of __in SAL notations in use that we were #defineing away on Linux.
However, for GCC-10's libstdc++ they use that token in some code generation so we were introducing errors by doing that.

6d318b0 fixes that by switching to _In_ in the few remaining places.

That still doesn't address the wchar_t width issues though.

@bpkroth
Brian Kroth (bpkroth) marked this pull request as ready for review October 12, 2020 19:24
@bpkroth

Copy link
Copy Markdown
Contributor Author

For the record, the wstrlen issue showed up in the first place because of some more strict header requirements introduced in the new libstdc++ version:
https://gcc.gnu.org/gcc-10/porting_to.html

@bpkroth
Brian Kroth (bpkroth) deleted the fixup-cpp-ci-errors branch October 12, 2020 19:44
Brian Kroth (bpkroth) added a commit to bpkroth/MLOS that referenced this pull request Oct 12, 2020
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.

2 participants