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 compilation under gcc 14. #6912

Merged
merged 1 commit into from
Sep 9, 2024
Merged

Conversation

smoser
Copy link
Contributor

@smoser smoser commented Sep 6, 2024

This probably isn't the ideal solution but it did allow me to get binaryen building with gcc 14.2.

Fixes: #6779

This probably isn't the ideal solution but it did allow me
to get binaryen building with gcc 14.2.

Fixes: WebAssembly#6779
@kripken
Copy link
Member

kripken commented Sep 6, 2024

Thanks for the PR!

Hmm, this would be the 6th such workaround we have for gcc, all for the same or similar reasons. Perhaps we should just disable -Wuninitialized/-Wmaybe-uninitialized in gcc? We would still have coverage from clang.

I don't feel strongly though. Also @tlively might have a specific parser idea here.

@tlively
Copy link
Member

tlively commented Sep 7, 2024

Hehe, I see you've changed your opinion since the discussion in #6779. Turning this option off for GCC still sounds good to me.

@kripken
Copy link
Member

kripken commented Sep 9, 2024

Yeah, I guess I'm waffling here... 😄 but I still don't feel strongly either way. This PR as is, or changed to disable the warning in gcc globally, both sgtm. (I'm not sure offhand if it's simple to detect gcc in CMakeLists - if not, let's go with this PR as is.)

@tlively
Copy link
Member

tlively commented Sep 9, 2024

Let's at least land this as a quick fix. The next time this comes up we can investigate a CMake change.

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Sounds good.

@kripken kripken merged commit 0b07c1b into WebAssembly:main Sep 9, 2024
13 checks passed
kripken added a commit that referenced this pull request Oct 28, 2024
Similar to

* #6330
* #6311
* #6912
* #5946

This extends the region we ignore the gcc warning in.

The warning:

ninja: job failed: /usr/bin/c++  -I/src/src -I/src/third_party/FP16/include -I/src/third_party/llvm-project/include -I/src -static -DBUILD_LLVM_DWARF -Wall -Werror -Wextra -Wno-unused-parameter -Wno-dangling-pointer -fno-omit-frame-pointer -fno-rtti -Wno-implicit-int-float-conversion -Wno-unknown-warning-option -Wswitch -Wimplicit-fallthrough -Wnon-virtual-dtor -fPIC -fdiagnostics-color=always -O3 -DNDEBUG -UNDEBUG -std=c++17 -MD -MT src/passes/CMakeFiles/passes.dir/Precompute.cpp.o -MF src/passes/CMakeFiles/passes.dir/Precompute.cpp.o.d -o src/passes/CMakeFiles/passes.dir/Precompute.cpp.o -c /src/src/passes/Precompute.cpp
In file included from /src/src/literal.h:27,
                 from /src/src/wasm.h:36,
                 from /src/src/ir/boolean.h:20,
                 from /src/src/ir/bits.h:20,
                 from /src/src/ir/properties.h:20,
                 from /src/src/ir/iteration.h:20,
                 from /src/src/passes/Precompute.cpp:30:
In copy constructor 'wasm::SmallVector<T, N>::SmallVector(const wasm::SmallVector<T, N>&) [with T = wasm::Expression*; long unsigned int N = 10]',
    inlined from 'constexpr std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _U1 = wasm::Select* const; _U2 = wasm::SmallVector<wasm::Expression*, 10>; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_ConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = true; _T1 = wasm::Select* const; _T2 = wasm::SmallVector<wasm::Expression*, 10>]' at /usr/include/c++/13.2.1/bits/stl_pair.h:559:21,
    inlined from 'T& wasm::InsertOrderedMap<Key, T>::operator[](const Key&) [with Key = wasm::Select*; T = wasm::SmallVector<wasm::Expression*, 10>]' at /src/src/support/insert_ordered.h:112:29,
    inlined from 'void wasm::Precompute::partiallyPrecompute(wasm::Function*)::StackFinder::visitSelect(wasm::Select*)' at /src/src/passes/Precompute.cpp:571:24,
    inlined from 'static void wasm::Walker<SubType, VisitorType>::doVisitSelect(SubType*, wasm::Expression**) [with SubType = wasm::Precompute::partiallyPrecompute(wasm::Function*)::StackFinder; VisitorType = wasm::Visitor<wasm::Precompute::partiallyPrecompute(wasm::Function*)::StackFinder, void>]' at /src/src/wasm-delegations.def:50:1:
/src/src/support/small_vector.h:69:35: error: '<unnamed>.wasm::SmallVector<wasm::Expression*, 10>::fixed' may be used uninitialized [-Werror=maybe-uninitialized]
   69 |     : usedFixed(other.usedFixed), fixed(other.fixed), flexible(other.flexible) {
      |                                   ^~~~~~~~~~~~~~~~~~
In file included from /src/src/passes/Precompute.cpp:37:
/src/src/support/insert_ordered.h: In static member function 'static void wasm::Walker<SubType, VisitorType>::doVisitSelect(SubType*, wasm::Expression**) [with SubType = wasm::Precompute::partiallyPrecompute(wasm::Function*)::StackFinder; VisitorType = wasm::Visitor<wasm::Precompute::partiallyPrecompute(wasm::Function*)::StackFinder, void>]':
/src/src/support/insert_ordered.h:112:29: note: '<anonymous>' declared here
  112 |     std::pair<const Key, T> kv = {k, {}};
      |                             ^~
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.

GCC maybe-uninitialized failure
3 participants