This is an archive of the discontinued LLVM Phabricator instance.

Don't use std::errc
ClosedPublic

Authored by ABataev on Aug 13 2019, 8:06 AM.

Details

Summary

As noted on Errc.h:

* std::errc is just marked with is_error_condition_enum. This means that
common patters like AnErrorCode == errc::no_such_file_or_directory take
// 4 virtual calls instead of two comparisons.

And on some libstdc++ those virtual functions conclude that


int main() {

std::error_code foo = std::make_error_code(std::errc::no_such_file_or_directory);
return foo == std::errc::no_such_file_or_directory;

}

should exit with 0.

Diff Detail

Repository
rL LLVM

Event Timeline

ABataev created this revision.Aug 13 2019, 8:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2019, 8:06 AM

This isn't in a hot codepath, so the virtual calls aren't super important.

This not working in some libstdc++s is important of course, but llvm's Errc.h claims "std::error_code works OK on all platforms we use". I guess that's not true? Can you include more details on which platforms this is broken?

This isn't in a hot codepath, so the virtual calls aren't super important.

This not working in some libstdc++s is important of course, but llvm's Errc.h claims "std::error_code works OK on all platforms we use". I guess that's not true? Can you include more details on which platforms this is broken?

PowerPC, Ubuntu 14.04.3 LTS, for example.

std::error_code works correctly, it is std::make_error_code leads to something strange in some cases.

That's Trusty and Trusty is on 4.8 which we no longer support, right?

That's Trusty and Trusty is on 4.8 which we no longer support, right?

It is still supported with some extra cmake flags.

GCC 4.8 is still supported

This small change is okay anyway

Also, there is a clang unit test that fails because of the same reason. Can I include the changes in this test into this patch too or better to make a separate patch? The test is unittests/Basic/FileManagerTest.cpp

As far as I know 4.8 is no longer supported.

That's Trusty and Trusty is on 4.8 which we no longer support, right?

It is still supported with some extra cmake flags.

It used to be, but that's no longer true. r366333 added an unconditional use of <regex> which doesn't exist in 4.8.

As far as I know 4.8 is no longer supported.

That's Trusty and Trusty is on 4.8 which we no longer support, right?

It is still supported with some extra cmake flags.

It used to be, but that's no longer true. r366333 added an unconditional use of <regex> which doesn't exist in 4.8.

This is only for lld. Plus, there was no final decision to drop support for 4.8 and all other LLVM subprojects still can be compiled with 4.8 without any problems.

As far as I know 4.8 is no longer supported.

That's Trusty and Trusty is on 4.8 which we no longer support, right?

It is still supported with some extra cmake flags.

It used to be, but that's no longer true. r366333 added an unconditional use of <regex> which doesn't exist in 4.8.

This is only for lld. Plus, there was no final decision to drop support for 4.8

I'm not sure this is correct

and all other LLVM subprojects still can be compiled with 4.8 without any problems.

Not for long. https://lists.llvm.org/pipermail/llvm-dev/2019-August/134360.html

jfb added a comment.Aug 13 2019, 8:58 AM

As far as I know 4.8 is no longer supported.

That's Trusty and Trusty is on 4.8 which we no longer support, right?

It is still supported with some extra cmake flags.

It used to be, but that's no longer true. r366333 added an unconditional use of <regex> which doesn't exist in 4.8.

This is only for lld. Plus, there was no final decision to drop support for 4.8

I'm not sure this is correct

and all other LLVM subprojects still can be compiled with 4.8 without any problems.

Not for long. https://lists.llvm.org/pipermail/llvm-dev/2019-August/134360.html

4.8 is still supported, but I intend to move the minimum version forward as soon as I find time now that there's no blocker.

thakis accepted this revision.Aug 13 2019, 11:03 AM

Should we revert the change in lld then? LLVM has a global policy for this; if 4.8 is still supported then regex can't be used yet.

Please mention in the commit message that this is a workaround for gcc 4.8; with that lgtm (for another 2 weeks or so ;) ).

This revision is now accepted and ready to land.Aug 13 2019, 11:03 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2019, 12:31 PM

FWIW it looks like 4.8 support is going away in days, not weeks, see D66188.