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

Cannot compile on FreeBSD 12 #686

Closed
fluca1978 opened this Issue Mar 4, 2019 · 6 comments

Comments

Projects
None yet
3 participants
@fluca1978
Copy link
Contributor

fluca1978 commented Mar 4, 2019

On FreeBSD 12-RELEASE amd64, I've tried to compile version 2.10 (release) and HEAD, both failing:

% gmake -s -C src 
common/io/tls/client.c: In function 'tlsClientOpen':
common/io/tls/client.c:298:41: error: 'IPPROTO_TCP' undeclared (first use in this function); did you mean 'EPROTOTYPE'?
hints.ai_protocol = IPPROTO_TCP;
^~~~~~~~~~~
EPROTOTYPE
compilation terminated due to -Wfatal-errors.
gmake: *** [Makefile:284: common/io/tls/client.o] Error 1

I've installed libressl-devel, if that matters.
The gcc I'm using is:

% gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc8/gcc/x86_64-portbld-freebsd12.0/8.2.0/lto-wrapper
Target: x86_64-portbld-freebsd12.0
Configured with: /wrkdirs/usr/ports/lang/gcc8/work/gcc-8.2.0/configure --with-build-config=bootstrap-debug --disable-nls --enable-gnu-indirect-function --libdir=/usr/local/lib/gcc8 --libexecdir=/usr/local/libexec/gcc8 --program-suffix=8 --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-gxx-include-dir=/usr/local/lib/gcc8/include/c++/ --with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection' --with-system-zlib --enable-languages=c,c++,objc,fortran --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/share/info/gcc8 --build=x86_64-portbld-freebsd12.0
Thread model: posix
gcc version 8.2.0 (FreeBSD Ports Collection)

Am I missing something?

@fluca1978

This comment has been minimized.

Copy link
Contributor Author

fluca1978 commented Mar 4, 2019

Apparently, with the following diff I can compile and it seems to start.

% git diff
diff --git a/src/Makefile b/src/Makefile
index 73672bff..b2425b55 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -8,7 +8,7 @@
CC=gcc
# Compile using C99 and Posix 2001 standards (also _DARWIN_C_SOURCE for MacOS)
-CSTD = -std=c99 -D_POSIX_C_SOURCE=200112L -D_DARWIN_C_SOURCE
+CSTD = -std=c99 
# Compile optimizations
COPT = -O2
diff --git a/src/common/io/tls/client.c b/src/common/io/tls/client.c
index ddddb790..10b1d538 100644
--- a/src/common/io/tls/client.c
+++ b/src/common/io/tls/client.c
@@ -25,6 +25,7 @@ TLS Client
#include "common/type/keyValue.h"
#include "common/wait.h"
#include "crypto/crypto.h"
+#include <netinet/in.h>
/***********************************************************************************************************************************
Object type

I would like any comment before closing the issue.

@jungle-boogie

This comment has been minimized.

Copy link

jungle-boogie commented Mar 5, 2019

See these two:
#670
#652

Removing CSTD = -std=c99 -D_POSIX_C_SOURCE=200112L -D_DARWIN_C_SOURCE from the Makefile allowed me to build pgbackrest

@dwsteele

This comment has been minimized.

Copy link
Member

dwsteele commented Mar 5, 2019

Yeah, for whatever reason FreeBSD does not like -D_POSIX_C_SOURCE=200112L. We don't have a configure script but since this keeps coming up we should at least add a comment.

Should we go with:

# FreeBSD requires: CSTD = -std=c99

@jungle-boogie Can you compile with -std=c99?

@dwsteele dwsteele self-assigned this Mar 5, 2019

@dwsteele dwsteele added the question label Mar 5, 2019

@dwsteele dwsteele added this to the 2.11 milestone Mar 5, 2019

@jungle-boogie

This comment has been minimized.

Copy link

jungle-boogie commented Mar 5, 2019

Hi David,

yep, I can build with only this change:

diff --git a/src/Makefile b/src/Makefile
index 73672bff..ed448013 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -8,7 +8,7 @@
 CC=gcc

 # Compile using C99 and Posix 2001 standards (also _DARWIN_C_SOURCE for MacOS)
-CSTD = -std=c99 -D_POSIX_C_SOURCE=200112L -D_DARWIN_C_SOURCE
+CSTD = -std=c99
$ ./src/pgbackrest version && git rev-parse HEAD
pgBackRest 2.11dev
d441061168ec56d22082a6ff54e5f1fb02cc8eae

Just a quick note, I'm running OpenBSD, so if will be a comment in the makefile, maybe it should be
*BSD or Free/OpenBSD.

@fluca1978

This comment has been minimized.

Copy link
Contributor Author

fluca1978 commented Mar 6, 2019

Would it be worth adding a Makefile.BSD file with appropriate configuration for such platforms? Also please note that on FreeBSD things should go installed into /usr/local/bin rather than in /usr/bin, while this can be configured via Makefile it seems pgbackrest always searches for /etc/pgbackrest/pgbackrest.conf, so maybe it would also be a little improvement to add a configurable "home" for the application.

@dwsteele

This comment has been minimized.

Copy link
Member

dwsteele commented Mar 10, 2019

For now let's stick with the comment committed in bc9fb0f.

Maintaining a separate Makefile for BSD is a non-starter since we won't be able to test it, at least not at this time. See my comments about autoconf in #690.

@dwsteele dwsteele closed this Mar 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.