Closed masayuki14 closed 3 years ago
$ cmake .. -DWITH_DEBUG=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=~/workspace/sandbox/mysql-8.0.12
CMake Deprecation Warning at CMakeLists.txt:57 (CMAKE_POLICY):
The OLD behavior for policy CMP0045 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.
-- Running cmake version 3.12.0
-- Configuring with MAX_INDEXES = 64U
-- CMAKE_GENERATOR: Unix Makefiles
CMake Error at cmake/os/Darwin.cmake:39 (MESSAGE):
Clang version 8.0 is known to generate wrong code for MySQL, you should
upgrade Xcode
Call Stack (most recent call first):
CMakeLists.txt:251 (INCLUDE)
-- Configuring incomplete, errors occurred!
See also "/Users/morisaki/workspace/sandbox/mysql-8.0.12/build/CMakeFiles/CMakeOutput.log".
OSもHighSierraにしたしXCodeも最新にしたけどうまくいかん 😢
% clang -v
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
8 じゃないんだけどなぁ
改めて始める。 約2年ぶりかぁ。
今回はUbuntuVMでやってみる。
vagrant init bento/ubuntu-20.04
vagrant up
ubuntu20.04でやってみる。ひさびさにvagrantつかう
MySQL 8.0.20 のソースコードをダウンロード mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz を選ぶ
# wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
闇雲にやる前に5.6日本語ドキュメント読むか。 https://dev.mysql.com/doc/refman/5.6/ja/source-installation.html
とりあえず。
apt update
apt upgrade
ドキュメント読んで、とりあえずなんかピックアップ
the installation step installs files under /usr/local/mysql.
/usr/local/mysql
にインストールされる
The component locations under the installation directory are the same as for binary distributions. https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html#binary-installation-layout
各種ファイルはインストール先はaptとかのバイナリインストールと同じ場所 configure で変えられるけどそのままでいい
CMake でのビルド方法はこっち https://dev.mysql.com/doc/internals/en/cmake.html
MySQL officially joined GitHub in September, 2014. For more information about MySQL's move to GitHub, refer to the announcement on the MySQL Release Engineering blog:
ソースコードはGitHubからcloneすればいいのだったー https://github.com/mysql/mysql-server
https://dev.mysql.com/doc/refman/8.0/en/source-installation-prerequisites.html ソースビルドするための要件
こんなところ。
一つずつインストールする
root@vagrant:~# apt install cmake
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-image-unsigned-5.4.0-26-generic linux-modules-5.4.0-26-generic
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
cmake-data gcc gcc-9 libasan5 libatomic1 libcc1-0 libgcc-9-dev libgomp1 libitm1 libjsoncpp1 liblsan0 libquadmath0 librhash0 libtsan0 libubsan1
Suggested packages:
cmake-doc ninja-build gcc-multilib manpages-dev autoconf automake libtool flex bison gdb gcc-doc gcc-9-multilib gcc-9-doc gcc-9-locales
The following NEW packages will be installed:
cmake cmake-data gcc gcc-9 libasan5 libatomic1 libcc1-0 libgcc-9-dev libgomp1 libitm1 libjsoncpp1 liblsan0 libquadmath0 librhash0 libtsan0 libubsan1
0 upgraded, 16 newly installed, 0 to remove and 0 not upgraded.
Need to get 17.4 MB of archives.
After this operation, 77.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 cmake-data all 3.16.3-1ubuntu1 [1,612 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 libjsoncpp1 amd64 1.7.4-3.1ubuntu2 [75.6 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/main amd64 librhash0 amd64 1.3.9-1 [113 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal/main amd64 cmake amd64 3.16.3-1ubuntu1 [3,669 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal/main amd64 libcc1-0 amd64 10-20200411-0ubuntu1 [41.1 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/main amd64 libgomp1 amd64 10-20200411-0ubuntu1 [101 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/main amd64 libitm1 amd64 10-20200411-0ubuntu1 [26.3 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 libatomic1 amd64 10-20200411-0ubuntu1 [9,284 B]
Get:9 http://archive.ubuntu.com/ubuntu focal/main amd64 libasan5 amd64 9.3.0-10ubuntu2 [395 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal/main amd64 liblsan0 amd64 10-20200411-0ubuntu1 [144 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal/main amd64 libtsan0 amd64 10-20200411-0ubuntu1 [319 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal/main amd64 libubsan1 amd64 10-20200411-0ubuntu1 [136 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal/main amd64 libquadmath0 amd64 10-20200411-0ubuntu1 [146 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal/main amd64 libgcc-9-dev amd64 9.3.0-10ubuntu2 [2,359 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal/main amd64 gcc-9 amd64 9.3.0-10ubuntu2 [8,234 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal/main amd64 gcc amd64 4:9.3.0-1ubuntu2 [5,208 B]
Fetched 17.4 MB in 7s (2,559 kB/s)
Selecting previously unselected package cmake-data.
(Reading database ... 51028 files and directories currently installed.)
Preparing to unpack .../00-cmake-data_3.16.3-1ubuntu1_all.deb ...
Unpacking cmake-data (3.16.3-1ubuntu1) ...
Selecting previously unselected package libjsoncpp1:amd64.
Preparing to unpack .../01-libjsoncpp1_1.7.4-3.1ubuntu2_amd64.deb ...
Unpacking libjsoncpp1:amd64 (1.7.4-3.1ubuntu2) ...
Selecting previously unselected package librhash0:amd64.
Preparing to unpack .../02-librhash0_1.3.9-1_amd64.deb ...
Unpacking librhash0:amd64 (1.3.9-1) ...
Selecting previously unselected package cmake.
Preparing to unpack .../03-cmake_3.16.3-1ubuntu1_amd64.deb ...
Unpacking cmake (3.16.3-1ubuntu1) ...
Selecting previously unselected package libcc1-0:amd64.
Preparing to unpack .../04-libcc1-0_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libcc1-0:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libgomp1:amd64.
Preparing to unpack .../05-libgomp1_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libgomp1:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libitm1:amd64.
Preparing to unpack .../06-libitm1_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libitm1:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libatomic1:amd64.
Preparing to unpack .../07-libatomic1_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libatomic1:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libasan5:amd64.
Preparing to unpack .../08-libasan5_9.3.0-10ubuntu2_amd64.deb ...
Unpacking libasan5:amd64 (9.3.0-10ubuntu2) ...
Selecting previously unselected package liblsan0:amd64.
Preparing to unpack .../09-liblsan0_10-20200411-0ubuntu1_amd64.deb ...
Unpacking liblsan0:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libtsan0:amd64.
Preparing to unpack .../10-libtsan0_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libtsan0:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libubsan1:amd64.
Preparing to unpack .../11-libubsan1_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libubsan1:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libquadmath0:amd64.
Preparing to unpack .../12-libquadmath0_10-20200411-0ubuntu1_amd64.deb ...
Unpacking libquadmath0:amd64 (10-20200411-0ubuntu1) ...
Selecting previously unselected package libgcc-9-dev:amd64.
Preparing to unpack .../13-libgcc-9-dev_9.3.0-10ubuntu2_amd64.deb ...
Unpacking libgcc-9-dev:amd64 (9.3.0-10ubuntu2) ...
Selecting previously unselected package gcc-9.
Preparing to unpack .../14-gcc-9_9.3.0-10ubuntu2_amd64.deb ...
Unpacking gcc-9 (9.3.0-10ubuntu2) ...
Selecting previously unselected package gcc.
Preparing to unpack .../15-gcc_4%3a9.3.0-1ubuntu2_amd64.deb ...
Unpacking gcc (4:9.3.0-1ubuntu2) ...
Setting up libgomp1:amd64 (10-20200411-0ubuntu1) ...
Setting up libasan5:amd64 (9.3.0-10ubuntu2) ...
Setting up libquadmath0:amd64 (10-20200411-0ubuntu1) ...
Setting up libatomic1:amd64 (10-20200411-0ubuntu1) ...
Setting up libubsan1:amd64 (10-20200411-0ubuntu1) ...
Setting up librhash0:amd64 (1.3.9-1) ...
Setting up cmake-data (3.16.3-1ubuntu1) ...
Setting up libcc1-0:amd64 (10-20200411-0ubuntu1) ...
Setting up liblsan0:amd64 (10-20200411-0ubuntu1) ...
Setting up libitm1:amd64 (10-20200411-0ubuntu1) ...
Setting up libjsoncpp1:amd64 (1.7.4-3.1ubuntu2) ...
Setting up libtsan0:amd64 (10-20200411-0ubuntu1) ...
Setting up libgcc-9-dev:amd64 (9.3.0-10ubuntu2) ...
Setting up cmake (3.16.3-1ubuntu1) ...
Setting up gcc-9 (9.3.0-10ubuntu2) ...
Setting up gcc (4:9.3.0-1ubuntu2) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...
root@vagrant:~# cmake --version
cmake version 3.16.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
root@vagrant:~# apt install make
Reading package lists... Done
Building dependency tree
Reading state information... Done
make is already the newest version (4.2.1-1.2).
make set to manually installed.
The following packages were automatically installed and are no longer required:
linux-image-unsigned-5.4.0-26-generic linux-modules-5.4.0-26-generic
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@vagrant:~# apt install gcc
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version (4:9.3.0-1ubuntu2).
gcc set to manually installed.
The following packages were automatically installed and are no longer required:
linux-image-unsigned-5.4.0-26-generic linux-modules-5.4.0-26-generic
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@vagrant:~# apt install openssl
Reading package lists... Done
Building dependency tree
Reading state information... Done
openssl is already the newest version (1.1.1f-1ubuntu2).
The following packages were automatically installed and are no longer required:
linux-image-unsigned-5.4.0-26-generic linux-modules-5.4.0-26-generic
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
ncurses は以下のコマンド群でOKなのかな。全部はいっている
captoinfo
, a termcap conversion toolclear
, utility for clearing the screeninfocmp
, the terminfo decompilertabs
, set tabs on a terminaltic
, the terminfo compilertoe
, list (table of) terminfo entriestput
, utility for retrieving terminal capabilities in shell scriptstset
, to initialize the terminal# apt install bison
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-image-unsigned-5.4.0-26-generic linux-modules-5.4.0-26-generic
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
m4
Suggested packages:
bison-doc m4-doc
The following NEW packages will be installed:
bison m4
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 856 kB of archives.
After this operation, 2,386 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 m4 amd64 1.4.18-4 [199 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 bison amd64 2:3.5.1+dfsg-1 [657 kB]
Fetched 856 kB in 3s (332 kB/s)
Selecting previously unselected package m4.
(Reading database ... 54092 files and directories currently installed.)
Preparing to unpack .../archives/m4_1.4.18-4_amd64.deb ...
Unpacking m4 (1.4.18-4) ...
Selecting previously unselected package bison.
Preparing to unpack .../bison_2%3a3.5.1+dfsg-1_amd64.deb ...
Unpacking bison (2:3.5.1+dfsg-1) ...
Setting up m4 (1.4.18-4) ...
Setting up bison (2:3.5.1+dfsg-1) ...
update-alternatives: using /usr/bin/bison.yacc to provide /usr/bin/yacc (yacc) in auto mode
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for install-info (6.7.0.dfsg.2-5) ...
これでいいかしら。
clone する
git clone https://github.com/mysql/mysql-server.git
重かったからやりなおし
git clone --depth 1 https://github.com/mysql/mysql-server.git
それでもまぁまぁ重かった。
$ git branch
* 8.0
デフォルトで8.0になってる。
ビルドのドキュメントじゃなかった。 2.9.7 MySQL Source-Configuration Options
こっちでビルドオプションのことが書いてある。デバッグビルドするにはこれ見ないと行けなさそう。
めっちゃ長いし、めっちゃ多いので、読めそうにない。
debug
を含むオプションを見ておく。
-DWITH_DEBUG=ON
-DWITH_INNODB_EXTRA_DEBUG=ON
-DWITH_MSCRT_DEBUG=ON
たぶんこの3つのオプションをONにしてコンパイルすればいいと思う
2.9.8 Dealing with Problems Compiling MySQL よくある失敗と対象、的な内容
再構成するときは CMakeCache.txt.
を消すべし。
make clean
rm CMakeCache.txt
C++コンパイラが必要ぽいけど g++
は入ってないが、まぁ今はいいか。
Doxgen とな。 https://dev.mysql.com/doc/dev/mysql-server/latest/PAGE_GET_STARTED.html#start_source
Debugging The easiest way to install a server, and attach a debugger to it, is to start the mysql-test-run (MTR) tool with debugging options
cd mysql-test
./mtr --ddd main.parser
ビルドのドキュメントは Chapter 4 Building MySQL Server with CMake こっちを読もう。
mkdir bld_debug
cd bld_debug
cmake .. -DCMAKE_BUILD_TYPE=Debug
make
なんかさっき見てたオプションと違うけど、まぁいいのか。
- DCMAKE_BUILD_TYPE=type
- Debug: Disable optimizations and generate debugging information. This build type is also used if the WITH_DEBUG option is enabled. That is, -DWITH_DEBUG=1 has the same effect as -DCMAKE_BUILD_TYPE=Debug.
デバッグ:最適化を無効にし、デバッグ情報を生成します。このビルドタイプは、WITH_DEBUGオプションが有効な場合にも使用されます。つまり、-DWITH_DEBUG = 1は-DCMAKE_BUILD_TYPE = Debugと同じ効果があります。
4.4 Detailed How-to-Build Instructions 続きは 4.4.5 Building Debug Configurations もチェックしよう。
MacのXCode使う場合は
cmake .. -G Xcode
にできるらしい。
cmake .. -DCMAKE_BUILD_TYPE=Debug -G Xcode
にすればXcodeでDebugBuildできるってことかな?
-DCMAKE_BUILD_TYPE=Debug
は -DWITH_DEBUG=ON
の alias だった
インストール先を指定するには cmake のオプションか make install のオプションか、どっちでもいい。
cmake .. -DCMAKE_INSTALL_PREFIX="/some/absolute/path"
make install DESTDIR="/some/absolute/path"
これからソースビルドする。
ドキュメントは 2.9.4 Installing MySQL Using a Standard Source Distribution の Configure the Distribution 以降にある。
cmake のオプションとは調べたとおりに使っていけばいいだろう。
やるぞー
cd mysql-server/
mkdir bld
cd bld
configure
cmake ..
ドキュメントは cmake ../mysql-src
だったけど、それはなかった。git clone したのはソースコード自体だとおもう。
$ cmake ..
-- Running cmake version 3.16.3
-- MySQL 8.0.20
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:337 (PROJECT):
No CMAKE_CXX_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "/home/vagrant/mysql-server/CMakeFiles/CMakeOutput.log".
See also "/home/vagrant/mysql-server/CMakeFiles/CMakeError.log".
c++コンパイラがない。やはり。
# apt install g++
cmake する。 デバッグオプションつけないといかん。
$ cmake .. -DWITH_DEBUG=ON
-- Running cmake version 3.16.3
-- MySQL 8.0.20
-- The CXX compiler identification is GNU 9.3.0
-- 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
-- Source directory /home/vagrant/mysql-server
-- Binary directory /home/vagrant/mysql-server
CMake Error at CMakeLists.txt:367 (MESSAGE):
Please do not build in-source. Out-of source builds are highly
recommended: you can have multiple builds for the same source, and there is
an easy way to do cleanup, simply remove the build directory (note that
'make clean' or 'make distclean' does *not* work)
You *can* force in-source build by invoking cmake with
-DFORCE_INSOURCE_BUILD=1
-- Configuring incomplete, errors occurred!
See also "/home/vagrant/mysql-server/CMakeFiles/CMakeOutput.log".
See also "/home/vagrant/mysql-server/CMakeFiles/CMakeError.log".
エラー出た。
$ make clean
make: *** No rule to make target 'clean'. Stop.
$ rm ../CMakeCache.txt
https://github.com/masayuki14/worklog/issues/15#issuecomment-648634841 のやつをやればいいのか?
そういうことだった。
$ cmake .. -DWITH_DEBUG=ON
-- Running cmake version 3.16.3
-- Found Git: /usr/bin/git (found version "2.25.1")
-- MySQL 8.0.20
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- 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
-- Source directory /home/vagrant/mysql-server
-- Binary directory /home/vagrant/mysql-server/bld
-- CMAKE_GENERATOR: Unix Makefiles
-- Looking for SHM_HUGETLB
-- Looking for SHM_HUGETLB - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void *
-- Check size of void * - done
-- SIZEOF_VOIDP 8
-- Performing Test HAVE_C_FLOATING_POINT_FUSED_MADD
-- Performing Test HAVE_C_FLOATING_POINT_FUSED_MADD - Failed
-- Performing Test HAVE_CXX_FLOATING_POINT_FUSED_MADD
-- Performing Test HAVE_CXX_FLOATING_POINT_FUSED_MADD - Failed
-- Packaging as: mysql-8.0.20-Linux-x86_64
-- Performing Test C_LD_LLD_RESULT
-- Performing Test C_LD_LLD_RESULT - Failed
-- Performing Test CXX_LD_LLD_RESULT
-- Performing Test CXX_LD_LLD_RESULT - Failed
-- Performing Test C_LD_GOLD_RESULT
-- Performing Test C_LD_GOLD_RESULT - Success
-- Performing Test CXX_LD_GOLD_RESULT
-- Performing Test CXX_LD_GOLD_RESULT - Success
-- Looked for boost/version.hpp in and
-- BOOST_INCLUDE_DIR BOOST_INCLUDE_DIR-NOTFOUND
-- LOCAL_BOOST_DIR
-- LOCAL_BOOST_ZIP
-- Could not find (the correct version of) boost.
-- MySQL currently requires boost_1_70_0
CMake Error at cmake/boost.cmake:104 (MESSAGE):
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>
This CMake script will look for boost in <directory>. If it is not there,
it will download and unpack it (in that directory) for you.
You can also download boost manually, from
https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz
If you are inside a firewall, you may need to use an https proxy:
export https_proxy=http://example.com:80
Call Stack (most recent call first):
cmake/boost.cmake:273 (COULD_NOT_FIND_BOOST)
CMakeLists.txt:1061 (INCLUDE)
-- Configuring incomplete, errors occurred!
See also "/home/vagrant/mysql-server/bld/CMakeFiles/CMakeOutput.log".
See also "/home/vagrant/mysql-server/bld/CMakeFiles/CMakeError.log".
またエラー。
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>
に従えばよい。
参考にしたこの辺の記事でも boost には触れられていたけど、ここまで見てきたドキュメントには見つからなくてなんじゃらほい、って感じだったけどここでどういうものかわかった。
The Boost library is required to build MySQL. These CMake options enable control over the library source location, and whether to download it automatically:
Boostライブラリが必要で、自動ダウンロードしてくれるみたい。
これは自動でダウンロードする設定にしたほうが良さそう。
http://labs.gree.jp/blog/2018/07/17099/ これやってみる。
etc