May 6, 2010

Ruby 1.8.7 and openssl 1.0.0

Archlinux upgrade openssl from 0.9.8 to 1.0.0 recently, which caused a big headache for me: all ruby distributions, except the latest ruby source code in svn, failed to compile with the new openssl, e.g. (compile error of 1.8.7):

ossl_ssl.c: In function ?ossl_sslctx_get_ciphers?:
ossl_ssl.c:626:19: error: ?STACK? undeclared (first use in this function)
ossl_ssl.c:626:19: note: each undeclared identifier is reported only once for each function it appears in
ossl_ssl.c:626:25: error: expected expression before ?)? token
ossl_ssl.c:629:47: error: expected expression before ?)? token
ossl_ssl.c:629:47: error: too few arguments to function ?sk_value?
/usr/include/openssl/stack.h:80:7: note: declared here
ossl_ssl.c: In function ?ossl_ssl_get_peer_cert_chain?:
ossl_ssl.c:1199:5: warning: passing argument 1 of ?sk_num? from incompatible pointer type
/usr/include/openssl/stack.h:79:5: note: expected ?const struct _STACK *? but argument is of type ?struct stack_st_X509 *?
ossl_ssl.c:1202:2: warning: passing argument 1 of ?sk_value? from incompatible pointer type
/usr/include/openssl/stack.h:80:7: note: expected ?const struct _STACK *? but argument is of type ?struct stack_st_X509 *?
ossl_ssl.c: In function ?ossl_ssl_get_cipher?:
ossl_ssl.c:1224:12: warning: assignment discards qualifiers from pointer target type
make[1]: *** [ossl_ssl.o] Error 1
make: *** [all] Error 1

Here's a patch for 1.8.7, it's a modified version of this. Copy and save it as openssl.patch in 1.8.7 source directory, run 'patch -p0 < openssl.patch' and recompile, there should be no errors anymore.

7 comments:

  1. http://wiki.archlinux.org/index.php/RVM#Troubleshooting

    ReplyDelete
  2. Thanks, amigo. Saved me lots of time tonight.

    ReplyDelete
  3. It worked. Great. Thanks a lot for sharing!

    ReplyDelete
  4. #thanksmate, http://twitter.com/janhxie
    The patch works !! & if anybody confused like "Cheese, I have rvm, how do I patch... "make" and "(sudo) make install".. so my rvm understands the end result"... Nevermind... I know the work arounds:

    Solutions:
    + rvm install ruby-1.8.7-p249 --patch path/to/downloaded.patch
    But....if still no luck...
    + do inject patch on fly of installation...

    Demo: like this: while intalling ruby like this...
    → rvm install ruby-1.8.7-p249
    it starts downloading source... start to configure... Meanwhile fire up new terminal and inject the patch then like:(considering systemwide installation)
    → cd /usr/local/rvm/src/ruby-1.8.7-p249;patch -p0 < 'path/to/openssl.patch'

    Mine worked :D, hope your do to.. Good luck :P

    ReplyDelete