diff --git a/ext/openssl/deprecation.rb b/ext/openssl/deprecation.rb index 6f08a206b4..afe989ead1 100644 --- a/ext/openssl/deprecation.rb +++ b/ext/openssl/deprecation.rb @@ -1,7 +1,23 @@ # frozen_string_literal: false module OpenSSL + def self.deprecated_warning_flag + unless flag = (@deprecated_warning_flag ||= nil) + if try_compile("", flag = "-Werror=deprecated-declarations") + $warnflags = "#{@warnflags = $warnflags}" #{flag}" + else + flag = "" + end + @deprecated_warning_flag = flag + end + flag + end + + def self.restore_warning_flag + $warnflags = @warnflags + end + def self.check_func(func, header) - have_func(func, header) + have_func(func, header, deprecated_warning_flag) end def self.check_func_or_macro(func, header) diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb index 5726007697..264130bb51 100644 --- a/ext/openssl/extconf.rb +++ b/ext/openssl/extconf.rb @@ -19,6 +19,9 @@ dir_config("kerberos") Logging::message "=== OpenSSL for Ruby configurator ===\n" +# Check with -Werror=deprecated-declarations if available +OpenSSL.deprecated_warning_flag + ## # Adds -DOSSL_DEBUG for compilation and some more targets when GCC is used # To turn it on, use: --with-debug or --enable-debug @@ -166,5 +169,6 @@ have_func("EVP_PBE_scrypt") Logging::message "=== Checking done. ===\n" create_header +OpenSSL.restore_warning_flag create_makefile("openssl") Logging::message "Done.\n"