grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.51k stars 318 forks source link

Build on Ubuntu 14: error: there are no arguments to ‘__builtin_sadd_overflow’ that depend on a template parameter, so a declaration of ‘__builtin_sadd_overflow’ must be available #104

Closed sdaau closed 4 years ago

sdaau commented 6 years ago

I'm trying to build faust from source; the same error happens in both the (new) master branch, and the old-faust2 branch. This is what I did:

# as per ./installer/ubuntu1404/install.regular.sh:
sudo apt-get install -y build-essential pkg-config git
sudo apt-get install jackd2
sudo apt-get install libmicrohttpd-dev llvm-3.6 libssl-dev ncurses-dev libsndfile-dev libgtk2.0-dev libasound2-dev libjack-jackd2-dev

git clone https://github.com/grame-cncm/faust.git faust_git
cd faust_git
git checkout master
make -j 4 world

The build runs fine for a while, and then:

...
g++ -std=gnu++11 -O1 -fPIC -D__USE_MINGW_ANSI_STDIO -Wall -Wuninitialized -Wno-parentheses -Wno-overloaded-virtual -fvisibility=hidden -I. -Iboxes -Ierrors -Ievaluate -Inormalize -Iparser -Ipropagate -Iparallelize -Isignals -Itlib -Idraw -Idraw/device -Idraw/schema -Iextended -Ipatternmatcher -Idocumentator -Iutils -I../libraries -Igenerator -Igenerator/asmjs -Igenerator/c -Igenerator/cpp -Igenerator/java -Igenerator/js -Igenerator/llvm -Igenerator/fir -Igenerator/wasm -Igenerator/interpreter -Igenerator/rust -DINSTALL_PREFIX='"/usr/local"' -I`/usr/bin/llvm-config-3.6 --includedir` -I../architecture -DLLVM_36 -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS  -DASMJS_BUILD -DC_BUILD -DCPP_BUILD -DFIR_BUILD -DINTERP_BUILD -DJAVA_BUILD -DJS_BUILD -DLLVM_BUILD -DOCPP_BUILD -DRUST_BUILD -DWASM_BUILD -O3   -c -o utils/names.o utils/names.cpp
...
In file included from generator/interpreter/interpreter_dsp_aux.hh:37:0,
                 from generator/interpreter/interpreter_code_container.hh:26,
                 from generator/interpreter/interpreter_code_container.cpp:26,
                 from libcode.cpp:79:
generator/interpreter/fir_interpreter.hh: In member function ‘void FIRInterpreter<T, TRACE>::ExecuteBlock(FIRBlockInstruction<T>*)’:
generator/interpreter/fir_interpreter.hh:800:69: error: there are no arguments to ‘__builtin_sadd_overflow’ that depend on a template parameter, so a declaration of ‘__builtin_sadd_overflow’ must be available [-fpermissive]
                             if (__builtin_sadd_overflow(v1, v2, &res)) {
                                                                     ^
generator/interpreter/fir_interpreter.hh:800:69: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
generator/interpreter/fir_interpreter.hh:824:69: error: there are no arguments to ‘__builtin_ssub_overflow’ that depend on a template parameter, so a declaration of ‘__builtin_ssub_overflow’ must be available [-fpermissive]
                             if (__builtin_ssub_overflow(v1, v2, &res)) {
                                                                     ^
generator/interpreter/fir_interpreter.hh:848:69: error: there are no arguments to ‘__builtin_smul_overflow’ that depend on a template parameter, so a declaration of ‘__builtin_smul_overflow’ must be available [-fpermissive]
                             if (__builtin_smul_overflow(v1, v2, &res)) {
                                                                     ^
...

This is kinda weird, since __builtin_sadd_overflow should be, well, built-in - as noted in https://clang.llvm.org/docs/LanguageExtensions.html#checked-arithmetic-builtins

Is there a way around this error?

sdaau commented 6 years ago

I managed to compile finally; this is what I think the issue is:

Under Linux/Ubuntu, g++ is the proper GNU version used. On Ubuntu 14.04, the default g++ has version 4.8.4; however:

https://stackoverflow.com/questions/27194771/bool-builtin-sadd-overflow-int-a-int-b-int-res-not-declared

https://gcc.gnu.org/onlinedocs/gcc-4.8.3/gcc/C-Extensions.html (documentation for the 4.8.3 release) does not mention the overflow builtins. The unversioned address https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html corresponds to the documentation for the development version of gcc (the future gcc-5). You can wait until March or April, or start playing with a snapshot, or use clang's equivalent.

I independently tried to build LLVM 5.0 ( that version can still be built with gcc 4.8* on Ubuntu 14.04, although it is quite a nasty process, see http://svn.code.sf.net/p/sdaaubckp/code/source-build-scripts/get_llvm_source_u1404.sh ), and managed to do so - however, that in itself was possibly not necessary.

What was necessary, however, is that the compilation is manually repeated for all those files, where the __builtin_ stuff fails, by copying the command line printed by the faust make process, and then replacing the g++ in it with clang++-5.0. This then requires stddef.h, stdarg.h and similar headers; however, using the default Linux headers (say, in /usr/include) causes compilation to fail again. And here it is important that the stddef.h, stdarg.h are used from the LLVM source, which in my case are in /path/to/llvm-toolchain/branches/llvm-toolchain-5.0_5.0~svn319231/clang_5.0~svn319231/lib/Headers - and also this directory needs to be added to the compile line as an -Include directory; in all, these are the files that I had to manually build in this way:

(cd compiler; clang++-5.0 -std=c++11 -O1 -fPIC -D__USE_MINGW_ANSI_STDIO -Wall -Wuninitialized -Wno-parentheses -Wno-overloaded-virtual -fvisibility=hidden -I. -Iboxes -Ierrors -Ievaluate -Inormalize -Iparser -Ipropagate -Iparallelize -Isignals -Itlib -Idraw -Idraw/device -Idraw/schema -Iextended -Ipatternmatcher -Idocumentator -Iutils -I../libraries -Igenerator -Igenerator/asmjs -Igenerator/c -Igenerator/cpp -Igenerator/java -Igenerator/js -Igenerator/llvm -Igenerator/fir -Igenerator/wasm -Igenerator/interpreter -Igenerator/rust -DINSTALL_PREFIX='"/usr/local"' -I`/usr/bin/llvm-config-5.0 --includedir` -I../architecture -DLLVM_50 -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS  -DASMJS_BUILD -DC_BUILD -DCPP_BUILD -DFIR_BUILD -DINTERP_BUILD -DJAVA_BUILD -DJS_BUILD -DLLVM_BUILD -DOCPP_BUILD -DRUST_BUILD -DWASM_BUILD -I/path/to/llvm-toolchain/branches/llvm-toolchain-5.0_5.0~svn319231/clang_5.0~svn319231/lib/Headers  -O3   -c -o global.o global.cpp)
(cd compiler; clang++-5.0 -std=gnu++11 -O1 -fPIC -D__USE_MINGW_ANSI_STDIO -Wall -Wuninitialized -Wno-parentheses -Wno-overloaded-virtual -fvisibility=hidden -I. -Iboxes -Ierrors -Ievaluate -Inormalize -Iparser -Ipropagate -Iparallelize -Isignals -Itlib -Idraw -Idraw/device -Idraw/schema -Iextended -Ipatternmatcher -Idocumentator -Iutils -I../libraries -Igenerator -Igenerator/asmjs -Igenerator/c -Igenerator/cpp -Igenerator/java -Igenerator/js -Igenerator/llvm -Igenerator/fir -Igenerator/wasm -Igenerator/interpreter -Igenerator/rust -DINSTALL_PREFIX='"/usr/local"' -I`/usr/bin/llvm-config-5.0 --includedir` -I../architecture -DLLVM_50 -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS  -DASMJS_BUILD -DC_BUILD -DCPP_BUILD -DFIR_BUILD -DINTERP_BUILD -DJAVA_BUILD -DJS_BUILD -DLLVM_BUILD -DOCPP_BUILD -DRUST_BUILD -DWASM_BUILD -I/path/to/llvm-toolchain/branches/llvm-toolchain-5.0_5.0~svn319231/clang_5.0~svn319231/lib/Headers -O3   -c -o libcode.o libcode.cpp)
(cd compiler; clang++-5.0 -std=gnu++11 -O1 -fPIC -D__USE_MINGW_ANSI_STDIO -Wall -Wuninitialized -Wno-parentheses -Wno-overloaded-virtual -fvisibility=hidden -I. -Iboxes -Ierrors -Ievaluate -Inormalize -Iparser -Ipropagate -Iparallelize -Isignals -Itlib -Idraw -Idraw/device -Idraw/schema -Iextended -Ipatternmatcher -Idocumentator -Iutils -I../libraries -Igenerator -Igenerator/asmjs -Igenerator/c -Igenerator/cpp -Igenerator/java -Igenerator/js -Igenerator/llvm -Igenerator/fir -Igenerator/wasm -Igenerator/interpreter -Igenerator/rust -DINSTALL_PREFIX='"/usr/local"' -I`/usr/bin/llvm-config-5.0 --includedir` -I../architecture -DLLVM_50 -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS  -DASMJS_BUILD -DC_BUILD -DCPP_BUILD -DFIR_BUILD -DINTERP_BUILD -DJAVA_BUILD -DJS_BUILD -DLLVM_BUILD -DOCPP_BUILD -DRUST_BUILD -DWASM_BUILD -I/path/to/llvm-toolchain/branches/llvm-toolchain-5.0_5.0~svn319231/clang_5.0~svn319231/lib/Headers -O3   -c -o generator/interpreter/interpreter_code_container.o generator/interpreter/interpreter_code_container.cpp)
(cd compiler; clang++-5.0 -std=gnu++11 -O1 -fPIC -D__USE_MINGW_ANSI_STDIO -Wall -Wuninitialized -Wno-parentheses -Wno-overloaded-virtual -fvisibility=hidden -I. -Iboxes -Ierrors -Ievaluate -Inormalize -Iparser -Ipropagate -Iparallelize -Isignals -Itlib -Idraw -Idraw/device -Idraw/schema -Iextended -Ipatternmatcher -Idocumentator -Iutils -I../libraries -Igenerator -Igenerator/asmjs -Igenerator/c -Igenerator/cpp -Igenerator/java -Igenerator/js -Igenerator/llvm -Igenerator/fir -Igenerator/wasm -Igenerator/interpreter -Igenerator/rust -DINSTALL_PREFIX='"/usr/local"' -I`/usr/bin/llvm-config-5.0 --includedir` -I../architecture -DLLVM_50 -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS  -DASMJS_BUILD -DC_BUILD -DCPP_BUILD -DFIR_BUILD -DINTERP_BUILD -DJAVA_BUILD -DJS_BUILD -DLLVM_BUILD -DOCPP_BUILD -DRUST_BUILD -DWASM_BUILD -I/path/to/llvm-toolchain/branches/llvm-toolchain-5.0_5.0~svn319231/clang_5.0~svn319231/lib/Headers -O3   -c -o generator/interpreter/interpreter_dsp_aux.o generator/interpreter/interpreter_dsp_aux.cpp)

After these files are compiled "manually", then I could run make -j 4 world again, and the compilation process completes for faust.

Not sure if this should be mentioned in the documentation, or ./installer/ubuntu1404/install.regular.sh.


EDIT: just removed the LLVM 5.0 packages I built, and did instead sudo apt-get install llvm-3.5 clang-3.5; the same trick with copying build lines and replacing g++ with clang++ works, and this time it is not required to add the -Include directory; so the manual files build commands are:

(cd compiler; clang++-3.5 -std=gnu++11 -O1 -fPIC -D__USE_MINGW_ANSI_STDIO -Wall -Wuninitialized -Wno-parentheses -Wno-overloaded-virtual -fvisibility=hidden -I. -Iboxes -Ierrors -Ievaluate -Inormalize -Iparser -Ipropagate -Iparallelize -Isignals -Itlib -Idraw -Idraw/device -Idraw/schema -Iextended -Ipatternmatcher -Idocumentator -Iutils -I../libraries -Igenerator -Igenerator/asmjs -Igenerator/c -Igenerator/cpp -Igenerator/java -Igenerator/js -Igenerator/llvm -Igenerator/fir -Igenerator/wasm -Igenerator/interpreter -Igenerator/rust -DINSTALL_PREFIX='"/usr/local"' -I`/usr/bin/llvm-config-3.5 --includedir` -I../architecture -DLLVM_35 -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS  -DASMJS_BUILD -DC_BUILD -DCPP_BUILD -DFIR_BUILD -DINTERP_BUILD -DJAVA_BUILD -DJS_BUILD -DLLVM_BUILD -DOCPP_BUILD -DRUST_BUILD -DWASM_BUILD -O3   -c -o global.o global.cpp)
(cd compiler; clang++-3.5 -std=gnu++11 -O1 -fPIC -D__USE_MINGW_ANSI_STDIO -Wall -Wuninitialized -Wno-parentheses -Wno-overloaded-virtual -fvisibility=hidden -I. -Iboxes -Ierrors -Ievaluate -Inormalize -Iparser -Ipropagate -Iparallelize -Isignals -Itlib -Idraw -Idraw/device -Idraw/schema -Iextended -Ipatternmatcher -Idocumentator -Iutils -I../libraries -Igenerator -Igenerator/asmjs -Igenerator/c -Igenerator/cpp -Igenerator/java -Igenerator/js -Igenerator/llvm -Igenerator/fir -Igenerator/wasm -Igenerator/interpreter -Igenerator/rust -DINSTALL_PREFIX='"/usr/local"' -I`/usr/bin/llvm-config-3.5 --includedir` -I../architecture -DLLVM_35 -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS  -DASMJS_BUILD -DC_BUILD -DCPP_BUILD -DFIR_BUILD -DINTERP_BUILD -DJAVA_BUILD -DJS_BUILD -DLLVM_BUILD -DOCPP_BUILD -DRUST_BUILD -DWASM_BUILD -O3   -c -o generator/interpreter/interpreter_dsp_aux.o generator/interpreter/interpreter_dsp_aux.cpp)
(cd compiler; clang++-3.5 -std=gnu++11 -O1 -fPIC -D__USE_MINGW_ANSI_STDIO -Wall -Wuninitialized -Wno-parentheses -Wno-overloaded-virtual -fvisibility=hidden -I. -Iboxes -Ierrors -Ievaluate -Inormalize -Iparser -Ipropagate -Iparallelize -Isignals -Itlib -Idraw -Idraw/device -Idraw/schema -Iextended -Ipatternmatcher -Idocumentator -Iutils -I../libraries -Igenerator -Igenerator/asmjs -Igenerator/c -Igenerator/cpp -Igenerator/java -Igenerator/js -Igenerator/llvm -Igenerator/fir -Igenerator/wasm -Igenerator/interpreter -Igenerator/rust -DINSTALL_PREFIX='"/usr/local"' -I`/usr/bin/llvm-config-3.5 --includedir` -I../architecture -DLLVM_35 -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS  -DASMJS_BUILD -DC_BUILD -DCPP_BUILD -DFIR_BUILD -DINTERP_BUILD -DJAVA_BUILD -DJS_BUILD -DLLVM_BUILD -DOCPP_BUILD -DRUST_BUILD -DWASM_BUILD -O3   -c -o generator/interpreter/interpreter_code_container.o generator/interpreter/interpreter_code_container.cpp)
(cd compiler; clang++-3.5 -std=gnu++11 -O1 -fPIC -D__USE_MINGW_ANSI_STDIO -Wall -Wuninitialized -Wno-parentheses -Wno-overloaded-virtual -fvisibility=hidden -I. -Iboxes -Ierrors -Ievaluate -Inormalize -Iparser -Ipropagate -Iparallelize -Isignals -Itlib -Idraw -Idraw/device -Idraw/schema -Iextended -Ipatternmatcher -Idocumentator -Iutils -I../libraries -Igenerator -Igenerator/asmjs -Igenerator/c -Igenerator/cpp -Igenerator/java -Igenerator/js -Igenerator/llvm -Igenerator/fir -Igenerator/wasm -Igenerator/interpreter -Igenerator/rust -DINSTALL_PREFIX='"/usr/local"' -I`/usr/bin/llvm-config-3.5 --includedir` -I../architecture -DLLVM_35 -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS  -DASMJS_BUILD -DC_BUILD -DCPP_BUILD -DFIR_BUILD -DINTERP_BUILD -DJAVA_BUILD -DJS_BUILD -DLLVM_BUILD -DOCPP_BUILD -DRUST_BUILD -DWASM_BUILD -O3   -c -o libcode.o libcode.cpp)

This is enough for make world, and to have make succeed, one also needs sudo apt-get install libedit-dev ( via https://stackoverflow.com/questions/27926618/linker-issues-with-ledit-ubuntu-14-10/27928077 )