Skip to content

Commit

Permalink
Upgrade openssl and freetds (#322)
Browse files Browse the repository at this point in the history
- Fix openssl being out of date. (Bumped to 1.0.2j)

- Fix freetds being out of date. (Bumped to 1.00.21)

- Fix the invalid w32 application error which occurs on x64 platforms
  occasionally due to problems with DLLs generated via dllwrap after
  being relocated.

Relates to: #290 and #310
  • Loading branch information
coderjoe authored Dec 7, 2016
1 parent 86c5a0e commit ed691ff
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
9 changes: 2 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,15 @@ Rake::ExtensionTask.new('tiny_tds', gemspec) do |ext|
gemplat = spec.platform.to_s
host = platform_host_map[gemplat]
dlls = [
"libeay32-1.0.2g-#{host}.dll",
"ssleay32-1.0.2g-#{host}.dll",
"libeay32-#{OPENSSL_VERSION}-#{host}.dll",
"ssleay32-#{OPENSSL_VERSION}-#{host}.dll",
'libiconv-2.dll',
'libsybdb-5.dll'
]
# We don't need the sources in a fat binary gem
spec.files = spec.files.reject { |f| f =~ %r{^ports\/archives/} }
spec.files += dlls.map { |dll| "ports/#{host}/bin/#{File.basename(dll)}" }
spec.files += Dir.glob('exe/*')
dlls.each do |dll|
file "ports/#{host}/bin/#{dll}" do |t|
sh 'x86_64-w64-mingw32-strip', t.name
end
end
end
end

Expand Down
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,8 @@ environment:
secure: fYKSKV4v+36OFQp2nZdX4DfUpgmy5cm0wuR73cgdmEk=
matrix:
- ruby_version: "23-x64"
- ruby_version: "23"
- ruby_version: "22-x64"
- ruby_version: "22"
on_failure:
- find -name compile.log | xargs cat
18 changes: 15 additions & 3 deletions ext/tiny_tds/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,19 @@ def configure
execute "configure", "sh -c \"#{args.join(" ")}\""
end

def dllwrap(dllname, outputlib, deffile, linkto)
gcc = consolidated_host(RbConfig::CONFIG["CC"])

#RbConfig does not provide dlltool, but it should exist where dllwrap lives
dlltool = consolidated_host(RbConfig::CONFIG["DLLWRAP"]).sub('dllwrap','dlltool')

execute "gcc-#{dllname}-compile", "#{gcc} -Wl,--base-file,#{dllname}.base -mdll -o #{dllname}.dll --leading-underscore #{linkto}"
execute "dlltool-#{dllname}-exp", "#{dlltool} --base-file #{dllname}.base --output-exp #{dllname}.exp --dllname #{dllname}.dll --def #{deffile}"
execute "gcc-#{dllname}-dll", "#{gcc} -Wl,--base-file,#{dllname}.base #{dllname}.exp -mdll -o #{dllname}.dll --leading-underscore #{linkto}"
execute "dlltool-#{dllname}-outputlib", "#{dlltool} --base-file #{dllname}.base --output-exp #{dllname}.exp --dllname #{dllname}.dll --def #{deffile} --output-lib #{outputlib}"
execute "gcc-#{dllname}-link", "#{gcc} #{dllname}.exp -mdll -o #{dllname}.dll --leading-underscore #{linkto}"
end

def compile
super
# OpenSSL DLLs are called "libeay32.dll" and "ssleay32.dll" per default,
Expand All @@ -174,9 +187,8 @@ def compile
# with our own naming scheme.
execute "mkdef-libeay32", "(perl util/mkdef.pl 32 libeay >libeay32.def)"
execute "mkdef-ssleay32", "(perl util/mkdef.pl 32 ssleay >ssleay32.def)"
dllwrap = consolidated_host(RbConfig::CONFIG["DLLWRAP"])
execute "dllwrap-libeay32", "#{dllwrap} --dllname libeay32-#{version}-#{host}.dll --output-lib libcrypto.dll.a --def libeay32.def libcrypto.a -lwsock32 -lgdi32 -lcrypt32"
execute "dllwrap-ssleay32", "#{dllwrap} --dllname ssleay32-#{version}-#{host}.dll --output-lib libssl.dll.a --def ssleay32.def libssl.a libcrypto.dll.a"
dllwrap("libeay32-#{version}-#{host}", "libcrypto.dll.a", "libeay32.def", "libcrypto.a -lws2_32 -lgdi32 -lcrypt32")
dllwrap("ssleay32-#{version}-#{host}", "libssl.dll.a", "ssleay32.def", "libssl.a libcrypto.dll.a")
end

def install
Expand Down
4 changes: 2 additions & 2 deletions ext/tiny_tds/extconsts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
ICONV_VERSION = ENV['TINYTDS_ICONV_VERSION'] || "1.14"
ICONV_SOURCE_URI = "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-#{ICONV_VERSION}.tar.gz"

OPENSSL_VERSION = ENV['TINYTDS_OPENSSL_VERSION'] || '1.0.2g'
OPENSSL_VERSION = ENV['TINYTDS_OPENSSL_VERSION'] || '1.0.2j'
OPENSSL_SOURCE_URI = "https://www.openssl.org/source/openssl-#{OPENSSL_VERSION}.tar.gz"

FREETDS_VERSION = ENV['TINYTDS_FREETDS_VERSION'] || "1.00.15"
FREETDS_VERSION = ENV['TINYTDS_FREETDS_VERSION'] || "1.00.21"
FREETDS_VERSION_INFO = Hash.new { |h,k|
h[k] = {files: "ftp://ftp.freetds.org/pub/freetds/stable/freetds-#{k}.tar.bz2"}
}
Expand Down

0 comments on commit ed691ff

Please sign in to comment.