Bug 209458

Summary: base OpenSSL complains for relocation for databases/mysql57
Product: Ports & Packages Reporter: gja822
Component: Individual Port(s)Assignee: Kurt Jaeger <pi>
Status: Closed FIXED    
Severity: Affects Only Me CC: amd64, jkim, mmokhi, pi, ports-bugs, rootservice
Priority: ---    
Version: Latest   
Hardware: amd64   
OS: Any   
URL: https://svnweb.freebsd.org/changeset/ports/412346
Bug Depends on:    
Bug Blocks: 209510    
Attachments:
Description Flags
ignore openssl from base
none
Previous patch (mark port if Base used intentionally) with some changes
mmokhi: maintainer-approval+
Minimal changes to make the system OpenSSL working
none
Patch merges Kim's fix to correctly choose SSL Ports for 9.X
mmokhi: maintainer-approval+
Previous Patch without ${PORTSDIR} mmokhi: maintainer-approval+

Description gja822 2016-05-11 18:12:54 UTC
As described on https://forums.freebsd.org/threads/56184/

Trying to compile some ports on 10.3-STABLE, databases/mysql57-client for example, with WITH_OPENSSL_BASE=yes in /etc/make.conf results in this error:

/usr/bin/ld: /usr/lib/libssl.a(ssl_err.o): relocation R_X86_64_32 against `a loc
al symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib/libssl.a: could not read symbols: Bad value
Comment 1 Markus Kohlmeyer 2016-05-12 14:25:29 UTC
Same issue as in bug #208759

Because of this we set WITH_OPENSSL_PORT in the Makefile for mysql57

I'll prepare a patch this weekend to catch WITH_OPENSSL_BASE and throw an error if set, so this will not bite us again until base is fixed.
Comment 2 Markus Kohlmeyer 2016-05-12 20:08:57 UTC
Created attachment 170235 [details]
ignore openssl from base

builds and runs on 10.3-RELEASE and 10-STABLE

QA not done
Comment 3 Markus Kohlmeyer 2016-05-12 20:17:36 UTC
added freebsd-ports-bugs and mysql57 maintainer to cc
Comment 4 gja822 2016-05-13 04:58:13 UTC
(In reply to Markus Kohlmeyer from comment #2)
Why it is said about LibreSSL in the patch, can mysql57 port use it?
Comment 5 Markus Kohlmeyer 2016-05-13 09:55:07 UTC
(In reply to gja822 from comment #4)

Yes, MySQL can be linked against LibreSSL

I've that combi in production since months now.
Comment 6 gja822 2016-05-14 02:05:46 UTC
(In reply to Markus Kohlmeyer from comment #5)
...for in the port's Makefile I do not see any occurrence of LibreSSL, neither in options nor in hidden form of code.
Comment 7 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-14 03:21:36 UTC
(In reply to gja822 from comment #6)
You can set default ssl in /etc/make.conf to libressl. Then ports framework will choose that when ssl options used
Comment 8 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-16 15:04:35 UTC
Created attachment 170365 [details]
Previous patch (mark port if Base used intentionally) with some changes

This is like patch Markus suggested with some changes (to be more exact)
Using BROKEN instead of IGNORE: as handbook suggests it's better to "Use BROKEN for ports where the problem is believed to be temporary."

and i believe it's temporary (as I'm trying to patch the Cmake-script to make it not use `ld` for static libs and use them to build ;D)

Also i see no reason to use .if condition for setting "WITH_OPENSSL_PORT=yes" as we should set it anyway.

BTW, i solved these in this patch.
QA: portlint -AC -> done successfully: no Fatal error
Comment 9 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-16 15:12:12 UTC
Also as this one and #209510 are minor changes, i guess it's good idea to increase port-revision on #209512's patch.
Comment 10 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-16 17:06:22 UTC
Re-assigning to default to go for commit :D

Thanks for reporter (gja822@narod.ru) and reviewer (Markus) and committer (who knows ;D)
Comment 11 Jung-uk Kim freebsd_committer freebsd_triage 2016-05-16 19:36:46 UTC
Note head and stable/10 have position independent libcrypto.so.

https://svnweb.freebsd.org/changeset/base/299389
https://svnweb.freebsd.org/changeset/base/299966
Comment 12 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-16 19:52:20 UTC
(In reply to Jung-uk Kim from comment #11)
The problem is with libssl.a not libcrypto (if I interpreted your meaning correctly :D)
Comment 13 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-16 20:00:21 UTC
(In reply to Mahdi Mokhtari from comment #12)
BTW using openssl-port fixes that.
(until patch for using openssl-base becomes ready)
Comment 14 Markus Kohlmeyer 2016-05-16 20:04:08 UTC
(In reply to Jung-uk Kim from comment #11)

That changesets are only related to libcrypto.so on i386, but AFAICS are not related to the linking issue with the libssl.a on i386, amd64 and possibly other arches.

Nonetheless thanks for the hint.
Comment 15 Jung-uk Kim freebsd_committer freebsd_triage 2016-05-16 20:07:18 UTC
(In reply to Mahdi Mokhtari from comment #12)
Ah, I see.  Something's wrong with the port.  I'll take a look at it.
Comment 16 Markus Kohlmeyer 2016-05-16 20:19:55 UTC
(In reply to Jung-uk Kim from comment #15)

The problem is with base not being compiled pic/pie by default, not with any port using pic/pie for good reasons (eg. improved security).
Comment 17 Jung-uk Kim freebsd_committer freebsd_triage 2016-05-16 20:24:17 UTC
(In reply to Markus Kohlmeyer from comment #16)
No, see the log.  It's complaining that *libssl.a* is not PIC.  It should use *libssl.so*, not libssl.a.
Comment 18 Markus Kohlmeyer 2016-05-16 21:17:47 UTC
(In reply to Jung-uk Kim from comment #17)

If you realy mean that you're correct, than have a look at mysql-5.7.12/cmake/ssl.cmake line 148-153 and please send any patches upstream, so that Oracle can explain why they prefer static libs.
Comment 19 Markus Kohlmeyer 2016-05-16 21:36:16 UTC
Same applies to MySQL >=5.6, MariaDB >=10 and Percona >=5.6
Comment 20 Markus Kohlmeyer 2016-05-16 21:47:11 UTC
That code was introduced 2012 to MySQL with this commit:
https://github.com/mysql/mysql-server/commit/93494195a986f4c6b5f9e394163af902bbe09869

So it's ages older than the linking problem we now have, which leads me to the conclusion that base is broken not the ports.
Comment 21 Jung-uk Kim freebsd_committer freebsd_triage 2016-05-16 23:54:22 UTC
Created attachment 170380 [details]
Minimal changes to make the system OpenSSL working

This is really a port bug because I was able to build databases/mysql57-{client,server} just fine with this patch.  Please note I haven't tried other SSL libraries.
Comment 22 Markus Kohlmeyer 2016-05-17 00:06:32 UTC
Nice, i'll test that tomorrow, thanks.
Comment 23 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-17 06:21:10 UTC
(In reply to Jung-uk Kim from comment #21)
Thanks for your help on this problem ;)

I'm trying to change ssl.cmake to find thing in more appropriate/dynamic way.
But till then i see your solution really good (better that totally ignoring OpenSSL from Base).

FWIW, The chosen/preferred approach is being able to use "-DWITH_SSL=${OPENSSLBASE}" instead of all "-DWITH_SSL=system/or/others" and everything should go correct, accurate and automated from both side (porst-framework and ssl.cmake)

BTW, I'm testing its QA :D (lint/build)
Comment 24 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-17 07:55:32 UTC
(In reply to Mahdi Mokhtari from comment #23)
Just to inform you guys :)
Linting had no Serious problem.
But for building, it was okay for 10 and 11, but as 9.X's base is older than supported version, i have to except it from Jung-uk Kim's patch.
So finally i added Jung-uk Kim's edits completely under conditions of IF FreeBSD >= 10 
and it seems fine now :)
Comment 25 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-17 08:17:29 UTC
Created attachment 170391 [details]
Patch merges Kim's fix to correctly choose SSL Ports for 9.X

Patch that do the works i mentioned above :D

Thanks for everybody's helps ;)

QA:
portlint Okay
poudriere Okay (9.X and newer)
Comment 26 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-17 08:18:48 UTC
If everybody agree, i guess we can let it to go for commit :)
Opinions ?
Comment 27 Markus Kohlmeyer 2016-05-17 08:35:32 UTC
OK for the patch to be committed, but isn't ${PORTSDIR} deprecated?
Comment 28 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-17 08:36:36 UTC
(In reply to Markus Kohlmeyer from comment #27)
> but isn't ${PORTSDIR} deprecated?
I'm afraid not :)
Cause i fixed it by suggestion of portlint tool :D
Comment 30 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-17 11:31:19 UTC
(In reply to Markus Kohlmeyer from comment #29)
Thanks for providing link :)
It doesn't say the other one is deprecated.
At least i think we should wait till `portlint` doesn't warn us for this case ;)
Comment 31 Kurt Jaeger freebsd_committer freebsd_triage 2016-05-17 16:38:18 UTC
testbuilds@work
Comment 32 Jung-uk Kim freebsd_committer freebsd_triage 2016-05-17 16:50:26 UTC
(In reply to Mahdi Mokhtari from comment #30)
No, you should remove ${PORTSDIR}.  See r412346:

https://svnweb.freebsd.org/changeset/ports/412346
Comment 33 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-17 16:58:22 UTC
Created attachment 170411 [details]
Previous Patch without ${PORTSDIR}

Done ;)
Comment 34 commit-hook freebsd_committer freebsd_triage 2016-05-17 18:18:48 UTC
A commit references this bug:

Author: pi
Date: Tue May 17 18:18:41 UTC 2016
New revision: 415404
URL: https://svnweb.freebsd.org/changeset/ports/415404

Log:
  databases/mysql57-server: changing the way the SSL libraries are linked

  PR:		209458
  Reported by:	gja822@narod.ru
  Submitted by:	Markus Kohlmeyer <rootservice@gmail.com>
  Reviewed by:	jkim
  Approved by:	Mahdi Mokhtari <mokhi64@gmail.com> (maintainer)

Changes:
  head/databases/mysql57-server/Makefile
Comment 35 Kurt Jaeger freebsd_committer freebsd_triage 2016-05-17 18:19:39 UTC
Committed. I've read the discussion, testbuilds are fine. I hope this does not mess things up 8-}
Comment 36 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-17 20:01:29 UTC
Thanks all guys.
Good job ;)