From: merch-redmine@... Date: 2016-12-29T21:58:54+00:00 Subject: [ruby-core:78912] [Ruby trunk Bug#13069] mkmf: ignore linker warnings on OpenBSD Issue #13069 has been updated by Jeremy Evans. I think this is a better fix. This keeps the `:werror` behavior in `Logging::postpone`, it just turns off the use of `:werror` by default. Users that want werror behavior by default can set `$werror = true`. ~~~ diff --- lib/mkmf.rb.orig +++ lib/mkmf.rb @@ -88,6 +88,7 @@ module MakeMakefile $static = nil $config_h = '$(arch_hdrdir)/ruby/config.h' $default_static = $static + $werror = false unless defined?($werror) unless defined? $configure_args $configure_args = {} @@ -611,7 +612,7 @@ def with_cppflags(flags) end def try_cppflags(flags, opts = {}) - try_header(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts)) + try_header(MAIN_DOES_NOTHING, flags, {:werror => $werror}.update(opts)) end def append_cppflags(flags, *opts) @@ -633,7 +634,7 @@ def with_cflags(flags) end def try_cflags(flags, opts = {}) - try_compile(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts)) + try_compile(MAIN_DOES_NOTHING, flags, {:werror => $werror}.update(opts)) end def append_cflags(flags, *opts) @@ -655,7 +656,7 @@ def with_ldflags(flags) end def try_ldflags(flags, opts = {}) - try_link(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts)) + try_link(MAIN_DOES_NOTHING, flags, {:werror => $werror}.update(opts)) end def append_ldflags(flags, *opts) @@ -1408,7 +1409,7 @@ def convertible_int(type, headers = nil, opts = nil, &b) u = "unsigned " if signed > 0 prelude << "extern rbcv_typedef_ foo();" compat = UNIVERSAL_INTS.find {|t| - try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, :werror=>true, &b) + try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, :werror=>$werror, &b) } end if compat ~~~ This basically reverts the changes made in r50215 and r50216, except that it allows enabling werror globally via `$werror`. The commit messages for both commits do not describe why the code was changed to default to `{:werror=>true}`. From looking at the history of mkmf, the werror code was originally added in r30107 to work around declaration conflict warnings, so maybe we want to keep `:werror=>true` in the final diff block. r35101 states that the exit code may be lost on mingw, so we may want to default `$werror` to true on mingw if that is still the case. I think we need to change the current default of treating warnings as errors. We should handle broken environments that do not use return codes correctly on an exception basis. ---------------------------------------- Bug #13069: mkmf: ignore linker warnings on OpenBSD https://bugs.ruby-lang.org/issues/13069#change-62326 * Author: Anton Lindqvist * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- Installing gems with native extensions fails on my OpenBSD machine since the linker emits warnings causing stderr to not be empty as expected. The warnings are security recommendations that does not affect the linked binary. See examples below from my mkmf.log caused by libruby: ~~~ warning: warning: strcpy() is almost always misused, please use strlcpy() warning: warning: strcat() is almost always misused, please use strlcat() warning: warning: sprintf() is often misused, please use snprintf() warning: warning: vsprintf() is often misused, please use vsnprintf() ~~~ Attached is patch that checks the output for such harmless warnings. Not sure if this exception should be allowed on all platforms, but instead wrapped in a `RUBY_PLATFORM =~ /openbsd/` conditional or something similar. ---Files-------------------------------- ruby-mkmf_openbsd.diff (880 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: