Bug 983769

Summary: compile error including ruby.h in c99 mode: unknown type name ‘fd_set’
Product: [Fedora] Fedora Reporter: Tim Cuthbertson <tim>
Component: rubyAssignee: Jeroen van Meeuwen <vanmeeuwen+fedora>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: bkabrda, jeremy, mmorsi, mtasaka, tagoh, vanmeeuwen+fedora, vondruch
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ruby-2.0.0.247-14.fc19 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-16 01:36:36 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tim Cuthbertson 2013-07-11 23:28:18 UTC
Description of problem:

I get errors trying to build the command-t vim plugin (which includes a compiled ruby extension). The errors come from including <ruby.h>, the plugin's code doesn't seem to be the cause.

Version-Release number of selected component (if applicable): ruby-devel-2.0.0.195-8.fc19.x86_64

How reproducible: Always


Steps to Reproduce:
1. Create:

-- ext.c:

    #include <stdlib.h>
    #include <ruby.h>

-- extconf.rb:

    require 'mkmf'
    have_header('ruby.h')
    create_makefile('ext')

-- depend

    CFLAGS += -std=c99


2. Run:

$ ruby extconf.rb
checking for ruby.h... yes
creating Makefile

$ make

Actual results:

gcc -I. -I/usr/include/x86_64-linux -I/usr/include/ruby/backward -I/usr/include -I. -DHAVE_RUBY_H    -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -grecord-gcc-switches -mtune=generic -fPIC -m64 -std=c99 -o ext.o -c ext.c
In file included from /usr/include/ruby/ruby.h:1567:0,
                 from /usr/include/ruby.h:33,
                 from ext.c:2:
/usr/include/ruby/intern.h:323:1: error: unknown type name ‘fd_set’
 typedef fd_set rb_fdset_t;
 ^
In file included from /usr/include/ruby/ruby.h:24:0,
                 from /usr/include/ruby.h:33,
                 from ext.c:2:
/usr/include/ruby/intern.h:412:1: error: unknown type name ‘fd_set’
 DEPRECATED(int rb_thread_select(int, fd_set *, fd_set *, fd_set *, struct timeval *));
 ^
/usr/include/ruby/intern.h:412:1: error: unknown type name ‘fd_set’
 DEPRECATED(int rb_thread_select(int, fd_set *, fd_set *, fd_set *, struct timeval *));
 ^
/usr/include/ruby/intern.h:412:1: error: unknown type name ‘fd_set’
 DEPRECATED(int rb_thread_select(int, fd_set *, fd_set *, fd_set *, struct timeval *));
 ^
make: *** [ext.o] Error 1



Additional info:

I can't figure out what exactly causing it. Either of the following workarounds make the problem go away:

 - require <ruby.h> before <stdlib.h> (in ext.c)
 - remove the -std=c99 flag from `depend`

Comment 1 Mamoru TASAKA 2013-07-12 09:09:28 UTC
--- ruby-devel-2.0.0.195-8.fc19.i686/usr/include/ruby/intern.h  2013-03-20 22:36:23.000000000 +0900
+++ ruby-devel-2.0.0.247-12.fc19.i686/usr/include/ruby/intern.h 2013-06-19 04:18:15.000000000 +0900
@@ -36,6 +36,10 @@
 #include <sys/types.h>
 #endif
 
+#if defined(HAVE_SYS_TIME_H)
+#include <sys/time.h>
+#endif
+
 #include "ruby/st.h"
 
 #if defined __GNUC__ && __GNUC__ >= 4

and with glibc-2.17, time.h includes bits/time.h, which includes sys/select.h, which defines fd_set.
According to 
http://pubs.opengroup.org/onlinepubs/007904975/basedefs/sys/select.h.html ,
perhaps directly including sys/select.h seems preferable than time.h, however anyway with ruby 2.0.0p249 this is not reproducible.

Comment 2 Mamoru TASAKA 2013-07-12 09:11:08 UTC
(In reply to Mamoru TASAKA from comment #1)
> and with glibc-2.17, time.h includes bits/time.h

Before this, sys/time.h includes time.h.

Comment 3 Vít Ondruch 2013-07-12 09:57:11 UTC
There is related command-t bug report:

https://wincent.com/issues/2098

And this seems to the fix in Ruby:

https://github.com/ruby/ruby/commit/99035ca2621f7128d0e3a7f3a8acd8c3e2323e09#include/ruby/intern.h

Comment 4 Fedora Update System 2013-07-12 10:03:32 UTC
ruby-2.0.0.247-12.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/FEDORA-2013-12663/ruby-2.0.0.247-12.fc19

Comment 5 Fedora Update System 2013-07-14 03:28:01 UTC
Package ruby-2.0.0.247-13.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing ruby-2.0.0.247-13.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-12663/ruby-2.0.0.247-13.fc19
then log in and leave karma (feedback).

Comment 6 Tim Cuthbertson 2013-07-14 22:44:08 UTC
Thanks, this update fixes the issue.

Comment 7 Fedora Update System 2013-07-16 01:36:36 UTC
ruby-2.0.0.247-14.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.