https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112016-12-25T17:58:25ZRuby Issue Tracking SystemRuby master - Bug #13069: mkmf: ignore linker warnings on OpenBSDhttps://redmine.ruby-lang.org/issues/13069?journal_id=622382016-12-25T17:58:25Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul></ul><p>Personally, I think it would be better to just check the return code and ignore the content of the log file. Are there environments that ruby wants to support where compiling returns success when it actually fails? The supplied patch won't handle all of the warnings produced by OpenBSD's linker, though it does handle the most common ones.</p> Ruby master - Bug #13069: mkmf: ignore linker warnings on OpenBSDhttps://redmine.ruby-lang.org/issues/13069?journal_id=622432016-12-26T02:56:36Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/62243/diff?detail_id=43516">diff</a>)</li><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>Seems <code>sprintf</code> nor <code>vsprintf</code> are used on OpenBSD.<br>
Those warnings are always emitted regardless use of the functions?</p> Ruby master - Bug #13069: mkmf: ignore linker warnings on OpenBSDhttps://redmine.ruby-lang.org/issues/13069?journal_id=622502016-12-26T10:00:05ZAnonymous
<ul></ul><p>Nobuyoshi Nakada wrote:</p>
<blockquote>
<p>Seems <code>sprintf</code> nor <code>vsprintf</code> are used on OpenBSD.<br>
Those warnings are always emitted regardless use of the functions?</p>
</blockquote>
<p>Here's a minimal example causing the errors to be outputted while<br>
dynamically linking against ruby:</p>
<pre><code>$ env "PATH=${DESTDIR}/usr/local/bin:${PATH}" ruby -v
ruby 2.4.0dev (2016-12-24 trunk 57169) [x86_64-openbsd6.0]
$ cat test.c
#include "ruby.h"
int main(void) { return 0; }
$ cc \
-o test \
-I ${DESTDIR}/usr/local/include/ruby-2.4.0/x86_64-openbsd6.0 \
-I ${DESTDIR}/usr/local/include/ruby-2.4.0 \
test.c \
-L ${DESTDIR}/usr/local/lib \
-lruby \
-lm \
-lpthread
usr/local/lib/libruby.so: warning: warning: strcpy() is almost always misused, please use strlcpy()
usr/local/lib/libruby.so: warning: warning: strcat() is almost always misused, please use strlcat()
</code></pre> Ruby master - Bug #13069: mkmf: ignore linker warnings on OpenBSDhttps://redmine.ruby-lang.org/issues/13069?journal_id=623252016-12-29T21:03:24Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Open</i></li></ul><p>Some of the warnings were addressed in r57189, r57190, and r57191. However, I think we should rethink checking for an empty log file, and rely purely on the return code:</p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gd">--- lib/mkmf.rb.orig Sun Dec 25 09:49:06 2016
</span><span class="gi">+++ lib/mkmf.rb Sun Dec 25 09:49:51 2016
</span><span class="p">@@ -388,7 +388,7 @@</span> module MakeMakefile
result = nil
Logging.postpone do |log|
output = IO.popen(libpath_env, command, &:read)
<span class="gd">- result = ($?.success? and File.zero?(log.path))
</span><span class="gi">+ result = $?.success?
</span> output
end
result
</code></pre>
<p>The only reason I can think of to not rely purely on the return code is if we want to support environments where the command would return 0 in the case where it failed. Are there such environments?</p>
<p>The approach of the current code is similar to defaulting to <code>-Werror</code> when compiling C, which is almost always a bad idea when distributing C code unless you know every possible environment you want to support (which ruby does not).</p> Ruby master - Bug #13069: mkmf: ignore linker warnings on OpenBSDhttps://redmine.ruby-lang.org/issues/13069?journal_id=623262016-12-29T21:58:54Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul></ul><p>I think this is a better fix. This keeps the <code>:werror</code> behavior in <code>Logging::postpone</code>, it just turns off the use of <code>:werror</code> by default. Users that want werror behavior by default can set <code>$werror = true</code>.</p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gd">--- lib/mkmf.rb.orig
</span><span class="gi">+++ lib/mkmf.rb
</span><span class="p">@@ -88,6 +88,7 @@</span> module MakeMakefile
$static = nil
$config_h = '$(arch_hdrdir)/ruby/config.h'
$default_static = $static
<span class="gi">+ $werror = false unless defined?($werror)
</span><span class="err">
</span> unless defined? $configure_args
$configure_args = {}
<span class="p">@@ -611,7 +612,7 @@</span> def with_cppflags(flags)
end
<span class="err">
</span> def try_cppflags(flags, opts = {})
<span class="gd">- try_header(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts))
</span><span class="gi">+ try_header(MAIN_DOES_NOTHING, flags, {:werror => $werror}.update(opts))
</span> end
<span class="err">
</span> def append_cppflags(flags, *opts)
<span class="p">@@ -633,7 +634,7 @@</span> def with_cflags(flags)
end
<span class="err">
</span> def try_cflags(flags, opts = {})
<span class="gd">- try_compile(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts))
</span><span class="gi">+ try_compile(MAIN_DOES_NOTHING, flags, {:werror => $werror}.update(opts))
</span> end
<span class="err">
</span> def append_cflags(flags, *opts)
<span class="p">@@ -655,7 +656,7 @@</span> def with_ldflags(flags)
end
<span class="err">
</span> def try_ldflags(flags, opts = {})
<span class="gd">- try_link(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts))
</span><span class="gi">+ try_link(MAIN_DOES_NOTHING, flags, {:werror => $werror}.update(opts))
</span> end
<span class="err">
</span> def append_ldflags(flags, *opts)
<span class="p">@@ -1408,7 +1409,7 @@</span> def convertible_int(type, headers = nil, opts = nil, &b)
u = "unsigned " if signed > 0
prelude << "extern rbcv_typedef_ foo();"
compat = UNIVERSAL_INTS.find {|t|
<span class="gd">- try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, :werror=>true, &b)
</span><span class="gi">+ try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, :werror=>$werror, &b)
</span> }
end
if compat
<span class="err">
</span></code></pre>
<p>This basically reverts the changes made in r50215 and r50216, except that it allows enabling werror globally via <code>$werror</code>. The commit messages for both commits do not describe why the code was changed to default to <code>{:werror=>true}</code>. 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 <code>:werror=>true</code> in the final diff block. r35101 states that the exit code may be lost on mingw, so we may want to default <code>$werror</code> to true on mingw if that is still the case.</p>
<p>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.</p> Ruby master - Bug #13069: mkmf: ignore linker warnings on OpenBSDhttps://redmine.ruby-lang.org/issues/13069?journal_id=623272016-12-30T07:53:32ZAnonymous
<ul></ul><p>Thansk for addressing the warnings. Your proposed patch solves my problem.</p> Ruby master - Bug #13069: mkmf: ignore linker warnings on OpenBSDhttps://redmine.ruby-lang.org/issues/13069?journal_id=696742018-01-22T10:24:34Zakihikodaki (Akihiko Odaki)akihiko.odaki.4i@stu.hosei.ac.jp
<ul><li><strong>File</strong> <a href="/attachments/6978">mkmf.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/6978/mkmf.patch">mkmf.patch</a> added</li><li><strong>ruby -v</strong> set to <i>ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]</i></li></ul><p>The issue is affecting my gem, <a href="https://github.com/akihikodaki/cld3-ruby" class="external">cld3-ruby</a>.<br>
<a href="https://github.com/akihikodaki/cld3-ruby/issues/16" class="external">Build failure on OpenBSD · Issue #16 · akihikodaki/cld3-ruby</a></p>
<blockquote>
<p>Those warnings are always emitted regardless use of the functions?</p>
</blockquote>
<p>I reviewed the source code of Binutils and GCC and found no means to suppress the warning.</p>
<p>I understand many link warnings result in runtime failure, but it is just insane to make all warnings errors. Warnings are not errors because they may not result in actual failure.</p>
<p>The impact of this issue is severe. It would disable many native extensions on OpenBSD. On the other hand, though those warnings sound ridiculous, OpenBSD should not be blamed because they are just adding warnings, not errors. mkmf should be fixed.</p>
<p>I have two suggestions to address this kind of issue:</p>
<ol>
<li>Redirect linker's stderr to mkmf's stderr, and optionally ask the user if he thinks it is fine to continue.</li>
<li>Execute the output instead of catching stderr to detect runtime failures if not cross compiling.</li>
</ol>
<p>I attached a patch to implement suggestion 2.</p> Ruby master - Bug #13069: mkmf: ignore linker warnings on OpenBSDhttps://redmine.ruby-lang.org/issues/13069?journal_id=696752018-01-22T12:34:56Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset trunk|r62007.</p>
<hr>
<p>mkmf.rb: ignore linker warnings</p>
<ul>
<li>lib/mkmf.rb (try_ldflags): ignore linker warnings. they cause<br>
unexpected failures on OpenBSD. <a href="/issues/13069">[ruby-core:78827]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: mkmf: ignore linker warnings on OpenBSD (Closed)" href="https://redmine.ruby-lang.org/issues/13069">#13069</a>]</li>
</ul> Ruby master - Bug #13069: mkmf: ignore linker warnings on OpenBSDhttps://redmine.ruby-lang.org/issues/13069?journal_id=696762018-01-22T12:37:26Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Could you let us know where those functions are used?<br>
It's better to get rid of them, I think.</p> Ruby master - Bug #13069: mkmf: ignore linker warnings on OpenBSDhttps://redmine.ruby-lang.org/issues/13069?journal_id=736262018-08-20T12:30:59Zhsbt (Hiroshi SHIBATA)hsbt@ruby-lang.org
<ul><li><strong>Backport</strong> changed from <i>2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN</i> to <i>2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: REQUIRED</i></li></ul> Ruby master - Bug #13069: mkmf: ignore linker warnings on OpenBSDhttps://redmine.ruby-lang.org/issues/13069?journal_id=743632018-10-09T14:09:40Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Backport</strong> changed from <i>2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: REQUIRED</i> to <i>2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: DONE</i></li></ul><p>ruby_2_5 r64979 merged revision(s) 62007,62024.</p> Ruby master - Bug #13069: mkmf: ignore linker warnings on OpenBSDhttps://redmine.ruby-lang.org/issues/13069?journal_id=744802018-10-17T09:22:28Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul><li><strong>Backport</strong> changed from <i>2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: DONE</i> to <i>2.3: UNKNOWN, 2.4: DONE, 2.5: DONE</i></li></ul><p>ruby_2_4 r65117 merged revision(s) 62007,62024.</p>