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

git2r build fail on OpenBSD (CRAN and github master) #138

Closed
pschmied opened this issue May 10, 2015 · 9 comments
Closed

git2r build fail on OpenBSD (CRAN and github master) #138

pschmied opened this issue May 10, 2015 · 9 comments

Comments

@pschmied
Copy link

Hello,

I was reinstalling devtools after upgrading R, and ran into a build failure with git2r. I'm on OpenBSD 5.7-current, amd64. The build appears to be failing when checking for OpenSSL. I suspect this has to do with OpenBSD having swapped out OpenSSL for LibreSSL (http://www.libressl.org/), and something in git2r's autoconf setup.

Other OpenSSL-using software seems to pick up LibreSSL as a replacement, so I'm guessing there is a cross-platform way of checking for both. That said, I are no autoconf genius. I'm posting this here in hopes that someone smarter than me will have an idea of what's going on there.

More than happy to test things, if anyone has suggestions!

Relevant ./configure bits:

checking for library containing SSL_library_init... no
configure: error: in `/home/peter/tmp/git2r':
configure: error: OpenSSL library required
See `config.log' for more details
ERROR: configuration failed for package 'git2r'

And here are the bits from config.log:

configure:3633: checking for library containing SSL_library_init
configure:3664: cc -std=gnu99 -o conftest -O2 -pipe -I/usr/local/include/ereadline -I/usr/local/include -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I. -Ilibgit2 -Ilibgit2/include -Ihttp-parser  conftest.c -lz  >&5
/tmp//ccMgCY3x.o(.text+0x7): In function `main':
: undefined reference to `SSL_library_init'
collect2: ld returned 1 exit status
configure:3664: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "git2r"
| #define PACKAGE_TARNAME "git2r"
| #define PACKAGE_VERSION "see.DESCRIPTION.file"
| #define PACKAGE_STRING "git2r see.DESCRIPTION.file"
| #define PACKAGE_BUGREPORT "https://github.com/ropensci/git2r/issues"
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char SSL_library_init ();
| int
| main ()
| {
| return SSL_library_init ();
|   ;
|   return 0;
| }
configure:3664: cc -std=gnu99 -o conftest -O2 -pipe -I/usr/local/include/ereadline -I/usr/local/include -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I. -Ilibgit2 -Ilibgit2/include -Ihttp-parser  conftest.c -lssl  -lz  >&5
/usr/lib/libssl.so.32.0: undefined reference to `EC_KEY_new_by_curve_name'
/usr/lib/libssl.so.32.0: undefined reference to `EVP_rc4_hmac_md5'

-- output truncated, lots of undefined refs --

/usr/lib/libssl.so.32.0: undefined reference to `OBJ_bsearch_'
/usr/lib/libssl.so.32.0: undefined reference to `EVP_DecryptFinal'
collect2: ld returned 1 exit status
configure:3664: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "git2r"
| #define PACKAGE_TARNAME "git2r"
| #define PACKAGE_VERSION "see.DESCRIPTION.file"
| #define PACKAGE_STRING "git2r see.DESCRIPTION.file"
| #define PACKAGE_BUGREPORT "https://github.com/ropensci/git2r/issues"
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char SSL_library_init ();
| int
| main ()
| {
| return SSL_library_init ();
|   ;
|   return 0;
| }
configure:3681: result: no
configure:3763: error: in `/home/peter/tmp/git2r':
configure:3765: error: OpenSSL library required
See `config.log' for more details
@pschmied
Copy link
Author

I should note this output is the result of a fresh checkout from github, and an install.packages("~/tmp/git2r/", repos=NULL, type="source")

@stewid
Copy link
Member

stewid commented May 10, 2015

@pschmied thanks for reporting the issue.

It seems the configuration is not picking up the correct path to the libressl header files. If you know the path it might work to pass it to the configure script. Could you please try (replace /path/to/libressl)

git clone https://github.com/ropensci/git2r.git
R CMD INSTALL --configure-args="--with-libssl-include=/path/to/libressl" git2r

@stewid stewid added this to the Next CRAN release version 0.11 milestone May 12, 2015
@vats-div
Copy link

I received a similar error on an ubuntu machine when trying to install devtools.

Installing libcryto++ and libssl-dev (using apt-get) fixed the problem.

@pschmied
Copy link
Author

Thanks @stewid,

In this case, I'm not sure that's the fix:

% ls /usr/lib/libssl*
/usr/lib/libssl.a         /usr/lib/libssl.so.32.0   /usr/lib/libssl_p.a

% ls /usr/include/ssl 
aes.h               cast.h              dh.h                err.h               mdc2.h              pem.h               rsa.h               tls1.h
asn1.h              chacha.h            dsa.h               evp.h               modes.h             pem2.h              safestack.h         ts.h
asn1_mac.h          cmac.h              dso.h               gost.h              obj_mac.h           pkcs12.h            sha.h               txt_db.h
asn1t.h             cms.h               dtls1.h             hmac.h              objects.h           pkcs7.h             srtp.h              ui.h
bio.h               comp.h              e_os2.h             idea.h              ocsp.h              poly1305.h          ssl.h               ui_compat.h
blowfish.h          conf.h              ec.h                krb5_asn.h          opensslconf.h       rand.h              ssl2.h              whrlpool.h
bn.h                conf_api.h          ecdh.h              lhash.h             opensslfeatures.h   rc2.h               ssl23.h             x509.h
buffer.h            crypto.h            ecdsa.h             md4.h               opensslv.h          rc4.h               ssl3.h              x509_vfy.h
camellia.h          des.h               engine.h            md5.h               ossl_typ.h          ripemd.h            stack.h             x509v3.h

% R CMD INSTALL --configure-args="--with-libssl-include=/usr/include/ssl --with-libssl-lib=/usr/lib" git2r
* installing to library '/home/peter/R/x86_64-unknown-openbsd5.7-library/3.2'
* installing *source* package 'git2r' ...
checking build system type... x86_64-unknown-openbsd5.7
checking host system type... x86_64-unknown-openbsd5.7
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for library containing inflate... -lz
checking for library containing SSL_library_init... no
configure: error: in `/home/peter/tmp/git2r':
configure: error: OpenSSL library required
See `config.log' for more details
ERROR: configuration failed for package 'git2r'
* removing '/home/peter/R/x86_64-unknown-openbsd5.7-library/3.2/git2r'

@pschmied
Copy link
Author

Okay, did some more digging, and was able to get the build to run. The library paths all appear to be correct, but the "LIBS" environment variable seems to not be set up properly. This results in a working build:

R CMD INSTALL --configure-vars="LIBS='-lz -lcrypto -lssl'" git2r

That suggests to me that the include and library paths are all set up properly, but that the tests are failing. From the config.log, the bit of c code they compile as a test for SSL_library_init () seems to be declaring a char return type, which doesn't work for me with a toy example:

% more foo.c 
#include </usr/include/ssl/ssl.h>
#include </usr/include/ssl/crypto.h>

char SSL_library_init ();
int main ()
{
  return SSL_library_init ();
}

% gcc -lcrypto -lssl foo.c
foo.c:5: error: conflicting types for 'SSL_library_init'
/usr/include/ssl/ssl.h:1739: error: previous declaration of 'SSL_library_init' was here

Switching the return type to int results in working build. Have no idea if that's relevant, but I thought that char return type looked suspicious from the config.log.

@stewid
Copy link
Member

stewid commented May 13, 2015

@pschmied thanks for the digging 👍

I have installed OpenBSD 5.7 on a virtual machine and can reproduce the issue.

@stewid
Copy link
Member

stewid commented May 13, 2015

@pschmied could you please try to install the build_on_OpenBSD branch. I have changed order of the libcrypto and libssl tests.

@pschmied
Copy link
Author

Confirmed! build_on_OpenBSD branch builds without a hitch.

I appreciate you taking the time to create a fix for us non-Linux, Mac, Windows weirdos! ;-) On the upside, this should resolve future problems, if libressl becomes more common outside OpenBSD.

@stewid
Copy link
Member

stewid commented May 13, 2015

Thanks for testing

@stewid stewid closed this as completed May 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants