jeroen / openssl

OpenSSL bindings for R
Other
65 stars 23 forks source link

Build fails in FreeBSD stable/11 (possibly other BSD environments) #41

Closed dhwolfskill closed 7 years ago

dhwolfskill commented 7 years ago

> install.packages("RPresto") ... * installing source package ‘openssl’ ... * package ‘openssl’ successfully unpacked and MD5 sums checked Using PKG_CFLAGS= Using PKG_LIBS=-lssl -lcrypto * libs ... gcc49 -std=gnu99 -I/usr/local/lib/R/include -DNDEBUG -DLIBICONV_PLUG -I/usr/local/include -isystem /usr/local/include -fpic -O2 -pipe -DLIBICONV_PLUG -fstack-protector -Wl,-rpath=/usr/local/lib/gcc49 -isystem /usr/local/include -fno-strict-aliasing -flto -c ssl.c -o ssl.o ssl.c: In function 'R_download_cert': ssl.c:41:21: error: 'PF_UNSPEC' undeclared (first use in this function) hints.ai_family = PF_UNSPEC; ^ ssl.c:41:21: note: each undeclared identifier is reported only once for each function it appears in *** Error code 1

Stop. make: stopped in /tmp/RtmpZaYMEA/R.INSTALL56d129603235/openssl/src ....

So, checking /usr/include/sys/socket.h: g1-252(11.0-S)[3] grep -nwC 6 PF_UNSPEC /usr/include/sys/socket.h 323-#include <sys/_sockaddr_storage.h> 324- 325-#if __BSD_VISIBLE 326-/ 327- Protocol families, same as address families for now. 328- / 329:#define PF_UNSPEC AF_UNSPEC 330-#define PF_LOCAL AF_LOCAL 331-#define PF_UNIX PF_LOCAL / backward compatibility */ 332-#define PF_INET AF_INET 333-#define PF_IMPLINK AF_IMPLINK 334-#define PF_PUP AF_PUP 335-#define PF_CHAOS AF_CHAOS g1-252(11.0-S)[4]

So PF_UNSPEC is only defined if __BSD_VISIBLE is true.

Might it be reasonable to define __BSD_VISIBLE as true, at least for BSD environments? Or is there something (obvious) that I am overlooking?

dhwolfskill commented 7 years ago

Empirically, the following patch appears to "make the build/install work" in my environment:

--- src/ssl.c.orig 2016-12-30 13:26:04.000000000 -0800 +++ src/ssl.c 2017-01-18 16:31:02.301226000 -0800 @@ -2,6 +2,9 @@

if !defined(_WIN32) && !defined(__sun) && !defined(_POSIX_C_SOURCE)

define _POSIX_C_SOURCE 200112L

endif

+#if defined(_FreeBSD_) +#define __BSD_VISIBLE 1 +#endif

include

include

jeroen commented 7 years ago

I'm not a BSD expert, but I'll take your word on it: https://github.com/jeroenooms/openssl/commit/4c0ef04888c50ec6ba168eca3705d0f1a869f02a. Can you verify that it now works?

jeroen commented 7 years ago

Assuming this is working now via https://github.com/jeroenooms/openssl/blob/master/src/ssl.c#L7-L9.