Bug #3834

ext/openssl fails to build in certain scenarios due to misordered pkg-config check

Added by Erik Hollensbe over 3 years ago. Updated almost 3 years ago.

[ruby-core:32406]
Status:Closed
Priority:Normal
Assignee:Aaron Patterson
Category:build
Target version:1.9.3
ruby -v:HEAD Backport:

Description

=begin
If mkmf via ext/openssl/extconf.rb is allowed to search for both headers and libs before consulting pkg-config, multiple installations of openssl will cause trouble during build time.

This is evident on my OS X 10.6 system with macports, gcc 4.2.1 from macports, openssl 1.0.0a from macports, and openssl 0.9.x provided by OS X. The problem appears at a glance is that it will locate the 1.0 headers first, the 0.9 libs first, and then prepare the conftest programs with improper ldflags based on its findings.

It's entirely probable there's a deeper autoconf, rbconfig, mkmf, or compiler issue that I am missing, but the solution I found is in the attached patch, which is to run pkg_config first, and in the event it fails, fall back to the default header / lib search that was previously in place. I think this will work for situations where pkg-config isn't available for openssl, but I was unable to test that case.
=end

ssl_compile_fix.patch.gz (426 Bytes) Erik Hollensbe, 09/16/2010 05:22 AM

History

#1 Updated by Aaron Patterson over 3 years ago

  • Assignee set to Aaron Patterson

=begin
This patch seems good to me, but I'm not sure how pkg_config will behave on windows builds.

Luis, can you comment on this?
=end

#2 Updated by Luis Lavena over 3 years ago

=begin
Hello,

RubyInstaller do not bundle pkg-config, so that part will fail and will check for crypto libeay32 and ssl ssleay32 as usual.

I just checked and compiles fine, following are the snip of mkmf.log that matters:


package configuration for openssl is not found
have_header: checking for openssl/ssl.h... -------------------- yes

"gcc -E -I../../.ext/include/i386-mingw32 -I../../../../../../ruby/include -I../../../../../../ruby/ext/openssl -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long conftest.c -o conftest.i"
checked program was:
/* begin /
1: #include "ruby.h"
2:
3: #include
4: #include
5: #include
/
end */


=end

#3 Updated by Luis Lavena over 3 years ago

=begin
Sorry, forgot to mention.

It needs to be:

result = pkgconfig("openssl") && haveheader("openssl/ssl.h")

As we don't want consider all the libraries found just because it found oepnssl/ssl.h header file. Correct?
=end

#4 Updated by Aaron Patterson over 3 years ago

=begin
Yes, I think you're correct. I'll apply the patch and update with that change. Thanks for testing this Luis!
=end

#5 Updated by Anonymous over 3 years ago

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

=begin
This issue was solved with changeset r30167.
Erik, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Also available in: Atom PDF