Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ CrossLibraries.each do |xlib|
bundle install --local &&
#{ "rake install_darwin_mig[__arm64__]" if platform =~ /arm64-darwin/ }
#{ "rake install_darwin_mig[__x86_64__]" if platform =~ /x86_64-darwin/ }
rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKEOPTS=-j`nproc` RUBY_CC_VERSION=#{RakeCompilerDock.ruby_cc_version("~>2.7", "~>3.0")}
rake native:#{platform} pkg/#{$gem_spec.full_name}-#{platform}.gem MAKEFLAGS="-j`nproc` V=1" RUBY_CC_VERSION=#{RakeCompilerDock.ruby_cc_version("~>2.7", "~>3.0")}
EOT
end
desc "Build the native binary gems"
Expand Down
24 changes: 18 additions & 6 deletions ext/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ def port_path
"#{target}/#{RUBY_PLATFORM}"
end

# Add "--prefix=/", to avoid our actual build install path compiled into the binary.
# Instead use DESTDIR variable of make to set our install path.
def configure_prefix
"--prefix="
end

def cook_and_activate
checkpoint = File.join(self.target, "#{self.name}-#{self.version}-#{RUBY_PLATFORM}.installed")
unless File.exist?(checkpoint)
Expand All @@ -70,13 +76,13 @@ def configure
envs = []
envs << "CFLAGS=-DDSO_WIN32 -DOPENSSL_THREADS" if RUBY_PLATFORM =~ /mingw|mswin/
envs << "CFLAGS=-fPIC -DOPENSSL_THREADS" if RUBY_PLATFORM =~ /linux|darwin/
execute('configure', ['env', *envs, "./Configure", openssl_platform, "threads", "-static", "CROSS_COMPILE=#{host}-", configure_prefix], altlog: "config.log")
execute('configure', ['env', *envs, "./Configure", openssl_platform, "threads", "-static", "CROSS_COMPILE=#{host}-", "--prefix=/"], altlog: "config.log")
end
def compile
execute('compile', "#{make_cmd} build_libs")
end
def install
execute('install', "#{make_cmd} install_dev")
execute('install', "#{make_cmd} install_dev DESTDIR=#{path}")
end
end

Expand Down Expand Up @@ -104,6 +110,9 @@ def configure
end
super
end
def install
execute('install', "#{make_cmd} install DESTDIR=#{path}")
end
end
# We specify -fcommon to get around duplicate definition errors in recent gcc.
# See https://github.com/cockroachdb/cockroach/issues/49734
Expand All @@ -112,6 +121,7 @@ def configure
recipe.configure_options << "--without-keyutils"
recipe.configure_options << "--disable-nls"
recipe.configure_options << "--disable-silent-rules"
recipe.configure_options << "--disable-rpath"
recipe.configure_options << "--without-system-verto"
recipe.configure_options << "krb5_cv_attr_constructor_destructor=yes"
recipe.configure_options << "ac_cv_func_regcomp=yes"
Expand Down Expand Up @@ -146,12 +156,13 @@ def configure_defaults
'--without-zlib',
'--without-icu',
'--without-readline',
'--disable-rpath',
'ac_cv_search_gss_store_cred_into=',
]
end
def compile
execute 'compile include', "#{make_cmd} -C src/include install"
execute 'compile interfaces', "#{make_cmd} -C src/interfaces install"
execute 'compile include', "#{make_cmd} -C src/include install DESTDIR=#{path}"
execute 'compile interfaces', "#{make_cmd} -C src/interfaces install DESTDIR=#{path}"
end
def install
end
Expand All @@ -169,15 +180,16 @@ def install
# Use our own library name for libpq to avoid loading of system libpq by accident.
FileUtils.ln_sf File.join(postgresql_recipe.port_path, "lib/#{libpq_orig}"),
File.join(postgresql_recipe.port_path, "lib/#{libpq_rubypg}")
# Link to libpq_rubypg in our ports directory without adding it as rpath (like dir_config does)
$CFLAGS << " -I#{postgresql_recipe.path}/include"
$LDFLAGS << " -L#{postgresql_recipe.path}/lib"
# Avoid dependency to external libgcc.dll on x86-mingw32
$LDFLAGS << " -static-libgcc" if RUBY_PLATFORM =~ /mingw|mswin/
# Avoid: "libpq.so: undefined reference to `dlopen'" in cross-ruby-2.7.8
$LDFLAGS << " -Wl,--no-as-needed" if RUBY_PLATFORM !~ /aarch64|arm64|darwin/
# Find libpq in the ports directory coming from lib/3.x
# It is shared between all compiled ruby versions.
$LDFLAGS << " '-Wl,-rpath=$$ORIGIN/../../ports/#{gem_platform}/lib'" if RUBY_PLATFORM =~ /linux/
# Don't use pg_config for cross build, but --with-pg-* path options
dir_config('pg', "#{postgresql_recipe.path}/include", "#{postgresql_recipe.path}/lib")

$defs.push( "-DPG_IS_BINARY_GEM")
else
Expand Down
Loading