Bug 236548 - devel/p4: build error when using DEFAULT_VERSIONS+=ssl=libressl-devel in make.conf
Summary: devel/p4: build error when using DEFAULT_VERSIONS+=ssl=libressl-devel in make...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Alan Somers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-15 10:42 UTC by Tassilo Philipp
Modified: 2019-06-06 11:02 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (asomers)


Attachments
Fix build with alternate OpenSSL implementations (350 bytes, patch)
2019-03-16 01:31 UTC, Alan Somers
asomers: maintainer-approval+
Details | Diff
Fix build with alternate OpenSSL implementations (379 bytes, patch)
2019-03-16 16:01 UTC, Alan Somers
asomers: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tassilo Philipp 2019-03-15 10:42:46 UTC
devel/p4 fails to build with the following error when selecting libressl-devel as default ssl provider (at least for libressl 2.9.0, unsure about libressl of the non-devel port):

  /usr/bin/ld: error: undefined symbol: X509_get_X509_PUBKEY

This is due to the fact that /usr/include/openssl/x509.h is included instead of /usr/local/include/openssl/x509.h, the former declaring X509_get_X509_PUBKEY as a symbol whereas the latter implements it as a macro.

Changing the include order and assuring that the build looks at the libressl headers, works, e.g.:

  cd /usr/ports/devel/p4
  sudo make CPATH=/usr/local/include:/usr/include


I think that this could also lead to problems with openssl from ports, instead of the one from base, as the base includes from /usr/include will be used instead of the ones from ports?

I am not sure what the best way would be to fix this, but I guess the Makefile should be changed to make sure this includes the matching headers for all possible combinations, openssl (from base or ports) or libressl.
Comment 1 Alan Somers freebsd_committer freebsd_triage 2019-03-16 01:31:03 UTC
Created attachment 202894 [details]
Fix build with alternate OpenSSL implementations

Thanks for reporting this bug.  Can you please try building with this patch?  It works for me in Poudriere.
Comment 2 Tassilo Philipp 2019-03-16 14:58:15 UTC
This works and fixes the issue I reported, however it seems to create another problem. With this patch the port fails to build if archivers/libzip is installed.

With -I${OPENSSLINC}, the following error is produced when compiling crc32.c (shipped with the distfile perforce/p4/2016-1.zip):

----------- log --------------->

clang -c -o p4-bin/objects/zlib/crc32.o -O2 -pipe  -I/usr/local/include -fstack-protector -fno-strict-aliasing  -pipe -O2 -Wno-parentheses -Wno-switch -fwrapv -DOS_FREEBSD -DOS_FREEBSD120 -DOS_FREEBSDX86_64 -DOS_FREEBSD120X86_64 -DUSE_SSL -Izlib -Imsgs -Isupport -Isys zlib/crc32.c

sys/zipfile.cc:52:25: error: use of undeclared identifier 'APPEND_STATUS_CREATE'
        zf = zipOpen64( fName, APPEND_STATUS_CREATE );
                               ^
sys/zipfile.cc:58:2: error: use of undeclared identifier 'zipClose'
        zipClose( zf, 0 );
        ^
sys/zipfile.cc:74:2: error: unknown type name 'zip_fileinfo'
        zip_fileinfo zi;
        ^
sys/zipfile.cc:94:15: error: use of undeclared identifier 'zipCloseFileInZip'
        int result = zipCloseFileInZip( zf );
                     ^
sys/zipfile.cc:106:15: error: use of undeclared identifier 'zipWriteInFileInZip'
        int result = zipWriteInFileInZip( zf, buf, len );
                     ^
5 errors generated.

<----------- log ---------------


The reason is that it includes libzip's installed /usr/local/include/zip.h whereas the build wants to include its own /usr/ports/devel/p4/work/2016-1/zlib/zip.h.


Looking at the clang command invocation above that now has the new -I/usr/local/include in it, I think it should be after the -Izlib one (which I guess refers to p4's own shipped zlib folder). I am not sure how you would place it accordingly, maybe as pragmatically as:
CFLAGS+=	-Izlib -I${OPENSSLINC}

Does feel a bit hacky though...
Comment 3 Tassilo Philipp 2019-03-16 15:01:02 UTC
Tiny (not really important) correction: it fails when sys/zipfile.cc is compiled, not crc32. I copy & pasted the wrong line. The analysis stays the same, though.

Thanks for the quick reply and fix btw, you rock!
Comment 4 Alan Somers freebsd_committer freebsd_triage 2019-03-16 16:01:07 UTC
Created attachment 202914 [details]
Fix build with alternate OpenSSL implementations

Try this patch instead.  I think this should fix the libzip problem.
Comment 5 Tassilo Philipp 2019-03-22 14:36:36 UTC
Sorry for the delay, I didn't see the notification. Anyways, thanks for the patch, seems to work fine!
Comment 6 commit-hook freebsd_committer freebsd_triage 2019-03-22 14:43:23 UTC
A commit references this bug:

Author: asomers
Date: Fri Mar 22 14:43:11 UTC 2019
New revision: 496572
URL: https://svnweb.freebsd.org/changeset/ports/496572

Log:
  devel/p4: fix the build with alternate OpenSSL implementations

  When setting DEFAULT_VERSIONS+=ssl=anything, p4 needs to use OPENSSLINC.

  PR:		236548
  Reported by:	Tassilo Philipp <tphilipp@potion-studios.com>
  MFH:		2019Q1

Changes:
  head/devel/p4/Makefile