[erlang-patches] Crypto Compile Problem on x86_64 OTP-R11B

Daniel Schutte <>
Mon Nov 19 22:01:47 CET 2007


It may have been unclear, reading the mail again :) not enough sleep

The problem is that the library must be built against libcrypto.so on the 64 
bit environments - I have a 32 bit environment as well and this problem does 
not appear there.  I think the problem is in something in libcrypto.a - but 
must admit - my knowledge on tracing that problem further is limited ;) 
although I am willing to try / give more information if you can tell me what 
you are looking for.

In order to ensure that crypto worked on the 64bit machines.

The instruction that gets executed is:
gcc -shared  -o ../priv/lib/x86_64-unknown-linux-gnu/crypto_drv.so ../priv/obj/x86_64-unknown-linux-gnu/crypto_drv.o  /usr/lib64/libcrypto.a
but replacing the final "libcrypto.a" with "libcrypto.so" ensures a functional 
crypto_drv.so (example command): 
gcc -shared  -o ../priv/lib/x86_64-unknown-linux-gnu/crypto_drv.so ../priv/obj/x86_64-unknown-linux-gnu/crypto_drv.o /usr/lib64/libcrypto.so

I know that this change fixed it so that my 64 bit machines are working 
perfectly with crypto again.  So the fix would be to relink using 
libcrypto.so and not libcrypto.a - there is no issue with gcc 4.1 as far as I 
could tell - everything else compiled perfectly with 4.1

I also read the mails about the OpenBSD problems on this, but don't have 
OpenBSD to confirm if this solves that issue on that as well.  




On Monday 19 November 2007 10:14:48 Raimo Niskanen wrote:
> It might have been clear, but I did not get it. What is the patch?
> Is it to relink crypto_drv.so using gcc 4.0, or is it just to
> manually relink crypto_drv.so using gcc 4.1..
>
> If the problem is in gcc 4.1, do you know if it is a 4.1 bug and has
> it been reported to gcc - will it be fixed in gcc, or do you know
> what is the root cause?
>
> We have suspected the problem being the OpenSSL libraries not
> being linked to allow building other (our) shared libraries (.so)
> that themselves contain statically linked OpenSSL libraries (libcrypto.a),
> but if it is a gcc 4.1 problem we are interested to know for sure.
> I might confuse this problem with another problem where we can not
> build crypto_drv.so on OpenBSD against libcrypto.a...
>
> On Sun, Nov 18, 2007 at 06:57:39PM +0200, Daniel Schutte wrote:
> > I have seen a few postings on the web regarding this error - specifically
> > in the e-jabberd lists.  The solution is given as compiling with gcc 4.0
> > instead of 4.1.
> > Erlang Compiles fine, it's just the crypto module that is incomplete -
> > more specifically the driver.
> >
> >
> > ================ ENVIRONMENT =====
> > ================ OS =====
> > (CentOS 5.0)
> > Linux cupid.erlfinsys.net 2.6.18-8.1.15.el5 #1 SMP Mon Oct 22 08:32:28
> > EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
> >
> > ================ OpenSSL =====
> > openssl-0.9.8b-8.3.el5_0.2
> >
> > ================ GCC =====
> >
> > [ otp_src_R11B-5]$ gcc --version
> > gcc (GCC) 4.1.1 20070105 (Red Hat 4.1.1-52)
> > Copyright (C) 2006 Free Software Foundation, Inc.
> > This is free software; see the source for copying conditions.  There is
> > NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> > PURPOSE.
> >
> > ================ Erlang =====
> > Erlang OTP-R11B-5
> >
> > ================ ERROR =====
> > in the make file the following appears:
> >
> > /usr/bin/ld: /usr/lib64/libcrypto.a(x86_64cpuid.o): relocation
> > R_X86_64_PC32 against `OPENSSL_cpuid_setup' can not be used when making a
> > shared object; recompile with -fPIC
> > /usr/bin/ld: final link failed: Bad value
> > collect2: ld returned 1 exit status
> > make[4]: *** [../priv/lib/x86_64-unknown-linux-gnu/crypto_drv.so] Error 1
> > make[3]: *** [opt] Error 2
> >
> > ============================
> > Tracing this you get this command that failed
> >
> > [ c_src]$
> > gcc -shared  -o ../priv/lib/x86_64-unknown-linux-gnu/crypto_drv.so
> > ../priv/obj/x86_64-unknown-linux-gnu/crypto_drv.o  /usr/lib64/libcrypto.a
> > /usr/bin/ld: /usr/lib64/libcrypto.a(x86_64cpuid.o): relocation
> > R_X86_64_PC32 against `OPENSSL_cpuid_setup' can not be used when making a
> > shared object; recompile with -fPIC
> > /usr/bin/ld: final link failed: Bad value
> >
> > ============================
> > else you will find it doing this:
> >
> > 1> crypto:start().
> > exec: 1: ok
> > 2> crypto_drv: not found
> >
> > =ERROR REPORT==== 25-Oct-2006::12:57:02 ===
> > ** Generic server crypto_server terminating
> > ** Last message in was {'EXIT',#Port<0.96>,normal}
> > ** When Server state == {#Port<0.96>,[]}
> > ** Reason for termination ==
> > ** {port_died,normal}
> > exec: 1: crypto_drv: not found
> >
> >
> > ============================= Solution / Fix ===
> >
> > Right or wrong this fixed the problem
> >
> > after
> >
> > ./configure
> > make
> >
> > go to the directory  %ERL_TOP%/lib/crypto/c_src
> > issue the command:
> >
> > gcc -shared  -o ../priv/lib/x86_64-unknown-linux-gnu/crypto_drv.so
> > ../priv/obj/x86_64-unknown-linux-gnu/crypto_drv.o
> >  /usr/lib64/libcrypto.so
> >
> > now do: make install
> >
> > crypto:start().
> > _______________________________________________
> > erlang-patches mailing list
> > 
> > http://www.erlang.org/mailman/listinfo/erlang-patches



-- 
-------------------------------------
Daniel Schutte
CEO - Erlang Financial Systems International

Office:  +27 11 602 9301
Mobile:  +27 84 468 3138
Phone :  +27 11 602 9302



More information about the erlang-patches mailing list