build fails when cmake is called with -DCMAKE_BUILD_TYPE=Release

Open
#1,180 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
c, cmake
Domain
build-system

Research direction

Start with src/test/accept.c and the CMake configuration that supplies its Release compiler flags; reproduce the failure by configuring rr with -DCMAKE_BUILD_TYPE=Release and building with verbose output. Done means the Release build completes without the unused-variable warnings being treated as errors.

Written by the indexing model from the issue text.

Description

goodfirstbug

While packaging rr, the problem is that in Release mode the -DNDEBUG is omitted, and the warning-as-error compilation flag is catching debug-only variable declarations.

A work-around is to give the additional argument -DCMAKE_C_FLAGS_RELEASE:STRING= to cmake.

(spew obtained with make VERBOSE=1)
When building with the Release mode:

building CMakeFiles/accept.dir/src/test/accept.c.o
/nix/store/vv90ccz0p6kyfasyhh1caxdjbrqdzqc1-cmake-2.8.11.2/bin/cmake -E cmake_progress_report /tmp/nix-build-rr-1.3.0.drv-0/rr-1.3.0/CMakeFiles 2
[  2%] Building C object CMakeFiles/accept.dir/src/test/accept.c.o
/nix/store/xnb0w1i2jdjv178j1y28q4bfn79b8xia-gcc-wrapper-4.8.2/bin/cc   -pthread -O0 -g3 -Wall -Werror -m32 -Wstrict-prototypes -O3 -DNDEBUG -I/tmp/nix-build-rr-1.3.0.drv-0/rr-1.3.0/include    -o CMakeFiles/accept.dir/src/test/accept.c.o   -c /tmp/nix-build-rr-1.3.0.drv-0/rr-1.3.0/src/test/accept.c
/tmp/nix-build-rr-1.3.0.drv-0/rr-1.3.0/src/test/accept.c: In function ‘client’:
/tmp/nix-build-rr-1.3.0.drv-0/rr-1.3.0/src/test/accept.c:6:6: erreur: variable ‘clientfd’ set but not used [-Werror=unused-but-set-variable]
  int clientfd;
      ^
/tmp/nix-build-rr-1.3.0.drv-0/rr-1.3.0/src/test/accept.c: In function ‘server’:
/tmp/nix-build-rr-1.3.0.drv-0/rr-1.3.0/src/test/accept.c:34:6: erreur: unused variable ‘status’ [-Werror=unused-variable]
  int status;
      ^
/tmp/nix-build-rr-1.3.0.drv-0/rr-1.3.0/src/test/accept.c:33:12: erreur: unused variable ‘len’ [-Werror=unused-variable]
  socklen_t len = sizeof(peer_addr);
            ^
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/accept.dir/src/test/accept.c.o] Erreur 1

When building without the Release mode:

building CMakeFiles/accept.dir/src/test/accept.c.o
/nix/store/vv90ccz0p6kyfasyhh1caxdjbrqdzqc1-cmake-2.8.11.2/bin/cmake -E cmake_progress_report /tmp/nix-build-rr-1.3.0.drv-0/rr-1.3.0/CMakeFiles 2
[  2%] Building C object CMakeFiles/accept.dir/src/test/accept.c.o
/nix/store/xnb0w1i2jdjv178j1y28q4bfn79b8xia-gcc-wrapper-4.8.2/bin/cc   -pthread -O0 -g3 -Wall -Werror -m32 -Wstrict-prototypes -I/tmp/nix-build-rr-1.3.0.drv-0/rr-1.3.0/include    -o CMakeFiles/accept.dir/src/test/accept.c.o   -c /tmp/nix-build-rr-1.3.0.drv-0/rr-1.3.0/src/test/accept.c
building bin/accept
Linking C executable bin/accept
/nix/store/vv90ccz0p6kyfasyhh1caxdjbrqdzqc1-cmake-2.8.11.2/bin/cmake -E cmake_link_script CMakeFiles/accept.dir/link.txt --verbose=1
/nix/store/xnb0w1i2jdjv178j1y28q4bfn79b8xia-gcc-wrapper-4.8.2/bin/cc   -pthread -O0 -g3 -Wall -Werror -m32 -Wstrict-prototypes    CMakeFiles/accept.dir/src/test/accept.c.o  -o bin/accept -rdynamic -lrt 
make[2] : on quitte le répertoire « /tmp/nix-build-rr-1.3.0.drv-0/rr-1.3.0 »
Dominant language
C++
Stars
10.7k
Forks
662
Avg merge
2d 3h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rr-debugger/rr

All issues in rr-debugger/rr

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.