Skip to content

Unifex with fno exceptions#673

Merged
MaxMotovilov merged 6 commits intofacebookexperimental:mainfrom
aethernetio:unifex-with-fno-exceptions
Feb 1, 2026
Merged

Unifex with fno exceptions#673
MaxMotovilov merged 6 commits intofacebookexperimental:mainfrom
aethernetio:unifex-with-fno-exceptions

Conversation

@BartolomeyKant
Copy link
Contributor

@BartolomeyKant BartolomeyKant commented Jan 26, 2026

Add ability to build with -fno-exceptions.

In general this only fixes use try/catch to UNIFEX_TRY/UNIFEX_CATCH and wrap some code in #if !UNIFEX_NO_EXCEPTIONS ... #endif.

Also this adds run CI testing with -fno-exceptions flag.

This PR related to #671 but still doesn't give the answer to main question.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 26, 2026
@BartolomeyKant BartolomeyKant force-pushed the unifex-with-fno-exceptions branch 2 times, most recently from b4b7dde to 7d27ebb Compare January 26, 2026 11:38
@MaxMotovilov
Copy link
Contributor

Would you mind running clang-format -i on all modified files and then resubmitting? Spurious formatting changes make the diff harder to review.

@BartolomeyKant
Copy link
Contributor Author

Would you mind running clang-format -i on all modified files and then resubmitting? Spurious formatting changes make the diff harder to review.

I did! I mean my IDE configured to automatically format on save.

But it makes a lot of changes. I discarded most of them and tried to format manually only that I really intend to change.
It looks like some of them accidentally was added to commit. I will fix it too.

I'm using clang-format --version

clang-format version 21.1.6

@BartolomeyKant BartolomeyKant force-pushed the unifex-with-fno-exceptions branch from 7d27ebb to 784dc22 Compare January 27, 2026 05:49
@BartolomeyKant BartolomeyKant force-pushed the unifex-with-fno-exceptions branch from 784dc22 to f96b2b7 Compare January 27, 2026 05:53
Copy link
Contributor

@MaxMotovilov MaxMotovilov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some apparently spurious changes in the code that need an explanation; also it is not at all clear how sync_wait() is expected to support set_error() completion.

};
} // namespace _schedule
inline constexpr _schedule::_fn schedule{};
inline const _schedule::_fn schedule{};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty major change - what was the reason behind it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because there is mismatched declaration with detail/unifex_fwd.hpp:76.

I checked other declarations like connect and start and all of it go with inline const.

Btw. I suppose it throws error only on my machine.
I use clang 21.1.6, and gcc 15.2.1.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance you could demonstrate this in a godbolt? Simply including both headers does not currently trigger it w/21.1 and 15.2 respectively although your updated versions could be more recent.

If that's not possible, could you paste the error from your run?

Copy link
Contributor Author

@BartolomeyKant BartolomeyKant Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wrong! It's neither clang nor gcc. It was msvc with /std:c++17.
The error message looks like:

  [1/229] Building CXX object source\CMakeFiles\unifex.dir\async_manual_reset_event.cpp.obj
  FAILED: source/CMakeFiles/unifex.dir/async_manual_reset_event.cpp.obj 
  C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe  /nologo /TP  -IC:\projects\libunifex\include -IC:\projects\libunifex\out\build\x64-Debug\include /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 -std:c++17 /W3 /WX /bigobj /showIncludes /Fosource\CMakeFiles\unifex.dir\async_manual_reset_event.cpp.obj /Fdsource\CMakeFiles\unifex.dir\unifex.pdb /FS -c C:\projects\libunifex\source\async_manual_reset_event.cpp
C:\projects\libunifex\include\unifex\scheduler_concepts.hpp(192): error C2370: 'unifex::schedule': redefinition; different storage class
  C:\projects\libunifex\include\unifex/detail/unifex_fwd.hpp(76): note: see declaration of 'unifex::schedule'
  [2/229] Building CXX object source\CMakeFiles\unifex.dir\async_auto_reset_event.cpp.obj
  FAILED: source/CMakeFiles/unifex.dir/async_auto_reset_event.cpp.obj 
  C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe  /nologo /TP  -IC:\projects\libunifex\include -IC:\projects\libunifex\out\build\x64-Debug\include /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 -std:c++17 /W3 /WX /bigobj /showIncludes /Fosource\CMakeFiles\unifex.dir\async_auto_reset_event.cpp.obj /Fdsource\CMakeFiles\unifex.dir\unifex.pdb /FS -c C:\projects\libunifex\source\async_auto_reset_event.cpp
C:\projects\libunifex\include\unifex\scheduler_concepts.hpp(192): error C2370: 'unifex::schedule': redefinition; different storage class
  C:\projects\libunifex\include\unifex/detail/unifex_fwd.hpp(76): note: see declaration of 'unifex::schedule'
  [3/229] Building CXX object googletest-build\googletest\CMakeFiles\gtest.dir\src\gtest-all.cc.obj
C:\projects\libunifex\out\build\x64-Debug\cl : Command line warning D9025: overriding '/W4' with '/W3'
  ninja: build stopped: subcommand failed.

I can revert this change and fix it when I figured out what's wrong with building on msvc /std:c++17

Any chance you could demonstrate this in a godbolt?

For some reason I could not make an example with msvc on godbolt. https://godbolt.org/z/sb48aYav6

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW. With this fix msvc still fails with a ton of different errors.

msvc_build_failed.log

@MaxMotovilov
Copy link
Contributor

MaxMotovilov commented Jan 31, 2026

See my new inline comments - also I think macOS clang makes an objection? https://github.com/facebookexperimental/libunifex/actions/runs/21514257277/job/62090827242?pr=673

@BartolomeyKant
Copy link
Contributor Author

BartolomeyKant commented Feb 1, 2026

I think macOS clang makes an objection? https://github.com/facebookexperimental/libunifex/actions/runs/21514257277/job/62090827242?pr=673

I did not touch this test on this PR. And it also runs successfully on my machine and my repository.

101/101 Test  #40: test-async_mutex_v2_test ................***Timeout 1500.18 sec
Running main() from googletest-src/googletest/src/gtest_main.cc
[==========] Running 6 tests from 2 test suites.
[----------] Global test environment set-up.
[----------] 1 test from async_mutex_v2
[ RUN      ] async_mutex_v2.multiple_threads

I would like to rerun this test. And maybe someone find how to fix this bug in the future.

@MaxMotovilov MaxMotovilov merged commit af6cacf into facebookexperimental:main Feb 1, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants