[MDEV-14899] CMake: Missing BYPRODUCT or OUTPUT Created: 2018-01-09  Updated: 2024-01-30  Resolved: 2024-01-30

Status: Closed
Project: MariaDB Server
Component/s: Compiling
Affects Version/s: 10.3.3
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: OndÅ™ej Surý (Inactive) Assignee: Daniel Black
Resolution: Won't Fix Votes: 0
Labels: beginner-friendly


 Description   

When using CMake with ninja build system, the following warning is generated for embedded libraries in PerconaFT. It seems this might be easy to fix for these two.

CMake Warning (dev):
  Policy CMP0058 is not set: Ninja requires custom command byproducts to be
  explicit.  Run "cmake --help-policy CMP0058" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.
 
  This project specifies custom command DEPENDS on files in the build tree
  that are not specified as the OUTPUT or BYPRODUCTS of any
  add_custom_command or add_custom_target:
 
   storage/tokudb/PerconaFT/./snappy/lib/libsnappy.a
   storage/tokudb/PerconaFT/./xz/lib/liblzma.a
 
  For compatibility with versions of CMake that did not have the BYPRODUCTS
  option, CMake is generating phony rules for such files to convince 'ninja'
  to build.
 
  Project authors should add the missing BYPRODUCTS or OUTPUT options to the
  custom commands that produce these files.



 Comments   
Comment by Sergei Golubchik [ 2018-01-09 ]

only happens in out-of-source builds

Comment by Anel Husakovic [ 2020-05-28 ]

It is boring thing that happends in out-of-source (OOS) builds.
I was working on 10.1 and patch is for 10.1, the patch is ae8559fd31eb54ecd7, cvicentiu.
For OOS builds CMAKE_CFG_INTDIR in case of ninja evaluates to '.', we are fixing this additionally to have a better overview.
As a solution is used BUILD_BYPRODUCTS <file>... in Externalproject_add during the make.
Note: Setting the variable and using it in externalproject_add() doesn't work as here.
Other links:
similar problem SO - solution with cmake and make
externalproject.cmake cmake_cfg_intdir
usage of externalproject 1
usage of ep 2
not related but good to know

Comment by Anel Husakovic [ 2020-05-28 ]

Patch failed while compiling (didn't notice before):

[142/375] Performing install step for 'build_snappy'
[0/1] Install the project...
-- Install configuration: "Debug"
-- Up-to-date: /home/anel/mariadb/builds/test-before-push-10.1/storage/tokudb/PerconaFT/snappy/lib/libsnappy.a  # instead of storage/tokudb/PerconaFT/Debug/snappy/lib/libsnappy.a
-- Up-to-date: /home/anel/mariadb/builds/test-before-push-10.1/storage/tokudb/PerconaFT/snappy/include/snappy.h
-- Up-to-date: /home/anel/mariadb/builds/test-before-push-10.1/storage/tokudb/PerconaFT/snappy/include/snappy-stubs-public.h
 
[342/375] Linking CXX shared library storage/tokudb/PerconaFT/ft/libft.so
FAILED: storage/tokudb/PerconaFT/ft/libft.so 
: && /usr/bin/g++-9 -fPIC -std=c++11 -Wno-error  -pie -fPIC -Wl,-z,relro,-z,now -fstack-protector --param=ssp-buffer-size=4 -DWITH_INNODB_DISALLOW_WRITES -fPIC -fno-exceptions -fno-rtti -Wno-shadow -Wno-implicit-fallthrough -std=c++11 -Wno-missing-field-initializers -Wno-address-of-packed-member -Wno-missing-field-initializers -Wstrict-null-sentinel -Winit-self -Wswitch -Wtrampolines -Wlogical-op -Wno-error=missing-format-attribute -Wno-error=maybe-uninitialized -fno-rtti -fno-exceptions -Wno-error=nonnull-compare -Wpacked -fno-omit-frame-pointer -Wno-error=strict-overflow -fexceptions -Wextra -Wno-missing-noreturn -Wmissing-declarations -Wpointer-arith -Wcast-align -g3 -O0 -g -DENABLED_DEBUG_SYNC -ggdb3 -DSAFE_MUTEX -DSAFEMALLOC -Wall -Wextra -Wformat-security -Wno-format-truncation -Wno-init-self -Wno-nonnull-compare -Wno-unused-parameter -Woverloaded-virtual -Wvla -Wwrite-strings -Werror -Wno-vla -Wno-cpp -DTOKUDB_DEBUG  -g -fuse-linker-plugin -shared -Wl,-soname,libft.so -o storage/tokudb/PerconaFT/ft/libft.so storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/bndata.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/cachetable/background_job_manager.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/cachetable/cachetable.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/cachetable/checkpoint.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/cursor.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/ft.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/ft-cachetable-wrappers.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/ft-flusher.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/ft-hot-flusher.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/ft-ops.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/ft-recount-rows.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/ft-status.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/ft-test-helpers.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/ft-verify.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/loader/callbacks.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/loader/dbufio.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/loader/loader.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/loader/pqueue.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/leafentry.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/le-cursor.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/logger/logcursor.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/logger/logfilemgr.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/logger/logger.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/logger/log_upgrade.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/logger/recover.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/msg.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/msg_buffer.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/node.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/pivotkeys.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/serialize/rbtree_mhs.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/serialize/block_allocator.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/serialize/block_table.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/serialize/compress.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/serialize/ft_node-serialize.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/serialize/ft-node-deserialize.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/serialize/ft-serialize.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/serialize/quicklz.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/serialize/sub_block.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/txn/rollback.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/txn/rollback-apply.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/txn/rollback-ct-callbacks.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/txn/rollback_log_node_cache.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/txn/roll.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/txn/txn.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/txn/txn_child_manager.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/txn/txn_manager.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/txn/xids.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/ule.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/log_code.cc.o storage/tokudb/PerconaFT/ft/CMakeFiles/ft.dir/log_print.cc.o  -Wl,-rpath,/home/anel/mariadb/builds/test-before-push-10.1/storage/tokudb/PerconaFT/portability -lpthread storage/tokudb/PerconaFT/util/libutil_static.a storage/tokudb/PerconaFT/Debug/xz/lib/liblzma.a storage/tokudb/PerconaFT/Debug/snappy/lib/libsnappy.a storage/tokudb/PerconaFT/portability/libtokuportability.so -lz -lpthread -ldl -lrt && :
 
g++-9: error: storage/tokudb/PerconaFT/Debug/snappy/lib/libsnappy.a: No such file or directory
 
[347/375] Building CXX object storage/tokudb/PerconaFT/locktree/CMakeFiles/locktree.dir/wfg.cc.o
ninja: build stopped: subcommand failed.

Added the patch:

+++ b/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake
@@ -31,7 +31,7 @@ endif ()
 
 FILE(GLOB XZ_ALL_FILES ${XZ_SOURCE_DIR}/*)
 ExternalProject_Add(build_lzma
-    PREFIX xz
+    PREFIX "${MY_CFG_INTDIR}/xz"
     DOWNLOAD_COMMAND
         cp -a "${XZ_ALL_FILES}" "<SOURCE_DIR>/"
     CONFIGURE_COMMAND
@@ -85,7 +85,7 @@ endif ()
 
 FILE(GLOB SNAPPY_ALL_FILES ${SNAPPY_SOURCE_DIR}/*)
 ExternalProject_Add(build_snappy
-    PREFIX snappy
+    PREFIX "${MY_CFG_INTDIR}/snappy"
     DOWNLOAD_COMMAND
         cp -a "${SN

With the patch it passed, with valid directory for the library

[5/5] Linking CXX static library libsnappy.a
[269/2011] Performing install step for 'build_snappy'
[0/1] Install the project...
-- Install configuration: "Debug"
-- Installing: /home/anel/mariadb/builds/test-before-push-10.1/storage/tokudb/PerconaFT/Debug/snappy/lib/libsnappy.a
-- Installing: /home/anel/mariadb/builds/test-before-push-10.1/storage/tokudb/PerconaFT/Debug/snappy/include/snappy.h
-- Installing: /home/anel/mariadb/builds/test-before-push-10.1/storage/tokudb/PerconaFT/Debug/snappy/include/snappy-stubs-public.h

Tested for in-source builds also:

[5/5] Linking CXX static library libsnappy.a
[275/2011] Performing install step for 'build_snappy'
[0/1] Install the project...
-- Install configuration: "Debug"
-- Installing: /home/anel/mariadb/10.1-cmake/storage/tokudb/PerconaFT/Debug/snappy/lib/libsnappy.a
-- Installing: /home/anel/mariadb/10.1-cmake/storage/tokudb/PerconaFT/Debug/snappy/include/snappy.h
-- Installing: /home/anel/mariadb/10.1-cmake/storage/tokudb/PerconaFT/Debug/snappy/include/snappy-stubs-public.h
 
Libraries have been installed in:
   /home/anel/mariadb/10.1-cmake/storage/tokudb/PerconaFT/Debug/xz/lib

cvicentiu new patch is here-04708a8e78.

Comment by Anel Husakovic [ 2020-06-08 ]

In buildbot - bb-10.1-anel-MDEV14899, there is a problem with:
trusty
jessy
Maybe libtool problem in buildbot?

Comment by Anel Husakovic [ 2020-08-20 ]

Test

Comment by Anel Husakovic [ 2020-10-20 ]

I cannot reproduce this anymore danblack ping?!

Comment by Daniel Black [ 2020-11-02 ]

I still can reproduce this with PLUGIN_TOKUDB=DYNAMIC.

10.3-d5ce7824444b7491f420061076ae5087d4829428 ninja, out-of-tree

~/repos/build-mariadb-server-10.3 
$ cmake -DPLUGIN_TOKUDB=DYNAMIC .
 
....
....
-- Performing Test HAVE_STDCXX0X
-- Performing Test HAVE_STDCXX0X - Success
-- Configuring done
-- Generating done
CMake Warning (dev):
  Policy CMP0058 is not set: Ninja requires custom command byproducts to be
  explicit.  Run "cmake --help-policy CMP0058" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.
 
  This project specifies custom command DEPENDS on files in the build tree
  that are not specified as the OUTPUT or BYPRODUCTS of any
  add_custom_command or add_custom_target:
 
   storage/tokudb/PerconaFT/./snappy/lib/libsnappy.a
   storage/tokudb/PerconaFT/./xz/lib/liblzma.a
 
  For compatibility with versions of CMake that did not have the BYPRODUCTS
  option, CMake is generating phony rules for such files to convince 'ninja'
  to build.
 
  Project authors should add the missing BYPRODUCTS or OUTPUT options to the
  custom commands that produce these files.
This warning is for project developers.  Use -Wno-dev to suppress it.
 
-- Build files have been written to: /home/dan/repos/build-mariadb-server-10.3

Comment by Anel Husakovic [ 2020-11-02 ]

danblack patch f80b11a70 is solving it:

-- Looking for include file crack.h
-- Looking for include file crack.h - found
-- Performing Test HAVE_CXX_WDEPRECATED_DECLARATIONS
-- Performing Test HAVE_CXX_WDEPRECATED_DECLARATIONS - Success
-- Performing Test SUPPORTS_VERSION_IN_LINK_SCRIPT
-- Performing Test SUPPORTS_VERSION_IN_LINK_SCRIPT - Success
-- Looking for event.h
-- Looking for event.h - not found
CMake Deprecation Warning at cmake/for_clients.cmake:15 (CMAKE_POLICY):
  The OLD behavior for policy CMP0007 will be removed from a future version
  of CMake.
 
  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  CMakeLists.txt:448 (INCLUDE)
 
 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/anel/mariadb/mdev-14899

Note here for the result obtained in buildbot there were failing cases jessy

CMakeFiles/libgroonga.dir/ts/ts_util.c.o
/usr/bin/ranlib libgroonga.a
make[3]: Leaving directory '/home/buildbot/buildbot/build/mariadb-10.1.48/builddir'
/usr/bin/cmake -E cmake_progress_report /home/buildbot/buildbot/build/mariadb-10.1.48/builddir/CMakeFiles  29 30 31 32 33 34
[ 18%] Built target libgroonga
make[2]: Leaving directory '/home/buildbot/buildbot/build/mariadb-10.1.48/builddir'
Makefile:147: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/buildbot/buildbot/build/mariadb-10.1.48/builddir'
debian/rules:84: recipe for target 'build-stamp' failed
make: *** [build-stamp] Error 2
dpkg-buildpackage: error: debian/rules build gave error exit status 2
Connection to localhost closed.
Command exit 2
+ ssh -t -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR -o ConnectTimeout=4 -p 2275 -l buildbot localhost sudo /sbin/shutdown -h now
Connection to localhost closed by remote host.
Connection to localhost closed.
+ ssh -t -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR -o ConnectTimeout=4 -p 2275 -l buildbot localhost sudo /sbin/shutdown -h now
ssh: connect to host localhost port 2275: Connection refused
program finished with exit code 2
elapsedTime=220.684910

Also similar for bintar

/usr/bin/ranlib libgroonga.a
make[2]: Leaving directory `/home/buildbot/buildbot/build/mkbin'
/usr/bin/cmake -E cmake_progress_report /home/buildbot/buildbot/build/mkbin/CMakeFiles  27 28 29 30 31 32
[ 16%] Built target libgroonga

Also I cherry-picked to 10.4 and evaluated insource and outofsource in case of Ninja and make build generators as well.
And tried following for without ninja config (since I don't see any usage of Ninja in buildbot):

$ cmake ../10.4 -DPLUGIN_TYPE # compile
$make -j4 VERBOSE=1 # no problems
 
$cmake ../10.4 -DBUILD_CONFIG=mysql_release -DPLUGIN_TOKUDB=DYNAMIC # 
$make -j4 VERBOSE=1 # reproduced the problem
$make -j4 VERBOSE=1 # again run and problem solved!

However after inspecting I added guarding to Ninja only with commit change-prefix
I got working example in case of make, but obtained

//No help, variable specified on the command line.
BUILD_CONFIG:UNINITIALIZED=mysql_release

In case of cmake there was a build failure

[2005/3026] Building CXX object storage/perfschema/CMakeFiles/perfschema_embedded.dir/pfs_digest.cc.o
FAILED: storage/perfschema/CMakeFiles/perfschema_embedded.dir/pfs_digest.cc.o 
/usr/bin/c++  -DDBUG_TRACE -DHAVE_CONFIG_H -DMYSQL_SERVER -D_FILE_OFFSET_BITS=64 -I/home/anel/mariadb/10.4/wsrep-lib/include -I/home/anel/mariadb/10.4/wsrep-lib/wsrep-API/v26 -Iinclude -I/home/anel/mariadb/10.4 -I/home/anel/mariadb/10.4/include -I/home/anel/mariadb/10.4/sql -Isql -Ipcre -I/home/anel/mariadb/10.4/pcre -Iextra/wolfssl -I/home/anel/mariadb/10.4/extra/wolfssl/wolfssl -I/home/anel/mariadb/10.4/extra/wolfssl/wolfssl/wolfssl -I/home/anel/mariadb/10.4/zlib -Izlib -pie -fPIC -fstack-protector --param=ssp-buffer-size=4 -O3 -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized -D_FORTIFY_SOURCE=2 -DDBUG_OFF -Wall -Wextra -Wformat-security -Wno-format-truncation -Wno-init-self -Wno-nonnull-compare -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -Wvla -Wwrite-strings   -fPIC -fvisibility=hidden -std=gnu++11 -MD -MT storage/perfschema/CMakeFiles/perfschema_embedded.dir/pfs_digest.cc.o -MF storage/perfschema/CMakeFiles/perfschema_embedded.dir/pfs_digest.cc.o.d -o storage/perfschema/CMakeFiles/perfschema_embedded.dir/pfs_digest.cc.o -c /home/anel/mariadb/10.4/storage/perfschema/pfs_digest.cc
In file included from /home/anel/mariadb/10.4/sql/sql_class.h:546:0,
                 from /home/anel/mariadb/10.4/sql/sql_acl.h:21,
                 from /home/anel/mariadb/10.4/storage/perfschema/pfs_engine_table.h:26,
                 from /home/anel/mariadb/10.4/storage/perfschema/table_helper.h:29,
                 from /home/anel/mariadb/10.4/storage/perfschema/pfs_digest.cc:39:
/home/anel/mariadb/10.4/sql/sql_lex.h:340:10: fatal error: sql_yacc.hh: No such file or directory
 #include "sql_yacc.hh"
          ^~~~~~~~~~~~~
compilation terminated.
[2010/3026] Building CXX object storage/perfschema/CMakeFiles/perfschema_embedded.dir/pfs_engine_table.cc.o

and I don't think the commit 4461b0f9b301 has any problem, but my change.

So I don't think this way is correct way to solve the problem and I'm looking forward to your review.

Comment by Daniel Black [ 2024-01-30 ]

tokudb fix - no time sorry

Generated at Thu Feb 08 08:17:08 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.