Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cmake): avoid really slow compile on emscripten #4642

Merged
merged 2 commits into from Nov 16, 2023

Conversation

henryiii
Copy link
Collaborator

This is really slow on emscripten cross-compiles to WebAssembly. I think it's safe just to hard-code it when cross-compiling to emscripten. (Thoughts welcome).

Description

Suggested changelog entry:

* Hardcode lto/thin lto for Emscripten cross-compiles.

@henryiii henryiii changed the title fix: avoid really slow compile on emscripten fix(cmake): avoid really slow compile on emscripten Apr 28, 2023
@henryiii
Copy link
Collaborator Author

We might want to solve this error when LTO flags are missing:

[ 86%] Building CXX object tests/CMakeFiles/pybind11_tests.dir/test_stl_binders.cpp.o
cd /home/runner/work/pybind11/pybind11/tests && /usr/bin/c++ -DBOOST_ALL_NO_LIB -DPYBIND11_SIMPLE_GIL_MANAGEMENT -DPYBIND11_TEST_BOOST -DPYBIND11_TEST_EIGEN -Dpybind11_tests_EXPORTS -I/home/runner/work/pybind11/pybind11/include -isystem /opt/hostedtoolcache/Python/3.9.16/x64/include/python3.9 -isystem /home/runner/work/pybind11/pybind11/_deps/eigen-src -Os -DNDEBUG -std=c++11 -fPIC -fvisibility=hidden -Wall -Wextra -Wconversion -Wcast-qual -Wdeprecated -Wundef -Wnon-virtual-dtor -Werror -MD -MT tests/CMakeFiles/pybind11_tests.dir/test_stl_binders.cpp.o -MF CMakeFiles/pybind11_tests.dir/test_stl_binders.cpp.o.d -o CMakeFiles/pybind11_tests.dir/test_stl_binders.cpp.o -c /home/runner/work/pybind11/pybind11/tests/test_stl_binders.cpp
In file included from /home/runner/work/pybind11/pybind11/include/pybind11/stl.h:12,
                 from /home/runner/work/pybind11/pybind11/tests/test_stl.cpp:10:
/home/runner/work/pybind11/pybind11/include/pybind11/pybind11.h: In static member function ‘static pybind11::handle pybind11::cpp_function::initialize(Func&&, Return (*)(Args ...), const Extra& ...) [with Func = test_submodule_stl(pybind11::module_&)::<lambda(const boost_opt_no_assign&)>; Return = int; Args = {const boost::optional<test_submodule_stl(pybind11::module_&)::NoAssign>&}; Extra = {pybind11::name, pybind11::scope, pybind11::sibling, pybind11::arg_v}]::<lambda(pybind11::detail::function_call&)>::_FUN(pybind11::detail::function_call&)’:
/home/runner/work/pybind11/pybind11/include/pybind11/pybind11.h:248:33: error: ‘*((void*)& args_converter +4)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  248 |                 = cast_out::cast(std::move(args_converter).template call<Return, Guard>(cap->f),
      |                   ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  249 |                                  policy,
      |                                  ~~~~~~~
  250 |                                  call.parent);
      |                                  ~~~~~~~~~~~~
/home/runner/work/pybind11/pybind11/include/pybind11/pybind11.h:224:21: note: ‘*((void*)& args_converter +4)’ was declared here
  224 |             cast_in args_converter;
      |                     ^~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [tests/CMakeFiles/pybind11_tests.dir/build.make:580: tests/CMakeFiles/pybind11_tests.dir/test_stl.cpp.o] Error 1

But first I'm fixing the missing LTO flag. :)

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
tools/pybind11Common.cmake Outdated Show resolved Hide resolved
@henryiii
Copy link
Collaborator Author

@hoodmane, does this look okay? Emscripten should always use clang, which has lto & thin lto?

@hoodmane
Copy link

Emscripten should always use clang, which has lto & thin lto?

Yes, and it's often a problem that configuration stuff is super slow on Emscripten so it's great to hard code things that will be true on a very recent clang.

@henryiii henryiii merged commit 6cf90e7 into pybind:master Nov 16, 2023
79 checks passed
@henryiii henryiii deleted the henryiii/fix/emscripten1 branch November 16, 2023 05:50
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Nov 16, 2023
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants