Bug #5675

[mingw] static build fails due to socket extension build failure

Added by Jon Forums over 2 years ago. Updated over 2 years ago.

[ruby-core:41314]
Status:Closed
Priority:Normal
Assignee:-
Category:ext
Target version:1.9.3
ruby -v:- Backport:

Description

I get the following failure on my Win7 32bit system while trying to build ruby19_3@33661 The problem likely exists on trunk@33852 but #5674 blocks me from trying to replicate.

Providing --with-out-ext=socket to ./configure is a one (undesirable) workaround. No failure when building on Arch.

C:\Users\Jon\Documents\RubyDev\ruby-git\build>sh -c "../configure --disable-shared --disable-install-doc && make"
...
make[2]: Entering directory /c/Users/Jon/Documents/RubyDev/ruby-git/build/ext/socket'
generating socket-i386-mingw32.def
generating constant definitions
compiling ../../../ext/socket/init.c
compiling ../../../ext/socket/constants.c
compiling ../../../ext/socket/basicsocket.c
compiling ../../../ext/socket/socket.c
../../../ext/socket/socket.c: In function 'rsock_sock_s_socketpair':
../../../ext/socket/socket.c:114:5: warning: implicit declaration of function 'socketpair'
compiling ../../../ext/socket/ipsocket.c
compiling ../../../ext/socket/tcpsocket.c
compiling ../../../ext/socket/tcpserver.c
compiling ../../../ext/socket/sockssocket.c
compiling ../../../ext/socket/udpsocket.c
compiling ../../../ext/socket/unixsocket.c
compiling ../../../ext/socket/unixserver.c
compiling ../../../ext/socket/option.c
compiling ../../../ext/socket/ancdata.c
compiling ../../../ext/socket/raddrinfo.c
linking shared-object socket.so
socket.o: In function
rsocksocks_socketpair':
c:\Users\Jon\Documents\RubyDev\ruby-git\build\ext\socket/../../../ext/socket/socket.c:114: undefined reference to socketpair'
c:\Users\Jon\Documents\RubyDev\ruby-git\build\ext\socket/../../../ext/socket/socket.c:117: undefined reference to
socketpair'
collect2: ld returned 1 exit status
make[2]: *** [../../.ext/i386-mingw32/socket.so] Error 1
make[2]: Leaving directory /c/Users/Jon/Documents/RubyDev/ruby-git/build/ext/socket'
make[1]: *** [ext/socket/all] Error 2
make[1]: Leaving directory
/c/Users/Jon/Documents/RubyDev/ruby-git/build'
make: *** [build-ext] Error 2

Associated revisions

Revision 33876
Added by Nobuyoshi Nakada over 2 years ago

  • include/ruby/subst.h: moved Windows specific substitions from win32.h.
  • ext/socket/rubysocket.h: include ruby/subst.h. [Bug #5675]

Revision 33879
Added by Nobuyoshi Nakada over 2 years ago

  • win32/mkexports.rb (Exports#read_substitution): need to read from subst.h too. [Bug #5675]

Revision 33947
Added by Usaku NAKAMURA over 2 years ago

  • include/ruby/{subst.h,win32.h}, ext/socket/rubysocket.h: revert
    r33876. [Bug #5706]

  • ext/socket/extconf.rb: the alternative hack for [Bug #5675].

History

#1 Updated by Motohiro KOSAKI over 2 years ago

  • ruby -v changed from ruby 1.9.3p0 (2011-11-08 revision 33661) [i386-mingw32] to -

compiling ../../../ext/socket/socket.c
../../../ext/socket/socket.c: In function 'rsocksocks_socketpair':
../../../ext/socket/socket.c:114:5: warning: implicit declaration of function 'socketpair'

This warning shouldn't be happen. But I'm wondering it because many
people did success mingw32 build. Hmm..

Luis, do you have any opinion? (note: this is head of ruby19_3 branch).

#2 Updated by Heesob Park over 2 years ago

Configuring with --disable-shared option caused failure on mingw32 build.

As a workaround, inserting following 4 lines at line #12 of socket.c solves the problem.

#ifdef WIN32
#undef socketpair
#define socketpair(a, t, p, s) rb
w32_socketpair(a, t, p, s)
#endif

#3 Updated by Luis Lavena over 2 years ago

On Sun, Nov 27, 2011 at 4:11 AM, KOSAKI Motohiro
kosaki.motohiro@gmail.com wrote:

This warning shouldn't be happen. But I'm wondering it because many
people did success mingw32 build. Hmm..

Build with --enable-shared does work, but doesn't work when build with
--disable-shared.

I think Heesob's patch does the trick, will test in a little bit.

--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

#4 Updated by Motohiro KOSAKI over 2 years ago

2011/11/27 Luis Lavena luislavena@gmail.com:

On Sun, Nov 27, 2011 at 4:11 AM, KOSAKI Motohiro
kosaki.motohiro@gmail.com wrote:

This warning shouldn't be happen. But I'm wondering it because many
people did success mingw32 build. Hmm..

Build with --enable-shared does work, but doesn't work when build with
--disable-shared.

I think Heesob's patch does the trick, will test in a little bit.

Why doesn't socket.c include "ruby/win32.h"? I apologize if I ask
dumb question.

#5 Updated by Luis Lavena over 2 years ago

On Sun, Nov 27, 2011 at 12:41 PM, KOSAKI Motohiro
kosaki.motohiro@gmail.com wrote:

Why doesn't socket.c include "ruby/win32.h"?  I apologize if I ask
dumb question.

Not a dumb question, a very valid one...

ruby.h includes ruby/ruby.h
ruby/ruby.h includes ruby/defines.h
ruby/defines.h does include ruby/win32.h

socket.c is including rubysocket.h which includes ruby/ruby.h, so it
should be resolving properly, right?

--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

#6 Updated by Motohiro KOSAKI over 2 years ago

Why doesn't socket.c include "ruby/win32.h"?  I apologize if I ask
dumb question.

Not a dumb question, a very valid one...

ruby.h includes ruby/ruby.h
ruby/ruby.h includes ruby/defines.h
ruby/defines.h does include ruby/win32.h

socket.c is including rubysocket.h which includes ruby/ruby.h, so it
should be resolving properly, right?

I thought so. But I can't think Jon told lie....

#7 Updated by Nobuyoshi Nakada over 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r33876.
Jon, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • include/ruby/subst.h: moved Windows specific substitions from win32.h.
  • ext/socket/rubysocket.h: include ruby/subst.h. [Bug #5675]

Also available in: Atom PDF