Bug #87524 Compilation of unit tests regenerates Makefile
Submitted: 24 Aug 2017 10:24 Modified: 25 Aug 2017 9:11
Reporter: P D Email Updates:
Status: Open Impact on me:
Category:MySQL Server: Tests Severity:S3 (Non-critical)
Version: OS:Ubuntu
Assigned to: CPU Architecture:Any

[24 Aug 2017 10:24] P D
Hi everyone,

This is not exactly a bug, but it represents a problem to me. I'm using MySQl server as part of a research experiment. This experiment follows these steps: 

- I introduce a simple change into sql/field.h or sql/field.cc. 
- make field.o
- Then I want to build and execute the unit tests in "unittest/gunit/field-t". To that end, I execute "make field-t" from the directory "unittest/gunit/".

The problem is that CMake regenerates the Makefile previously created in "unittest/gunit" and it starts to recompile almost everything. For instance, it takes a long time to buid all the objects in "sql/CMakeFiles/sql.dir" to link the library "libsql.a". To be honest, I don't know how to interpret the CMakeLists.txt file to know which are the dependencies to create the executable field-t, but I wonder if there is a way to speed up the process. It also builds the objects in:

- sql/CMakeFiles/binlog.dir/
- sql/CMakeFiles/slave.dir
- ...
- storage/perfschema/CMakeFiles/perfschema.dir

And the libraries generated are:
-       sql/libbinlog.a
-       sql/libmaster.a
-       sql/librpl.a
-       sql/libslave.a
-       sql/libsql.a
-       storage/archive/libarchive.a
-       storage/csv/libcsv.a
-       ...
-       storage/perfschema/libperfschema.a

Are all of them really necessary to build field-t?

If I had to do this only once, it shouldn't be a problem, but I have to insert almost one thousand changes into the code of field.cc/.h one by one, so the whole process can take hours or even days if I'm not able to reduce the time to create the executable "field-t". 

Finally, I tried with field-t/fast, but it didn't help because the tests in field_new_decimal-t fails:

"# Run 22 FieldNewDecimalTest.StoreLegalStringValues
10:18:25 UTC - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. ..."

Could you help me with this?



How to repeat:
- I introduce a simple change into sql/field.h or sql/field.cc. 
- make field.o
- Then I want to build and execute the unit tests in "unittest/gunit/field-t". To that end, I execute "make field-t" from the directory "unittest/gunit/".
[25 Aug 2017 7:51] Tor Didriksen
What version of mysql, and what platform?

In both 5.6 and 5.7 I see:

$touch ../sql/field.cc 

make field-t
[  1%] Built target gen_lex_hash
[  1%] Built target GenServerSource
[  1%] Built target gen_lex_token
[  1%] Built target GenDigestServerSource
[  2%] Built target yassl
[  5%] Built target taocrypt
[  8%] Built target zlib
[ 14%] Built target strings
[ 14%] Built target gen_dtrace_header
[ 28%] Built target mysys
[ 28%] Built target dbug
[ 29%] Built target mysys_ssl
[ 29%] Built target comp_err
[ 29%] Built target GenError
[ 37%] Built target myisam
[ 37%] Built target csv
[ 41%] Built target heap
[ 41%] Built target federated
[ 41%] Built target blackhole
[ 44%] Built target myisammrg
[ 44%] Built target archive
[ 55%] Built target perfschema
[ 71%] Built target innobase
[ 73%] Built target vio
[ 73%] Built target regex
[ 73%] Built target partition
Scanning dependencies of target sql
[ 73%] Building CXX object sql/CMakeFiles/sql.dir/field.cc.o
[ 73%] Linking CXX static library libsql.a
[ 94%] Built target sql
[ 94%] Built target gmock
[ 94%] Built target gtest
[ 94%] Built target mytap
[ 95%] Built target gunit_large
[ 98%] Built target binlog
[100%] Built target slave
[100%] Built target rpl
[100%] Built target master
[100%] Linking CXX executable field-t
[100%] Built target field-t

If you touch the *header* file though, you must expect to recompile just about everything, including storage engines and the server itself.
[25 Aug 2017 9:11] P D
Thanks Tor,

I cloned the last commit in github. The platform is Ubuntu 14.04.2 LTS.

You are right: the recompilation happens when the header file is modified. It can take minutes and minutes... I attach the output of "make field-t": is that the expected output? Also, Why is cmake regenerating the Makefile (as you can observe at the beginning of the file)? Does it affect the build? 

Is it possible to add only the necessary dependencies in CMakeLists.txt to build "field-t"? Do it happen the same with the rest of header files? 

[25 Aug 2017 9:12] P D
Output of "make field-t"

Attachment: execution.txt (text/plain), 31.16 KiB.