You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
binaryen fails to build from source with LTO (link time optimization) enabled #5946
Debian wants to enable link time optimization in the near future but binaryen 116 fails to build from source when LTO is enabled.
The error seems to be caused by third party code in third_party/llvm-project
third_party/llvm-project/./third_party/llvm-project/include/llvm/ADT/edit_distance.h: In function ‘ComputeEditDistance’:
third_party/llvm-project/./third_party/llvm-project/include/llvm/ADT/edit_distance.h:96:12: error: ‘SmallBuffer’ may be used uninitialized [-Werror=maybe-uninitialized]
third_party/llvm-project/./third_party/llvm-project/include/llvm/ADT/edit_distance.h:61:12: note: ‘SmallBuffer’ declared here
lto1: all warnings being treated as errors
make[4]: *** [/tmp/ccrE0idZ.mk:365: /tmp/ccqqy1Bf.ltrans121.ltrans.o] Error 1
make[4]: *** Waiting for unfinished jobs....
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Would it be possible to build there with -DBUILD_LLVM_DWARF=OFF? That would disable using this third-party code, which is only used for Binaryen's partial DWARF support (edit: because it's partial, I don't think many people actually depend on it. we don't build it into binaryen.js for example).
Hi,
then I get another error because Allocator.h is part of the disabled llvm-project directory
In file included from /<<PKGBUILDDIR>>/src/support/suffix_tree.cpp:16:
/<<PKGBUILDDIR>>/src/support/suffix_tree.h:38:10: fatal error: llvm/Support/Allocator.h: No such file or directory
38 | #include "llvm/Support/Allocator.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
Hmm, looks related to @ashleynh's work on the suffix tree. Building just that without LLVM errors it seems. Looks like we don't have a flag to disable the suffix tree, and instead we manually disable it in binaryen.js (emscripten) builds, which do not build LLVM:
Perhaps we should add such a flag? Another option might be to find a workaround in that source file. I'm not sure how to do that, though, since LTO shouldn't affect compile-time errors... so that error is odd. But @apoleon , does this patch fix things for you?
The patch didn't make a difference for me. I still get the same error. But when I set the ENABLE_WERROR flag in CMakeLists to OFF instead, it works. Maybe there is a better solution but as a quick workaround it already helps.
Activity
kripken commentedon Sep 18, 2023
Would it be possible to build there with
-DBUILD_LLVM_DWARF=OFF? That would disable using this third-party code, which is only used for Binaryen's partial DWARF support (edit: because it's partial, I don't think many people actually depend on it. we don't build it intobinaryen.jsfor example).apoleon commentedon Sep 18, 2023
Hi,
then I get another error because Allocator.h is part of the disabled llvm-project directory
kripken commentedon Sep 18, 2023
Hmm, looks related to @ashleynh's work on the suffix tree. Building just that without LLVM errors it seems. Looks like we don't have a flag to disable the suffix tree, and instead we manually disable it in
binaryen.js(emscripten) builds, which do not build LLVM:binaryen/src/support/CMakeLists.txt
Lines 18 to 30 in 003a6ff
Perhaps we should add such a flag? Another option might be to find a workaround in that source file. I'm not sure how to do that, though, since LTO shouldn't affect compile-time errors... so that error is odd. But @apoleon , does this patch fix things for you?
If it works then it might be the quickest fix here.
apoleon commentedon Sep 18, 2023
The patch didn't make a difference for me. I still get the same error. But when I set the ENABLE_WERROR flag in CMakeLists to OFF instead, it works. Maybe there is a better solution but as a quick workaround it already helps.
Fix Apline compile error on uninitialized value (#7035)
rathann commentedon Feb 26, 2025
I suggest building with
-DENABLE_WERROR=OFFinstead. We do that on Fedora.tlively commentedon Mar 3, 2025
Closing this because turning Werror off is pretty much the only correct solution in situations like this.
GulgDev commentedon Apr 9, 2025
I get this error when building on Windows like this:
tlively commentedon Apr 9, 2025
@GulgDev, can you open a new issue with details about your build config and the error you're getting?