Seems broken with latest AFL++ ?
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/support/Any.h:125:51: error: self-comparison always evaluates to true [-Werror=tautological-compare]
125 | template<int N = 0, typename std::enable_if<N == N && std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
| ~~^~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/support/Any.h:130:51: error: self-comparison always evaluates to true [-Werror=tautological-compare]
130 | template<int N = 0, typename std::enable_if<N == N && !std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
| ~~^~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/tree/ParseTree.h:49:18: error: ‘virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const’ was hidden [-Werror=overloaded-virtual=]
49 | virtual bool operator == (const ParseTree &other) const;
| ^~~~~~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/RuleContext.h:131:10: note: by ‘bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)’
131 | bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
| ^~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:51: antlr4_shim.o] Error 1
make[2]: Leaving directory '/home/s0urc3/Downloads/Grammar-Mutator/lib/antlr4_shim'
make[1]: *** [Makefile:25: antlr4_shim] Error 2
make[1]: Leaving directory '/home/s0urc3/Downloads/Grammar-Mutator/lib'
make: *** [GNUmakefile:120: build_lib] Error 2
Maybe try either updating antlr4-cpp-runtime or disable these errors?
Tried latest version of antlr4 and the one from the readme. Got this error again, which is weird bc it used to work perfectly fine
gnu++14 -fPIC -Wno-attributes -Wall -Wextra -Werror -O3 -o antlr4_shim.o -c antlr4_shim.cpp
In file included from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/tree/ParseTree.h:8,
from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/RuleContext.h:8,
from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/ParserRuleContext.h:8,
from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/InterpreterRuleContext.h:8,
from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/antlr4-runtime.h:30,
from antlr4_shim.cpp:21:
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/support/Any.h:125:51: error: self-comparison always evaluates to true [-Werror=tautological-compare]
125 | template<int N = 0, typename std::enable_if<N == N && std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
| ~~^~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/support/Any.h:130:51: error: self-comparison always evaluates to true [-Werror=tautological-compare]
130 | template<int N = 0, typename std::enable_if<N == N && !std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
| ~~^~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/tree/ParseTree.h:49:18: error: ‘virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const’ was hidden [-Werror=overloaded-virtual=]
49 | virtual bool operator == (const ParseTree &other) const;
| ^~~~~~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/RuleContext.h:131:10: note: by ‘bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)’
131 | bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
| ^~~~~~~~
In file included from antlr4_shim.cpp:22:
./generated/GrammarLexer.h:263:16: error: ‘SerializedATNView’ in namespace ‘antlr4::atn’ does not name a type
263 | antlr4::atn::SerializedATNView getSerializedATN() const override;
| ^~~~~~~~~~~~~~~~~
In file included from antlr4_shim.cpp:23:
./generated/GrammarParser.h:256:64: error: ‘ParserATNSimulatorOptions’ in namespace ‘antlr4::atn’ does not name a type; did you mean ‘ParserATNSimulator’?
256 | GrammarParser(antlr4::TokenStream *input, const antlr4::atn::ParserATNSimulatorOptions &options);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| ParserATNSimulator
./generated/GrammarParser.h:268:16: error: ‘SerializedATNView’ in namespace ‘antlr4::atn’ does not name a type
268 | antlr4::atn::SerializedATNView getSerializedATN() const override;
| ^~~~~~~~~~~~~~~~~
antlr4_shim.cpp: In function ‘tree_t* tree_from_buf(const uint8_t*, size_t)’:
antlr4_shim.cpp:84:22: error: cannot declare variable ‘lexer’ to be of abstract type ‘GrammarLexer’
84 | GrammarLexer lexer(&input);
| ^~~~~
./generated/GrammarLexer.h:12:8: note: because the following virtual functions are pure within ‘GrammarLexer’:
12 | class GrammarLexer : public antlr4::Lexer {
| ^~~~~~~~~~~~
In file included from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/Lexer.h:8,
from /home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/antlr4-runtime.h:31:
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/Recognizer.h:28:45: note: ‘virtual const std::vector<std::__cxx11::basic_string<char> >& antlr4::Recognizer::getTokenNames() const’
28 | virtual std::vector<std::string> const& getTokenNames() const = 0;
| ^~~~~~~~~~~~~
antlr4_shim.cpp:91:19: error: cannot declare variable ‘parser’ to be of abstract type ‘GrammarParser’
91 | GrammarParser parser(&tokens);
| ^~~~~~
./generated/GrammarParser.h:12:8: note: because the following virtual functions are pure within ‘GrammarParser’:
12 | class GrammarParser : public antlr4::Parser {
| ^~~~~~~~~~~~~
/home/s0urc3/Downloads/Grammar-Mutator/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/Recognizer.h:28:45: note: ‘virtual const std::vector<std::__cxx11::basic_string<char> >& antlr4::Recognizer::getTokenNames() const’
28 | virtual std::vector<std::string> const& getTokenNames() const = 0;
| ^~~~~~~~~~~~~
I have three options to fix the broken build:
- Use an older compiler version
- Disable the
-Werrorflag in the build system - Fix the root cause of the problem
1. Older Compiler
The build fails with g++-13 but succeeds with g++-11 (I haven't tested at other compilers). Install the older compiler and run the build:
apt install -y g++-11
mkdir build && cd build
cmake .. -DANTLR_JAR_LOCATION=/path/to/antlr-4.8-complete.jar -DGRAMMAR_FILE=/path/to/Grammar-Mutator/grammars/ruby.json -DCMAKE_CXX_COMPILER=g++-11
cmake --build .
2. Disabling -Werror flag
- Create a file named
disable_Werror.patchwith the following content:diff --git a/CMakeLists.txt b/CMakeLists.txt index c94eba0..32ba7cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ endif () # Set -Wall -Wextra -Werror set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") # Do not disable assertions based on CMAKE_BUILD_TYPE. foreach (_build_type "Release" "MinSizeRel" "RelWithDebInfo") - Apply the patch:
git apply disable_Werror.patch - Build the project:
mkdir build && cd build cmake .. -DANTLR_JAR_LOCATION=/path/to/antlr-4.8-complete.jar -DGRAMMAR_FILE=/path/to/Grammar-Mutator/grammars/ruby.json cmake --build .
3. Fix the Root Cause
A Pull Request with the fixes has been created, but it is unlikely to be accepted: PR with fixes. Therefore, here are the instructions to apply the fixes manually:
-
Start build the project:
mkdir build && cd build cmake .. -DANTLR_JAR_LOCATION=/path/to/antlr-4.8-complete.jar -DGRAMMAR_FILE=/path/to/Grammar-Mutator/grammars/ruby.json cmake --build .* After some time, the build error will appear *
-
Make changes to
build/third_party/antlr4-cpp-runtime/antlr4-cpp-runtime-src/runtime/src/RuleContext.h:diff --git a/runtime/src/RuleContext.h b/runtime/src/RuleContext.h index 9ee0d2d..9de977a 100755 --- a/runtime/src/RuleContext.h +++ b/runtime/src/RuleContext.h @@ -128,6 +128,7 @@ namespace antlr4 { virtual std::string toString(const std::vector<std::string> &ruleNames, RuleContext *stop); + using ParseTree::operator==; bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison. private: -
Continue the build with the changes applied:
cmake --build .