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

Failure to compile 0.4.2 on Arch w/ gcc or clang #22

Closed
troyengel opened this issue Oct 21, 2016 · 12 comments
Closed

Failure to compile 0.4.2 on Arch w/ gcc or clang #22

troyengel opened this issue Oct 21, 2016 · 12 comments

Comments

@troyengel
Copy link

I'm creating a package for Arch, here are the current versions of requirements we have:

$ pacman -Q gcc clang libpcap json-c ncurses
gcc 6.2.1-1
clang 3.8.1-1
libpcap 1.7.4-1
json-c 0.12.1-1
ncurses 6.0-4

When compiling with gcc I error out with:

==> Starting build()...
-- The C compiler identification is GNU 6.2.1
-- The CXX compiler identification is GNU 6.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- To enable code self-profiling set option PROFILING=ON and build in Release mode
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Looking for wsyncup in /usr/lib64/libcurses.so
-- Looking for wsyncup in /usr/lib64/libcurses.so - found
-- Looking for cbreak in /usr/lib64/libncurses.so
-- Looking for cbreak in /usr/lib64/libncurses.so - found
-- Found Curses: /usr/lib64/libncurses.so  
-- Found JSON: /usr/lib64/libjson-c.so  
CMake Warning at tests/unit/CMakeLists.txt:2 (message):
  GMOCK_SOURCE_DIR variable not set - unit-tests are not available.  Use
  '-DGMOCK_SOURCE_DIR=<path_to_gmock_sources>' param for CMake


-- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE) 
-- Could NOT find LATEX (missing:  LATEX_COMPILER PDFLATEX) 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tengel/abs/nfstrace/src/nfstrace-0.4.2/release
Scanning dependencies of target nfstrace
[  1%] Building CXX object CMakeFiles/nfstrace.dir/src/analysis/analysis_manager.cpp.o
In file included from /home/tengel/abs/nfstrace/src/nfstrace-0.4.2/src/analysis/nfs_parser.h:28:0,
                 from /home/tengel/abs/nfstrace/src/nfstrace-0.4.2/src/analysis/parsers.h:27,
                 from /home/tengel/abs/nfstrace/src/nfstrace-0.4.2/src/analysis/analysis_manager.h:32,
                 from /home/tengel/abs/nfstrace/src/nfstrace-0.4.2/src/analysis/analysis_manager.cpp:22:
/home/tengel/abs/nfstrace/src/nfstrace-0.4.2/src/protocols/nfs/nfs_procedure.h: In destructor ‘NST::protocols::NFSProcedure<ArgType, ResType>::~NFSProcedure()’:
/home/tengel/abs/nfstrace/src/nfstrace-0.4.2/src/protocols/nfs/nfs_procedure.h:111:9: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
         if(pres) xdr_free((xdrproc_t)proc_t_of(res), (char*)&res      );
         ^~
/home/tengel/abs/nfstrace/src/nfstrace-0.4.2/src/protocols/nfs/nfs_procedure.h:112:18: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
                  xdr_free((xdrproc_t)xdr_replymsg,   (char*)&reply);
                  ^~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/nfstrace.dir/build.make:63: CMakeFiles/nfstrace.dir/src/analysis/analysis_manager.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/nfstrace.dir/all] Error 2
make: *** [Makefile:161: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...

When compiling with clang I error out with:

==> Starting build()...
-- The C compiler identification is Clang 3.8.1
-- The CXX compiler identification is Clang 3.8.1
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- To enable code self-profiling set option PROFILING=ON and build in Release mode
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Looking for wsyncup in /usr/lib64/libcurses.so
-- Looking for wsyncup in /usr/lib64/libcurses.so - found
-- Looking for cbreak in /usr/lib64/libncurses.so
-- Looking for cbreak in /usr/lib64/libncurses.so - found
-- Found Curses: /usr/lib64/libncurses.so  
-- Found JSON: /usr/lib64/libjson-c.so  
CMake Warning at tests/unit/CMakeLists.txt:2 (message):
  GMOCK_SOURCE_DIR variable not set - unit-tests are not available.  Use
  '-DGMOCK_SOURCE_DIR=<path_to_gmock_sources>' param for CMake


-- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE) 
-- Could NOT find LATEX (missing:  LATEX_COMPILER PDFLATEX) 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tengel/abs/nfstrace/src/nfstrace-0.4.2/release
Scanning dependencies of target nfstrace
[  1%] Building CXX object CMakeFiles/nfstrace.dir/src/analysis/analysis_manager.cpp.o
In file included from /home/tengel/abs/nfstrace/src/nfstrace-0.4.2/src/analysis/analysis_manager.cpp:22:
In file included from /home/tengel/abs/nfstrace/src/nfstrace-0.4.2/src/analysis/analysis_manager.h:28:
/home/tengel/abs/nfstrace/src/nfstrace-0.4.2/src/analysis/parser_thread.h:46:17: error: 
      braces around scalar initializer [-Werror,-Wbraced-scalar-init]
    , running  {ATOMIC_FLAG_INIT} // false
                ^~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../include/c++/6.2.1/bits/atomic_base.h:157:26: note: 
      expanded from macro 'ATOMIC_FLAG_INIT'
#define ATOMIC_FLAG_INIT { 0 }
                         ^~~~~
1 error generated.
make[2]: *** [CMakeFiles/nfstrace.dir/build.make:63: CMakeFiles/nfstrace.dir/src/analysis/analysis_manager.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/nfstrace.dir/all] Error 2
make: *** [Makefile:161: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...

Both of these appear to be errors in what the compilers are looking for or expect, any advice on where to go from here? Nothing special about the compile, following the README instructions.

@ailyasov
Copy link
Contributor

ailyasov commented Nov 3, 2016

These compilation errors for gcc 6 and clang 3.8 have been fixed in version 0.4.3.
Please try to download and compile 0.4.3.

@troyengel
Copy link
Author

Alas, the above errors are gone but with each compiler we have different errors now; I am snipping out only the top portions of them, as each one (each compiler) produces a huge list of errors starting with this part so I'm sure it's all related.

NOTE: it looks like Arch updated to clang 3.9.0 now so that may be part of the clang issues, but it looks like gcc has not updated:

$ pacman -Q gcc clang libpcap json-c ncurses
gcc 6.2.1-1
clang 3.9.0-1
libpcap 1.7.4-1
json-c 0.12.1-1
ncurses 6.0-4

Here's the gcc output:

Scanning dependencies of target json
[ 89%] Building CXX object analyzers/src/json/CMakeFiles/json.dir/abstract_tcp_service.cpp.o
In file included from /usr/include/sched.h:43:0,
                 from /usr/include/pthread.h:23,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/gthr-default.h:35,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/gthr.h:148,
                 from /usr/include/c++/6.2.1/ext/atomicity.h:35,
                 from /usr/include/c++/6.2.1/bits/basic_string.h:39,
                 from /usr/include/c++/6.2.1/string:52,
                 from /usr/include/json/config.h:9,
                 from /usr/include/json/forwards.h:10,
                 from /usr/include/json/features.h:10,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/os_defines.h:39,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/c++config.h:495,
                 from /usr/include/c++/6.2.1/cstring:41,
                 from /home/tengel/abs/nfstrace/src/nfstrace-0.4.3/analyzers/src/json/abstract_tcp_service.cpp:22:
/usr/include/bits/sched.h:132:20: error: missing binary operator before token "("
 # if __GNUC_PREREQ (2, 91)
                    ^
/usr/include/bits/sched.h:170:20: error: missing binary operator before token "("
 # if __GNUC_PREREQ (2, 91)
                    ^
In file included from /usr/include/libio.h:56:0,
                 from /usr/include/stdio.h:74,
                 from /usr/include/c++/6.2.1/cstdio:42,
                 from /usr/include/c++/6.2.1/ext/string_conversions.h:43,
                 from /usr/include/c++/6.2.1/bits/basic_string.h:5402,
                 from /usr/include/c++/6.2.1/string:52,
                 from /usr/include/json/config.h:9,
                 from /usr/include/json/forwards.h:10,
                 from /usr/include/json/features.h:10,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/os_defines.h:39,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/c++config.h:495,
                 from /usr/include/c++/6.2.1/cstring:41,
                 from /home/tengel/abs/nfstrace/src/nfstrace-0.4.3/analyzers/src/json/abstract_tcp_service.cpp:22:
/usr/include/sys/cdefs.h:41:20: error: missing binary operator before token "("
 # if __GNUC_PREREQ (4, 6) && !defined _LIBC

Here's the clang output:

Scanning dependencies of target json
[ 89%] Building CXX object analyzers/src/json/CMakeFiles/json.dir/abstract_tcp_service.cpp.o
In file included from /home/tengel/abs/nfstrace/src/nfstrace-0.4.3/analyzers/src/json/abstract_tcp_service.cpp:22:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../include/c++/6.2.1/cstring:41:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../include/c++/6.2.1/x86_64-pc-linux-gnu/bits/c++config.h:495:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../include/c++/6.2.1/x86_64-pc-linux-gnu/bits/os_defines.h:39:
In file included from /usr/include/json/features.h:10:
In file included from /usr/include/json/forwards.h:10:
In file included from /usr/include/json/config.h:9:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../include/c++/6.2.1/string:40:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../include/c++/6.2.1/bits/char_traits.h:135:38: error: 
      use of undeclared identifier '_GLIBCXX_STDIO_EOF'
      { return static_cast<int_type>(_GLIBCXX_STDIO_EOF); }
                                     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../include/c++/6.2.1/bits/char_traits.h:317:38: error: 
      use of undeclared identifier '_GLIBCXX_STDIO_EOF'
      { return static_cast<int_type>(_GLIBCXX_STDIO_EOF); }

Nothing else has changed in the build method used, same as before. Thx! By the way, I personally don't care if we use gcc or clang so getting just one to work would be OK. :-)

@troyengel
Copy link
Author

PS: I would be happy to build you a basic Arch VirtualBox VM and upload it somewhere if you'd like a development instance to sort this out.

@ailyasov
Copy link
Contributor

ailyasov commented Nov 4, 2016

Yes Arch VirtualBox VM where you have these errors would be helpful.

@troyengel
Copy link
Author

Apologies for the delay - I used one of my scripts to create a VM (it has a basic MATE desktop) and recreated the nfstrace compile errors - everything is ready for you, just import this OVA into your VirtualBox - it's about 2.5G because I had all the GUI stuff added automatically (sorry - it's all scripted for me):

The password for both root and 'archuser' is 'archtest' - the nfstrace setup is located in /home/archuser/nfstrace. Inside that directory is a file PKGBUILD, the standard arch packaging script (it's my in-progress work). If you look in this file at the bottom, you will see I have the gcc and clang compile lines commented out easily for you to test both.

To trigger it to build, just change to the nfstrace directory and type "makepkg". The build method Arch uses stays all within that directory, and cleans up itself (so you can build as gcc, edit PKGBUILD to uncomment clang, and just type "makepkg" again) each run. This is the build file I will eventually upload to make a real package for everyone else once we sort out these issues.

Please let me know once you've downloaded so I can delete the OVA from my side, thanks!

@ailyasov
Copy link
Contributor

ailyasov commented Nov 9, 2016

I have downloaded the image so you can delete it.
Thanks.

@troyengel
Copy link
Author

Thanks! I've removed it.

@ailyasov
Copy link
Contributor

I've updated cmake/FindJSON.cmake 2574031

Could you please update from master and let me know how it goes ?

@troyengel
Copy link
Author

It all works! I tested both gcc and clang, no errors in either system now. Might we tag a 0.4.3.1 or a 0.4.4 with this commit so I don't have to use .patch files in my packaging? :-)

PS: I am agnostic to which compiler is used, and read a lot of back-and-forth as to if clang or gcc is better, there's no clear winner. As project maintainer, which compiler would you recommend we use as the default to compile nfstrace, do you have a preference or experience to share? Thanks!

@ailyasov
Copy link
Contributor

I'd say gcc is the default compiler.
But I don't have any strong reasons choosing one over another in terms of
which one should be used for building nfstrace.

@ailyasov
Copy link
Contributor

Created 0.4.3.1 tag.

@troyengel
Copy link
Author

Thank you - I went with gcc as it's usually installed by most folks (AUR is a compile-on-the-fly system, unlike precompiled official packages) and clang is a hefty download if you don't already have it installed. Everything is 100% now, package is live:

Much appreciated for your help!

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

2 participants