Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pg 0.10.0 fails to compile on OpenSolaris #56

Closed
ged opened this issue Dec 4, 2010 · 11 comments
Closed

pg 0.10.0 fails to compile on OpenSolaris #56

ged opened this issue Dec 4, 2010 · 11 comments

Comments

@ged
Copy link
Owner

ged commented Dec 4, 2010

Original report by Don Morrison (Bitbucket: elskwid, GitHub: elskwid).


Hello pg team,

Recently ran into a problem compiling 0.10.0 on our OpenSolaris server. Server version: OpenSolaris 2008.11 snv_101b_rc2 X86


The error when bundler attempts the install:

Installing pg (0.10.0) with native extensions /usr/local/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/usr/local/rubies/ruby-1.8.7-p302/bin/ruby extconf.rb 
checking for pg_config... yes
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/local/rubies/ruby-1.8.7-p302/bin/ruby
        --with-pg
        --without-pg
        --with-pg-config
        --without-pg-config
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/lib
        --with-pqlib
        --without-pqlib
        --with-libpqlib
        --without-libpqlib
        --with-ms/libpqlib
        --without-ms/libpqlib

The contents of mkmf.log

psex@worms:~/psexchange/current$ cat ../shared/bundle/ruby/1.8/gems/pg-0.10.0/ext/mkmf.log 
find_executable: checking for pg_config... -------------------- yes

--------------------

find_header: checking for libpq-fe.h... -------------------- yes

"gcc -E -I. -I/usr/local/rubies/ruby-1.8.7-p302/lib/ruby/1.8/i386-solaris2.11 -I.  -D_FILE_OFFSET_BITS=64  -I/usr/postgres/8.3/include -g -O2   -xO3 -xarch=386 -xchip=pentium -xspace -Xa  -xildoff -xc99=all  -xc99=none -xCC  conftest.c -o conftest.i"
gcc: unrecognized option `-Xa'
gcc: language CC not recognized
gcc: conftest.c: linker input file unused because linking not done
checked program was:
/* begin */
1: #include <libpq-fe.h>
/* end */

--------------------

find_header: checking for libpq/libpq-fs.h... -------------------- yes

"gcc -E -I. -I/usr/local/rubies/ruby-1.8.7-p302/lib/ruby/1.8/i386-solaris2.11 -I.  -D_FILE_OFFSET_BITS=64  -I/usr/postgres/8.3/include -g -O2   -xO3 -xarch=386 -xchip=pentium -xspace -Xa  -xildoff -xc99=all  -xc99=none -xCC  conftest.c -o conftest.i"
gcc: unrecognized option `-Xa'
gcc: language CC not recognized
gcc: conftest.c: linker input file unused because linking not done
checked program was:
/* begin */
1: #include <libpq/libpq-fs.h>
/* end */

--------------------

have_library: checking for PQconnectdb() in -lpq... -------------------- no

"gcc -o conftest -I. -I/usr/local/rubies/ruby-1.8.7-p302/lib/ruby/1.8/i386-solaris2.11 -I.  -D_FILE_OFFSET_BITS=64  -I/usr/postgres/8.3/include -g -O2   -xO3 -xarch=386 -xchip=pentium -xspace -Xa  -xildoff -xc99=all  -xc99=none -xCC conftest.c  -L. -L/usr/local/rubies/ruby-1.8.7-p302/lib -Wl,-R/usr/local/rubies/ruby-1.8.7-p302/lib -L.  -L/usr/postgres/8.3/lib     -lruby-static -lpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
gcc: unrecognized option `-Xa'
gcc: language CC not recognized
ld: fatal: file conftest.c: unknown file type
ld: fatal: File processing errors. No output written to conftest
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: #include <libpq-fe.h>
2: 
3: /*top*/
4: int main() { return 0; }
5: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return 0; }
/* end */

"gcc -o conftest -I. -I/usr/local/rubies/ruby-1.8.7-p302/lib/ruby/1.8/i386-solaris2.11 -I.  -D_FILE_OFFSET_BITS=64  -I/usr/postgres/8.3/include -g -O2   -xO3 -xarch=386 -xchip=pentium -xspace -Xa  -xildoff -xc99=all  -xc99=none -xCC conftest.c  -L. -L/usr/local/rubies/ruby-1.8.7-p302/lib -Wl,-R/usr/local/rubies/ruby-1.8.7-p302/lib -L.  -L/usr/postgres/8.3/lib     -lruby-static -lpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
gcc: unrecognized option `-Xa'
gcc: language CC not recognized
ld: fatal: file conftest.c: unknown file type
ld: fatal: File processing errors. No output written to conftest
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: #include <libpq-fe.h>
2: 
3: /*top*/
4: int main() { return 0; }
5: int t() { PQconnectdb(); return 0; }
/* end */

--------------------

have_library: checking for PQconnectdb() in -llibpq... -------------------- no

"gcc -o conftest -I. -I/usr/local/rubies/ruby-1.8.7-p302/lib/ruby/1.8/i386-solaris2.11 -I.  -D_FILE_OFFSET_BITS=64  -I/usr/postgres/8.3/include -g -O2   -xO3 -xarch=386 -xchip=pentium -xspace -Xa  -xildoff -xc99=all  -xc99=none -xCC conftest.c  -L. -L/usr/local/rubies/ruby-1.8.7-p302/lib -Wl,-R/usr/local/rubies/ruby-1.8.7-p302/lib -L.  -L/usr/postgres/8.3/lib     -lruby-static -llibpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
gcc: unrecognized option `-Xa'
gcc: language CC not recognized
ld: fatal: file conftest.c: unknown file type
ld: fatal: File processing errors. No output written to conftest
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: #include <libpq-fe.h>
2: 
3: /*top*/
4: int main() { return 0; }
5: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return 0; }
/* end */

"gcc -o conftest -I. -I/usr/local/rubies/ruby-1.8.7-p302/lib/ruby/1.8/i386-solaris2.11 -I.  -D_FILE_OFFSET_BITS=64  -I/usr/postgres/8.3/include -g -O2   -xO3 -xarch=386 -xchip=pentium -xspace -Xa  -xildoff -xc99=all  -xc99=none -xCC conftest.c  -L. -L/usr/local/rubies/ruby-1.8.7-p302/lib -Wl,-R/usr/local/rubies/ruby-1.8.7-p302/lib -L.  -L/usr/postgres/8.3/lib     -lruby-static -llibpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
gcc: unrecognized option `-Xa'
gcc: language CC not recognized
ld: fatal: file conftest.c: unknown file type
ld: fatal: File processing errors. No output written to conftest
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: #include <libpq-fe.h>
2: 
3: /*top*/
4: int main() { return 0; }
5: int t() { PQconnectdb(); return 0; }
/* end */

--------------------

have_library: checking for PQconnectdb() in -lms/libpq... -------------------- no

"gcc -o conftest -I. -I/usr/local/rubies/ruby-1.8.7-p302/lib/ruby/1.8/i386-solaris2.11 -I.  -D_FILE_OFFSET_BITS=64  -I/usr/postgres/8.3/include -g -O2   -xO3 -xarch=386 -xchip=pentium -xspace -Xa  -xildoff -xc99=all  -xc99=none -xCC conftest.c  -L. -L/usr/local/rubies/ruby-1.8.7-p302/lib -Wl,-R/usr/local/rubies/ruby-1.8.7-p302/lib -L.  -L/usr/postgres/8.3/lib     -lruby-static -lms/libpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
gcc: unrecognized option `-Xa'
gcc: language CC not recognized
ld: fatal: file conftest.c: unknown file type
ld: fatal: File processing errors. No output written to conftest
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: #include <libpq-fe.h>
2: 
3: /*top*/
4: int main() { return 0; }
5: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return 0; }
/* end */

"gcc -o conftest -I. -I/usr/local/rubies/ruby-1.8.7-p302/lib/ruby/1.8/i386-solaris2.11 -I.  -D_FILE_OFFSET_BITS=64  -I/usr/postgres/8.3/include -g -O2   -xO3 -xarch=386 -xchip=pentium -xspace -Xa  -xildoff -xc99=all  -xc99=none -xCC conftest.c  -L. -L/usr/local/rubies/ruby-1.8.7-p302/lib -Wl,-R/usr/local/rubies/ruby-1.8.7-p302/lib -L.  -L/usr/postgres/8.3/lib     -lruby-static -lms/libpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
gcc: unrecognized option `-Xa'
gcc: language CC not recognized
ld: fatal: file conftest.c: unknown file type
ld: fatal: File processing errors. No output written to conftest
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: #include <libpq-fe.h>
2: 
3: /*top*/
4: int main() { return 0; }
5: int t() { PQconnectdb(); return 0; }
/* end */

--------------------

I did do some investigation/verification before filing the ticket:

  • verified my path configuration was correct, pg_config is available

  • the files that are reported as missing are actually on the server

  • since I deploy from cap, I made sure that the same failure is experienced when logged in to the server

  • checked rbconfig.rb for common erroneous compiler settings - they all looked good to me - and I had just recently compiled a new version of ruby 1.8.7 so I know the toolchain was working a short time ago. (I have attached a copy to this issue)

This same server is able to compile pg 0.9.0 no problem.

Please let me know if there is anything else I can do or information I can provide to help solve this problem.

Thank you!

@ged
Copy link
Owner Author

ged commented Dec 6, 2010

Original comment by Michael Granger (Bitbucket: ged, GitHub: ged).


Something about the way the extconf.rb combines the compilation flags from Ruby and Postgres isn't working, it would appear. It's causing trouble on other platforms as well, so I'm thinking I'll remove it and release 0.10.1 with a simpler extconf.

@ged
Copy link
Owner Author

ged commented Dec 16, 2010

Original comment by Don Morrison (Bitbucket: elskwid, GitHub: elskwid).


Hi Michael,

Thanks for the update. Ping me when you'd like me to give this a shot.

Don

@ged
Copy link
Owner Author

ged commented Dec 22, 2010

Original comment by Michael Granger (Bitbucket: ged, GitHub: ged).


I've been trying without success to get PostgreSQL 8.4 installed on OpenSolaris so I can test this myself (I'm fairly clueless about Solaris administration), but I'll give up for now and just ask that you try out the prerelease of 0.10.1 I just pushed to rubygems.org:

gem install pg --pre -v 0.10.1pre209

Once we get this resolved, would you mind lending me your advice on adding an OpenSolaris environment to my bevvy of VirtualBox testing machines? I try to install and run the specs on as many environments as possible, and this is one I don't yet have.

Thanks for your help!

@ged
Copy link
Owner Author

ged commented Dec 28, 2010

Original comment by Michael Granger (Bitbucket: ged, GitHub: ged).


A bit more detail...

The relevant portion of the mkmf.log is this:

have_library: checking for PQconnectdb() in -lpq... -------------------- no

"gcc -o conftest -I. -I/usr/local/rubies/ruby-1.8.7-p302/lib/ruby/1.8/i386-solaris2.11 \
  -I.  -D_FILE_OFFSET_BITS=64  -I/usr/postgres/8.3/include -g -O2   -xO3 -xarch=386 \
  -xchip=pentium -xspace -Xa  -xildoff -xc99=all  -xc99=none -xCC conftest.c  -L. \
  -L/usr/local/rubies/ruby-1.8.7-p302/lib -Wl,-R/usr/local/rubies/ruby-1.8.7-p302/lib -L. \
  -L/usr/postgres/8.3/lib     -lruby-static -lpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
>>> gcc: unrecognized option `-Xa'
gcc: language CC not recognized
ld: fatal: file conftest.c: unknown file type
ld: fatal: File processing errors. No output written to conftest
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: #include <libpq-fe.h>
2: 
3: /*top*/
4: int main() { return 0; }
5: int t() { void ((*volatile p)()); p = (void ((*)()))PQconnectdb; return 0; }
/* end */

"gcc -o conftest -I. -I/usr/local/rubies/ruby-1.8.7-p302/lib/ruby/1.8/i386-solaris2.11 -I. \
  -D_FILE_OFFSET_BITS=64  -I/usr/postgres/8.3/include -g -O2   -xO3 -xarch=386 -xchip=pentium \
  -xspace -Xa  -xildoff -xc99=all  -xc99=none -xCC conftest.c  -L. \
  -L/usr/local/rubies/ruby-1.8.7-p302/lib -Wl,-R/usr/local/rubies/ruby-1.8.7-p302/lib -L. \
  -L/usr/postgres/8.3/lib     -lruby-static -lpq  -lpthread -lrt -ldl -lcrypt -lm   -lc"
>>> gcc: unrecognized option `-Xa'
gcc: language CC not recognized
ld: fatal: file conftest.c: unknown file type
ld: fatal: File processing errors. No output written to conftest
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: #include <libpq-fe.h>
2: 
3: /*top*/
4: int main() { return 0; }
5: int t() { PQconnectdb(); return 0; }
/* end */

The two lines with the '>>>' are the clues.

The two strategies for compiling the test program are both apparently giving the compiler flags it doesn't understand. With version 0.10.0, I introduced a change to the extconf that added the compiler flags specified by pg_config to those used to compile 'pg', but that caused more problems than it solved, so I backed that change out for 0.10.1.

I'm guessing that the problem under OpenSolaris is that PostgreSQL is built using a different compiler than Ruby is, resulting in the unrecognized options.

@ged
Copy link
Owner Author

ged commented Jan 3, 2011

Original comment by Don Morrison (Bitbucket: elskwid, GitHub: elskwid).


Hey Michael,

Thanks so much for looking at this. I will try out the gem in the next couple of days. As for helping with OpenSolaris install, I'm actually quite new to it. I'll need to have a coworker help me, then I can help you. :-)

I will give you an update as soon as I can.

Thanks again!

@ged
Copy link
Owner Author

ged commented Jan 3, 2011

Original comment by Michael Granger (Bitbucket: ged, GitHub: ged).


No problem. I've been talking to a former co-worker of mine who's a Solaris admin, and he's been trying out the newer gems for me. We haven't been able to duplicate your results, but I at least verified that the newest gem installs okay in his environment.

@ged
Copy link
Owner Author

ged commented Jan 19, 2011

Original comment by Michael Granger (Bitbucket: ged, GitHub: ged).


I wanted to push out 0.10.1 to fix a few other problems, but hopefully this will resolve any issues under Solaris as well.

@ged
Copy link
Owner Author

ged commented Jan 24, 2011

Original comment by Don Morrison (Bitbucket: elskwid, GitHub: elskwid).


Michael,

Been a crazy couple of weeks. I can confirm that 0.10.1 is able to install and function on our OpenSolaris install.

Thank you so much for all your help on this!

Don

@ged ged closed this as completed Jan 24, 2011
@ged
Copy link
Owner Author

ged commented Jan 24, 2011

Original comment by Michael Granger (Bitbucket: ged, GitHub: ged).


Yay! Glad it helped. :)

@ged
Copy link
Owner Author

ged commented Jan 31, 2011

Original comment by Anonymous.


Hi,

This didn't work on Mac OS X 10.6.6 with latest XCode. I get the same failure as described above.

Thanks
Babu

@ged
Copy link
Owner Author

ged commented Jan 31, 2011

Original comment by Michael Granger (Bitbucket: ged, GitHub: ged).


Are you sure it's not more like #57?

99% of the time, when someone reports a problem installing the library under OSX, it's because they're installing 'pg' with a universal Ruby binary compiled against a non-universal PostgreSQL. See the instructions in [[https://bitbucket.org/ged/ruby-pg/src/8ab3dd3c757b/README.OS_X|README.OS_X]] for how to resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant