summaryrefslogtreecommitdiff
path: root/README-DEV
blob: da4a9bbb5bafef4e7045c069ece155f8450eeac3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
This document describes how MySQL was packaged for build2. In particular, this
understanding will be useful when upgrading to a new upstream version.

The upstream package contains the MySQL server, libmysqlclient library and a
number of client/administrative utilities (mysql, mysqlcheck, etc). Currently,
we only package libmysqlclient (see libmysqlclient/README-DEV for details).

We add the upstream package as a git submodule and symlink the required files
and subdirectories into the build2 package subdirectories. Then, when required,
we "overlay" the upstream with our own header/source files, placing them into
the library/program directories and their downstream/ subdirectories.

Note that symlinking upstream submodule subdirectories into a build2 package
subdirectory results in creating intermediate build files (.d, .o, etc) inside
upstream directory while building the package in source tree. That's why we
need to make sure that packages do not share upstream source files via
subdirectory symlinks, not to also share the related intermediate files. If
several packages need to compile the same upstream source file, then only one
of them can symlink it via the parent directory while others must symlink it
directly. We also add the `ignore = untracked` configuration option into
.gitmodules to make sure that git ignores the intermediate build files under
upstream/ subdirectory.

The upstream package can be configured to contain a specific feature set. We
reproduce the union of features configured for the upstream source package in
Debian and Fedora distributions. The configuration options defining these sets
are specified in the Debian's rules and Fedora's RPM .spec files. Note,
however, that at the time of this writing the latest packaged versions are
different: 5.7.25 on Debian and 8.0.15 on Fedora. These files can be obtained
as follows:

$ wget https://download.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/source/tree/Packages/c/community-mysql-8.0.15-1.fc30.src.rpm
$ rpm2cpio community-mysql-8.0.15-1.fc30.src.rpm | cpio -civ '*.spec'

#$ wget http://deb.debian.org/debian/pool/main/m/mysql-5.7/mysql-5.7_5.7.25-1.debian.tar.xz
#$ tar xf mysql-5.7_5.7.25-1.debian.tar.xz debian/rules

Instead of using MySQL 5.7.25 Debian's rules for MySQL 8.0.15 we are
packaging, let's use upstream/packaging/deb-in/rules.in. That's not ideal but
is, probably, better than nothing.

Here are the discovered configuration options.

Debian:

  -DWITH_INNODB_MEMCACHED=ON -DWITH_NUMA=ON

Fedora:

  -DWITH_INNODB_MEMCACHED=ON -DENABLED_LOCAL_INFILE=ON

Omitting options that are not related to the client library we end up with:

  -DENABLED_LOCAL_INFILE=ON

See the configuration options description at
https://dev.mysql.com/doc/refman/8.0/en/source-configuration-options.html

As a side note, on Debian and Fedora libmysqlclient is packaged under the
libmysqlclient20 and community-mysql-libs package names respectively. The
headers-containing development packages are libmysqlclient-dev and
community-mysql-devel. Search for the Debian and Fedora packages at
https://packages.debian.org/search and
https://apps.fedoraproject.org/packages/.

Normally, when packaging a cmake-based project, we try to deduce the source
file and compilation/linking option sets analyzing the root and
feature/component/platform-specific CMakeLists.txt and .cmake files. In
practice, however, that can be uneasy and error prone, so you may also need
to refer to cmake-generated configuration files or, as a last resort, to see
the actual compiler and linker command lines in the build log. If that's the
case, you can configure/build the upstream package on the platform of interest
running the following commands in the project root directory.

On POSIX:

$ mkdir build
$ cd build
$ cmake -DDOWNLOAD_BOOST=ON -DWITH_BOOST=../boost -DWITHOUT_SERVER=ON \
        -DENABLED_LOCAL_INFILE=ON ..

$ make VERBOSE=1 >build.log 2>&1

Here we assume that OpenSSL is installed into the system.

With MSVC:

Run Visual Studio and change the settings:

Tools > Options > Projects and Solutions > Build and Run >
MSBuild project build output verbosity: Detailed

Build libssl from cppget.org, install to C:/openssl and rename *.dll.lib to
*.lib to match MySQL's expectations.

> set OPENSSL_ROOT_DIR=C:/openssl
> set PATH=c:\openssl\bin;%PATH%
> mkdir build
> cd build
> cmake -DDOWNLOAD_BOOST=ON -DWITH_BOOST=../boost -DWITHOUT_SERVER=ON ^
  -DENABLED_LOCAL_INFILE=ON ..  -G "Visual Studio 15 2017 Win64" ^ >config.log 2>&1
> devenv MySQL.sln /build RelWithDebInfo >build-log 2>&1

With MinGW GCC:

MinGW GCC is not mentioned at the "Installing MySQL from Source" page as a
supported compiler for Windows and is, presumably, unsupported. Trying to use
it fails at the compilation stage:

> set OPENSSL_ROOT_DIR=C:/openssl
> set PATH=c:\openssl\bin;C:\msys64\mingw64\bin;%PATH%
> mkdir build
> cd build
> cmake -DDOWNLOAD_BOOST=ON -DWITH_BOOST=../boost -DWITHOUT_SERVER=ON ^
  -DENABLED_LOCAL_INFILE=ON ..  -G  "MinGW Makefiles"
> mingw32-make

When the packaging is complete, build all the project packages in source tree
and make sure that all the preprocessor include directives reference the
packaged header files, rather than MariaDB or MySQL headers that are installed
into the system. It's easy to miss some headers in the package if MariaDB or
MySQL development package is installed on the host. We also need to check if
the bundled library headers are picked up. To verify the correctness you can
build the merged project, concatenate the produced .d files, sort the resulting
file removing duplicates and edit the result, leaving only the system headers.
Afterwards grep through the remained headers for some patterns:

$ cat `find . -type f -name '*.d'` | sort -u >headers
$ emacs headers  # Edit, leaving system headers only.
$ fgrep -e 'mysql' -e 'mariadb' -e 'openssl' -e 'zlib' headers