ninja-build / ninja

a small build system with a focus on speed
https://ninja-build.org/
Apache License 2.0
11.02k stars 1.58k forks source link

Weird behavior non-existent variables and the ninja log #729

Open mathstuf opened 10 years ago

mathstuf commented 10 years ago

I'm still tracking down the issue because it's a heisenbug, but here's some of the breadcrumbs:

With the following rule:

rule CXX_COMPILER
  depfile = $DEP_FILE
  deps = gcc
  command = /usr/lib64/ccache/c++   $DEFINES $FLAGS -MMD -MT $out -MF $DEP_FILE -o $out -c $in
  description = Building CXX object $out

Usage:

build cmake_order_depends_target_test-dlopen: phony
cmake_flags_target_test-dlopen_lang_CXX = -g -I/home/boeckb/code/sprokit/src/tests -I/home/boeckb/code/sprokit/src/src -Isrc    -fvisibility=hidden -std=c++98 -Wall -Wextra -Wabi -Wctor-dtor-privacy -Winit-self -Woverloaded-virtual -Wpointer-arith -Wstrict-null-sentinel -Wswitch-default -Wswitch-enum -Wformat=2 -Wcast-align -Wcast-qual -Wdouble-promotion -Wfloat-equal -fstrict-overflow -Wstrict-overflow=5 -Wshadow -Wnarrowing -Wnoexcept -Wlogical-op -Wmissing-braces -Wundef -Wunused-macros -O0 -pg -ftest-coverage -fprofile-arcs

build tests/sprokit/test/CMakeFiles/test-dlopen.dir/test_dlopen.cxx.o: CXX_COMPILER /home/boeckb/code/sprokit/src/tests/sprokit/test/test_dlopen.cxx || cmake_order_depends_target_test-dlopen
  DEFINES = $cmake_defines_target_test-dlopen_lang_CXX
  DEP_FILE = tests/sprokit/test/CMakeFiles/test-dlopen.dir/test_dlopen.cxx.o.d
  FLAGS = $cmake_flags_target_test-dlopen_lang_CXX
  OBJECT_DIR = tests/sprokit/test/CMakeFiles/test-dlopen.dir

Output:

% rm .ninja_*
% ninja -v test-dlopen
[0-1->0/1@?] : && /usr/lib64/ccache/c++   -g   tests/sprokit/test/CMakeFiles/test-dlopen.dir/test_dlopen.cxx.o  -o tests/bin/test-dlopen  -rdynamic -lboost_filesystem -lboost_system -ldl && :

If I comment out the DEFINES line (which uses an undefined variable), this happens:

% rm .ninja_*
% ninja -v test-dlopen
[1-1->0/2@?] /usr/lib64/ccache/c++    -g -I/home/boeckb/code/sprokit/src/tests -I/home/boeckb/code/sprokit/src/src -Isrc    -fvisibility=hidden -std=c++98 -Wall -Wextra -Wabi -Wctor-dtor-privacy -Winit-self -Woverloaded-virtual -Wpointer-arith -Wstrict-null-sentinel -Wswitch-default -Wswitch-enum -Wformat=2 -Wcast-align -Wcast-qual -Wdouble-promotion -Wfloat-equal -fstrict-overflow -Wstrict-overflow=5 -Wshadow -Wnarrowing -Wnoexcept -Wlogical-op -Wmissing-braces -Wundef -Wunused-macros -O0 -pg -ftest-coverage -fprofile-arcs -MMD -MT tests/sprokit/test/CMakeFiles/test-dlopen.dir/test_dlopen.cxx.o -MF tests/sprokit/test/CMakeFiles/test-dlopen.dir/test_dlopen.cxx.o.d -o tests/sprokit/test/CMakeFiles/test-dlopen.dir/test_dlopen.cxx.o -c /home/boeckb/code/sprokit/src/tests/sprokit/test/test_dlopen.cxx

However, if I run this multiple times without removing the .ninja_* files, it fluctuates between getting the flags and not getting the flags seemingly randomly.

jonesmz commented 4 years ago

@mathstuf Still reproducible with Ninja 1.10.0?

mathstuf commented 4 years ago

Not sure. I haven't seen anything that would fix this, but I haven't tested either.

jonesmz commented 4 years ago

Well, it has been 6 years. Just confirming that the issue is still relevant is helpful shrug