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

binaryen fails to compile in Arch clean chroot #6740

Open
anatol opened this issue Jul 12, 2024 · 3 comments
Open

binaryen fails to compile in Arch clean chroot #6740

anatol opened this issue Jul 12, 2024 · 3 comments

Comments

@anatol
Copy link

anatol commented Jul 12, 2024

Hi, here is a followup for tinygo-org/tinygo#4332

I am trying to compile tinygo for Arch Linux in its clean build environment. tinygo in turn include binaryen (commit 11dba9b). Compilation for binaryen is invoked and it fails with

[161/230] Building CXX object src/passes/CMakeFiles/passes.dir/SimplifyLocals.cpp.o
FAILED: src/passes/CMakeFiles/passes.dir/SimplifyLocals.cpp.o 
/usr/bin/c++  -I/home/anatol/sources/tinygo/tinygo/lib/binaryen/src -I/home/anatol/sources/tinygo/tinygo/lib/binaryen/third_party/llvm-project/include -I/home/anatol/sources/tinygo/tinygo/lib/binaryen -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -DBUILD_LLVM_DWARF -Wall -Werror -Wextra -Wno-unused-parameter -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/SimplifyLocals.cpp.o -MF src/passes/CMakeFiles/passes.dir/SimplifyLocals.cpp.o.d -o src/passes/CMakeFiles/passes.dir/SimplifyLocals.cpp.o -c /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/passes/SimplifyLocals.cpp
In file included from /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/parsing.h:29,
                 from /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/wasm-builder.h:21,
                 from /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/ir/literal-utils.h:20,
                 from /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/ir/bits.h:21,
                 from /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/ir/properties.h:20,
                 from /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/ir/iteration.h:20,
                 from /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/ir/branch-utils.h:20,
                 from /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/passes/SimplifyLocals.cpp:50:
In constructor ‘wasm::Walker<SubType, VisitorType>::Task::Task(wasm::Walker<SubType, VisitorType>::TaskFunc, wasm::Expression**) [with SubType = wasm::LocalGetCounter; VisitorType = wasm::Visitor<wasm::LocalGetCounter, void>]’,
    inlined from ‘void wasm::SmallVector<T, N>::emplace_back(ArgTypes&& ...) [with ArgTypes = {void (*&)(wasm::LocalGetCounter*, wasm::Expression**), wasm::Expression**&}; T = wasm::Walker<wasm::LocalGetCounter, wasm::Visitor<wasm::LocalGetCounter, void> >::Task; long unsigned int N = 10]’ at /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/support/small_vector.h:73:7,
    inlined from ‘void wasm::Walker<SubType, VisitorType>::pushTask(TaskFunc, wasm::Expression**) [with SubType = wasm::LocalGetCounter; VisitorType = wasm::Visitor<wasm::LocalGetCounter, void>]’ at /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/wasm-traversal.h:314:23,
    inlined from ‘void wasm::Walker<SubType, VisitorType>::walk(wasm::Expression*&) [with SubType = wasm::LocalGetCounter; VisitorType = wasm::Visitor<wasm::LocalGetCounter, void>]’ at /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/wasm-traversal.h:329:13,
    inlined from ‘void wasm::LocalGetCounter::analyze(wasm::Function*, wasm::Expression*)’ at /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/ir/local-utils.h:37:9:
/home/anatol/sources/tinygo/tinygo/lib/binaryen/src/wasm-traversal.h:309:59: error: storing the address of local variable ‘ast’ in ‘*(std::array<wasm::Walker<wasm::LocalGetCounter, wasm::Visitor<wasm::LocalGetCounter, void> >::Task, 10>*)((char*)&_2->stack + 8).std::array<wasm::Walker<wasm::LocalGetCounter, wasm::Visitor<wasm::LocalGetCounter, void> >::Task, 10>::_M_elems[<unknown>].wasm::Walker<wasm::LocalGetCounter, wasm::Visitor<wasm::LocalGetCounter, void> >::Task::currp’ [-Werror=dangling-pointer=]
  309 |     Task(TaskFunc func, Expression** currp) : func(func), currp(currp) {}
      |                                                           ^~~~~~~~~~~~
In file included from /home/anatol/sources/tinygo/tinygo/lib/binaryen/src/passes/SimplifyLocals.cpp:54:
/home/anatol/sources/tinygo/tinygo/lib/binaryen/src/ir/local-utils.h: In member function ‘void wasm::LocalGetCounter::analyze(wasm::Function*, wasm::Expression*)’:
/home/anatol/sources/tinygo/tinygo/lib/binaryen/src/ir/local-utils.h:34:44: note: ‘ast’ declared here
   34 |   void analyze(Function* func, Expression* ast) {
      |                                ~~~~~~~~~~~~^~~
/home/anatol/sources/tinygo/tinygo/lib/binaryen/src/ir/local-utils.h:34:47: note: ‘this’ declared here
   34 |   void analyze(Function* func, Expression* ast) {
      |                                               ^
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option ‘-Wno-implicit-int-float-conversion’ may have been intended to silence earlier diagnostics
cc1plus: all warnings being treated as errors
[169/230] Building CXX object src/wasm/CMakeFiles/wasm.dir/wat-parser.cpp.o
ninja: build stopped: subcommand failed.

Most likely the failure is related to one of the security fortfication flags used by Arch CXXFLAGS="-O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g"

@kripken
Copy link
Member

kripken commented Jul 12, 2024

Hmm, we do take the address of a local there, but it is safe as the call to walk() will fully consume the data with that address. So this looks like a false positive.

But I'm not familiar with that error message so I'm not sure how best to work around it (or if there is a better solution than working around it).

@anatol
Copy link
Author

anatol commented Jul 13, 2024

I tried to google more about this problem. It looks like dangling-pointer warnings were added recently and are prone to false positives. But I don't really know GCC/C++ well enough to debug the problem.

Another part of the issue is that the project enables -Werror by default. Thus any warning (including false positive) becomes compilation error. tinygo plans to disable it by -DENABLE_WERROR=OFF.

@mtb0x1
Copy link
Contributor

mtb0x1 commented Jul 13, 2024

tinygo plans to disable it by -DENABLE_WERROR=OFF.

meanwhile you can try to skip compiling binaryen and use pre-built binaries (you need to install them).

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

No branches or pull requests

3 participants