Skip to content
Snippets Groups Projects
Commit d1e4d3eb authored by James Liu's avatar James Liu
Browse files

gitaly: Add Git build opts to Gitaly definition

With https://gitlab.com/gitlab-org/gitaly/-/merge_requests/7035, we'll
start embedding the Git binaries inside Gitaly itself. This means that
Gitaly's `make install` target will also implicitly build Git, and embed
the binaries using the go:embed machinery.

Omnibus' Git software definition (config/software/git.rb) specifies a
number of build options to tell Git where specific required libraries
are located, and also toggles some compiler options depending on the
system we're compiling on. These options must now be set whenever Gitaly
is compiled.

Merge the options from config/software/git.rb into Gitaly's software
definition. This allows us to roll out embedded Git binaries without
disrupting how Git is built by Omnibus. Build options are set directly
as env vars since we can't write a config.mak file directly. This should
be okay as Gitaly itself does not use these flags.

Later on, we'll remove Omnibus' ability to build Git binaries with
https://gitlab.com/gitlab-org/gitaly/-/issues/6195
parent afc6ab8e
2 merge requests!153heptapod#1722: making 17.3 the new stable,!151Merge upstream Omnibus GitLab into Omnibus Heptapod
......@@ -57,6 +57,10 @@
# Similar is the case for SLES OSs also.
git_cflags += ' -std=gnu99' if OhaiHelper.get_centos_version.to_i == 7 || OhaiHelper.os_platform == 'sles'
# NOTE: the Git software definition is in the process of being deprecated in favour of bundling
# Git with Gitaly. Any changes to the following build options must be replicated to the Gitaly
# software definition at config/software/gitaly.rb in the env hash. See
# https://gitlab.com/gitlab-org/gitaly/-/issues/6195 for more information.
build_options = [
"# Added by Omnibus git software definition git.rb",
"GIT_APPEND_BUILD_OPTIONS += CURLDIR=#{install_dir}/embedded",
......
......@@ -31,6 +31,13 @@
dependency 'libicu'
dependency 'omnibus-gitlab-gems'
# Dependencies for building Git as part of Gitaly
dependency 'zlib'
dependency 'openssl' unless Build::Check.use_system_ssl?
dependency 'curl'
dependency 'pcre2'
dependency 'libiconv'
# Technically, gitaly depends on git also. But because of how omnibus arranges
# components to be built, this causes git to be built early in the process. But
# in our case, git is built from gitaly source code. This results in git
......@@ -47,7 +54,26 @@
build do
env = with_standard_compiler_flags(with_embedded_path)
git_cflags = '-fno-omit-frame-pointer'
# CentOS 7 uses gcc v4.8.5, which uses C90 (`-std=gnu90`) by default.
# C11 is a newer standard than C90, and gcc v5.1.0 switched the default
# from `std=gnu90` to `std=gnu11`.
# Git v2.35 added a balloon test that will fail the build if
# C99 is not supported. On other platforms, C11 may be required
# (https://gitlab.com/gitlab-org/gitlab-git/-/commit/7bc341e21b5).
# Similar is the case for SLES OSs also.
git_cflags += ' -std=gnu99' if OhaiHelper.get_centos_version.to_i == 7 || OhaiHelper.os_platform == 'sles'
env['CURLDIR'] = "#{install_dir}/embedded"
env['ICONVDIR'] = "#{install_dir}/embedded"
env['ZLIB_PATH'] = "#{install_dir}/embedded"
env['NEEDS_LIBICONV'] = 'YesPlease'
env['NO_R_TO_GCC_LINKER'] = 'YesPlease'
env['INSTALL_SYMLINKS'] = 'YesPlease'
env['CFLAGS'] = "\"#{git_cflags}\""
if Build::Check.use_system_ssl?
env['CMAKE_FLAGS'] = OpenSSLHelper.cmake_flags
env['PKG_CONFIG_PATH'] = OpenSSLHelper.pkg_config_dirs
env['FIPS_MODE'] = '1'
......@@ -50,7 +76,9 @@
if Build::Check.use_system_ssl?
env['CMAKE_FLAGS'] = OpenSSLHelper.cmake_flags
env['PKG_CONFIG_PATH'] = OpenSSLHelper.pkg_config_dirs
env['FIPS_MODE'] = '1'
else
env['OPENSSLDIR'] = "#{install_dir}/embedded"
end
make "install PREFIX=#{install_dir}/embedded", env: env
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment