Bug 192555 - [PATCH] security/libgcrypt: fix build with GCC on 8.x/amd64
Summary: [PATCH] security/libgcrypt: fix build with GCC on 8.x/amd64
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Kurt Jaeger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-10 18:04 UTC by Carlos J Puga Medina
Modified: 2014-09-04 17:29 UTC (History)
4 users (show)

See Also:


Attachments
libgcrypt.diff (1.30 KB, patch)
2014-08-10 18:04 UTC, Carlos J Puga Medina
no flags Details | Diff
libgcrypt.diff (446 bytes, patch)
2014-08-11 09:42 UTC, Carlos J Puga Medina
no flags Details | Diff
libgcrypt-fix-asm-8.x.diff (1.81 KB, patch)
2014-08-12 10:46 UTC, Carlos J Puga Medina
no flags Details | Diff
libgcrypt-fix-asm-8.x-v1.diff (1.74 KB, patch)
2014-08-13 14:15 UTC, Carlos J Puga Medina
no flags Details | Diff
re-add disable drng support on amd64 (1.65 KB, patch)
2014-09-03 08:29 UTC, Carlos J Puga Medina
no flags Details | Diff
re-add disable drng support on amd64 (1.65 KB, patch)
2014-09-03 08:45 UTC, Carlos J Puga Medina
no flags Details | Diff
re-add disable drng support on amd64 (1.69 KB, patch)
2014-09-03 08:49 UTC, Carlos J Puga Medina
no flags Details | Diff
libgcrypt-1.6.1_5.diff (1.02 KB, patch)
2014-09-04 10:16 UTC, Carlos J Puga Medina
no flags Details | Diff
libgcrypt-1.6.1_5.diff (851 bytes, patch)
2014-09-04 10:43 UTC, Carlos J Puga Medina
no flags Details | Diff
libgcrypt-1.6.1_5.diff (852 bytes, patch)
2014-09-04 11:17 UTC, Carlos J Puga Medina
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos J Puga Medina 2014-08-10 18:04:56 UTC
Created attachment 145618 [details]
libgcrypt.diff

The following patch was proposed by an user via mail to build happy libgrypt with GCC on FreeBSD 8.x

Build logs:

https://redports.org/buildarchive/20140804121800-54485/
Comment 1 Kurt Jaeger freebsd_committer freebsd_triage 2014-08-10 18:31:43 UTC
> The following patch was proposed by an user via mail to build happy libgrypt
> with GCC on FreeBSD 8.x

Testbuild on 8.4amd64 @work.

If I understand it, it *always* builds without using the assembler code ?
Is my understanding correct ?
Comment 2 Carlos J Puga Medina 2014-08-10 19:52:41 UTC
(In reply to Kurt Jaeger from comment #1)
> > The following patch was proposed by an user via mail to build happy libgrypt
> > with GCC on FreeBSD 8.x
> 
> Testbuild on 8.4amd64 @work.
> 
> If I understand it, it *always* builds without using the assembler code ?
> Is my understanding correct ?

Yes, libgcrypt has some assembly code routines but to disable it we can use '--disable-asm' option to the configure script.
Comment 3 John Marino freebsd_committer freebsd_triage 2014-08-11 08:49:15 UTC
I would have it disabled by default, but you can add an option to build with assembly routines.  I think that's a pretty standard approach.
Comment 4 Carlos J Puga Medina 2014-08-11 09:11:04 UTC
(In reply to John Marino from comment #3)
> I would have it disabled by default, but you can add an option to build with
> assembly routines.  I think that's a pretty standard approach.

Yes, I think that build libgcrypt with clang including -DNO_ASM flag in CFLAGS should work.

Clarification: Using --disable-asm only disables the use of the MPI assembler modules but not of the other asm functions.
Comment 5 Carlos J Puga Medina 2014-08-11 09:42:31 UTC
Created attachment 145657 [details]
libgcrypt.diff

New patch which fix libgcrypt build with GCC on 8.x/amd64 

Build logs:

https://redports.org/buildarchive/20140811092701-19531/
Comment 6 Carlos J Puga Medina 2014-08-12 10:46:42 UTC
Created attachment 145708 [details]
libgcrypt-fix-asm-8.x.diff

Patch reworked to undefine assembly code with gcc on 8.x/amd64. Pending the OP report to commit it.

Test build on 8.4-RELEASE/amd64:

https://redports.org/~cpm/20140812103001-56669-232794/libgcrypt-1.6.1_4.log

Rest of build logs:

https://redports.org/buildarchive/20140812103001-56669/
Comment 7 John Marino freebsd_committer freebsd_triage 2014-08-12 10:48:46 UTC
moving to patch-ready
Comment 8 Carlos J Puga Medina 2014-08-13 10:25:00 UTC
The OP confirms that the patch solves his problem. I show a copy of the email sent by Terry.

Delivered-To: cjpugmed@gmail.com
Received: by 10.220.131.202 with SMTP id y10csp270377vcs;
        Tue, 12 Aug 2014 22:22:35 -0700 (PDT)
X-Received: by 10.140.87.244 with SMTP id r107mr2886017qgd.13.1407907354774;
        Tue, 12 Aug 2014 22:22:34 -0700 (PDT)
Return-Path: <TERRY@tmk.com>
Received: from server.tmk.com (server.tmk.com. [204.141.35.63])
        by mx.google.com with ESMTPS id 94si972310qgl.88.2014.08.12.22.22.34
        for <cjpugmed@gmail.com>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Tue, 12 Aug 2014 22:22:34 -0700 (PDT)
Received-SPF: pass (google.com: domain of TERRY@tmk.com designates 204.141.35.63 as permitted sender) client-ip=204.141.35.63;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of TERRY@tmk.com designates 204.141.35.63 as permitted sender) smtp.mail=TERRY@tmk.com
Received: from tmk.com by tmk.com (PMDF V6.6 #37010)
 id <01PBBB7JZ74G001841@tmk.com> for cjpugmed@gmail.com; Wed,
 13 Aug 2014 01:22:33 -0400 (EDT)
Date: Wed, 13 Aug 2014 01:20:29 -0400 (EDT)
From: Terry Kennedy <TERRY@tmk.com>
Subject: Re: Port security/libgcrypt 1.6.1 upgrade
In-reply-to: "Your message dated Tue, 12 Aug 2014 12:34:46 +0200"
 <CAHHLbRM0Tq66zFxoXzR=4JokzwM=jLye=_O5umahg466M_eBFA@mail.gmail.com>
To: Carlos Jacobo Puga Medina <cjpugmed@gmail.com>
Message-id: <01PBBBD0ZVZC001841@tmk.com>
MIME-version: 1.0
Content-type: TEXT/PLAIN; charset=UTF-8
References: <01PAY8UNOMJ80007SG@tmk.com> <20140803205850.GF1426@f10.opsec.eu>
 <01PAYHJ5PTXM0007SG@tmk.com>
 <CAHHLbRO_KUPDjHq3hOYsJmbcWV57snREmfHsAFMr+5UO0mAegg@mail.gmail.com>
 <CAHHLbRM6_qba6JdgpXBGCimK1iYWNua14EfigxBLdhfVhB5qFg@mail.gmail.com>
 <01PB86N5XWNC000TVX@tmk.com>
 <CAHHLbRN0pW-qN+vY1EHiG5GOuXoqGXNQwdHMy2-TsTXuzDFTmA@mail.gmail.com>
 <CAHHLbRMFWc-Dm5xX_LGe27RYAd28zw=UtTUYRbBFdKbhq-XDaQ@mail.gmail.com>
 <01PBA1JNRH88000V3D@tmk.com>
 <CAHHLbRMyPR4ZNepRYtWOuBD9rrKeAzTLY-TN-3Pi9D-0E=rnRg@mail.gmail.com>
 <CAHHLbRPqhAAOun+6XZuuT7q=qGZ_4sWrjRpTkHciw=gZuPfYSg@mail.gmail.com>

> Sorry, I forgot to fix the patch name :)
>
> Test build on 8.4/amd64:
> https://redports.org/~cpm/20140812103001-56669-232794/libgcrypt-1.6.1_4.log

  This one (https://bugs.freebsd.org/bugzilla/attachment.cgi?id=145708) 
works. Ok to commit.

	Thanks,
	Terry
Comment 9 Kurt Jaeger freebsd_committer freebsd_triage 2014-08-13 11:06:44 UTC
(In reply to Carlos Jacobo Puga Medina from comment #6)
> Created attachment 145708 [details]
> libgcrypt-fix-asm-8.x.diff
> 
> Patch reworked to undefine assembly code with gcc on 8.x/amd64. Pending the
> OP report to commit it.

tested on 10.0-amd64, has issues with it:

# make
/!\ libgcrypt-1.6.1_4: Makefile errors /!\
 
you cannot include bsd.port[.pre].mk twice
 
*** Error code 1
 
Stop.
make[1]: stopped in /usr/local/home/pi/myp/security/libgcrypt
*** Error code 1
 
Stop.
Comment 10 Carlos J Puga Medina 2014-08-13 14:15:01 UTC
Created attachment 145756 [details]
libgcrypt-fix-asm-8.x-v1.diff

Current patch fixes the problem.

Build logs:

https://redports.org/buildarchive/20140813125100-24398/
Comment 11 Kurt Jaeger freebsd_committer freebsd_triage 2014-08-13 14:26:33 UTC
(In reply to Carlos Jacobo Puga Medina from comment #10)
> Created attachment 145756 [details]
> libgcrypt-fix-asm-8.x-v1.diff

Test-build via poudriere on 8.4-i386 and amd64, 9.1-amd64, and 10.0-amd64.
Comment 12 Kurt Jaeger freebsd_committer freebsd_triage 2014-08-15 19:18:44 UTC
(In reply to Kurt Jaeger from comment #11)
> (In reply to Carlos Jacobo Puga Medina from comment #10)
> > Created attachment 145756 [details]
> > libgcrypt-fix-asm-8.x-v1.diff
> 
> Test-build via poudriere on 8.4-i386 and amd64, 9.1-amd64, and 10.0-amd64.

http://people.freebsd.org/~pi/misc/gcrypt/84i.log
http://people.freebsd.org/~pi/misc/gcrypt/91a.log
http://people.freebsd.org/~pi/misc/gcrypt/10a.log
Comment 13 John Marino freebsd_committer freebsd_triage 2014-08-15 21:39:18 UTC
moving back to patch-ready.
Comment 14 John Marino freebsd_committer freebsd_triage 2014-08-15 21:40:18 UTC
ack, same mistake.
We are waiting for umq@ueo.co.jp (maintainer)
Start the clock.
Comment 15 Carlos J Puga Medina 2014-09-01 21:33:25 UTC
Do we have any news about this?
Comment 16 Kurt Jaeger freebsd_committer freebsd_triage 2014-09-02 20:37:44 UTC
I'm retesting with the new framework, and commit if it builds.
Comment 17 commit-hook freebsd_committer freebsd_triage 2014-09-02 20:48:31 UTC
A commit references this bug:

Author: pi
Date: Tue Sep  2 20:47:44 UTC 2014
New revision: 367081
URL: http://svnweb.freebsd.org/changeset/ports/367081

Log:
  security/libgcrypt: fix build without assembler on 8.x/amd64

  PR:		192555
  Submitted by:	Carlos Jacobo Puga Medina <cpm@fbsd.es>
  Approved by:	maintainer (timeout)

Changes:
  head/security/libgcrypt/Makefile
  head/security/libgcrypt/files/extra-patch-configure
Comment 18 Kurt Jaeger freebsd_committer freebsd_triage 2014-09-02 20:48:57 UTC
Committed, thanks for your patience.
Comment 19 Kurt Jaeger freebsd_committer freebsd_triage 2014-09-03 04:30:08 UTC
Hint from tijl@: The patch removes 

.elif ${ARCH} == "amd64"

which leads to

CONFIGURE_ARGS+=        --disable-drng-support

for i386 (which is wasn't before).
Is that what you intended ? If so, why ?
Comment 20 Carlos J Puga Medina 2014-09-03 08:29:46 UTC
Created attachment 146721 [details]
re-add disable drng support on amd64

I removed it by mistake. Bump PORTREVISION to re-add it.
Comment 21 Carlos J Puga Medina 2014-09-03 08:45:49 UTC
Created attachment 146723 [details]
re-add disable drng support on amd64
Comment 22 Carlos J Puga Medina 2014-09-03 08:49:47 UTC
Created attachment 146724 [details]
re-add disable drng support on amd64
Comment 23 Carlos J Puga Medina 2014-09-03 09:15:54 UTC
Indeed --disable-drng-support is only applied on amd64. Both before and after modifying Makefile. Is it intended?

https://redports.org/buildarchive/20140903085200-19734/
Comment 24 Volodymyr Kostyrko 2014-09-03 12:01:40 UTC
That's because clang-in-world generates bytecode with RDRAND instructions. They don't work on AMD amd64.

The last version makes vpnc dump core on SIGILL for me.
Comment 25 Carlos J Puga Medina 2014-09-03 18:42:12 UTC
(In reply to arcade from comment #24)
> That's because clang-in-world generates bytecode with RDRAND instructions.
> They don't work on AMD amd64.
> 
> The last version makes vpnc dump core on SIGILL for me.

Fixes this patch your problem?

https://bugs.freebsd.org/bugzilla/attachment.cgi?id=146724
Comment 26 Carlos J Puga Medina 2014-09-03 18:44:01 UTC
(In reply to arcade from comment #24)
> That's because clang-in-world generates bytecode with RDRAND instructions.
> They don't work on AMD amd64.
> 
> The last version makes vpnc dump core on SIGILL for me.

Fixes this patch your problem?

https://bugs.freebsd.org/bugzilla/attachment.cgi?id=146724
Comment 27 Carlos J Puga Medina 2014-09-03 20:04:04 UTC
(In reply to Carlos Jacobo Puga Medina from comment #26)
> (In reply to arcade from comment #24)
> > That's because clang-in-world generates bytecode with RDRAND instructions.
> > They don't work on AMD amd64.
> > 
> > The last version makes vpnc dump core on SIGILL for me.
> 
> Fixes this patch your problem?
> 
> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=146724

I'm sorry, I clicked twice when I replied you :)
Comment 28 Volodymyr Kostyrko 2014-09-04 09:33:46 UTC
1. This is not a patch, this is whole Makefile.
2. Taking out bumping version to 1.6.2_5 this works for me. I mean this works:

--- Makefile    (revision 367239)
+++ Makefile    (working copy)
@@ -41,6 +41,10 @@
 CONFIGURE_ARGS+=       --disable-aesni-support
 .endif

+.elif ${ARCH} == "amd64"
+.if (${OSVERSION} < 900000)
+USE_GCC=       yes
+.endif
 CONFIGURE_ARGS+=       --disable-drng-support

 .endif
Comment 29 Terry Kennedy 2014-09-04 09:44:33 UTC
This would seem to be redundant, since we already have:

# Fix build without ASM on 8.x/amd64
.if ${OPSYS} == FreeBSD && ${ARCH} == "amd64" && ${OSVERSION} < 900000
USE_GCC=        any
EXTRA_PATCHES+= ${FILESDIR}/extra-patch-configure
.endif

The problem (how we got into this swamp in the first place) is that "USE_GCC= yes" wants to drag in gcc (currently gcc47) and its huge list of dependencies, just so a few assembly instructions not recognized by the base GCC in 8-STABLE (4.2.1) can be used.

"USE_GCC= any" permits the use of the base GCC. However, none of the --disable-foo knobs in configure to control assembly language are actually connected to anything useful, hence the need for extra-patch-configure to beat configure into submission.
Comment 30 Volodymyr Kostyrko 2014-09-04 09:53:36 UTC
What this patch actually does is moving "CONFIGURE_ARGS+= --disable-drng-support" from i386 to amd64.
Comment 31 Terry Kennedy 2014-09-04 09:58:06 UTC
Ok, as long as we end up with "USE_GCC= any" (instead of yes) on FreeBSD 8.x amd64.

Unless I'm missing something, bugzilla is pretty confusing because there doesn't seem to be any way to ask for either the complete, patched file or just the patch as of any comment that proposes a patch. Sometimes I get one, sometimes the other, and sometimes nothing...
Comment 32 Carlos J Puga Medina 2014-09-04 10:16:45 UTC
Created attachment 146774 [details]
libgcrypt-1.6.1_5.diff

Fix build without ASM on 8.x and relocate '--disable-drng-support' flag.
Comment 33 Carlos J Puga Medina 2014-09-04 10:43:37 UTC
Created attachment 146778 [details]
libgcrypt-1.6.1_5.diff
Comment 34 Terry Kennedy 2014-09-04 11:07:43 UTC
I'm not sure we're making progress here. Looks like the CONFIGURE_ARGS in this patch has a # commenting it out, and disable-drng-support is missing the -- at the beginning.
Comment 35 Carlos J Puga Medina 2014-09-04 11:17:38 UTC
Created attachment 146779 [details]
libgcrypt-1.6.1_5.diff

Thanks, it was fixed.
Comment 36 Kurt Jaeger freebsd_committer freebsd_triage 2014-09-04 17:24:40 UTC
(In reply to Carlos Jacobo Puga Medina from comment #35)
> Created attachment 146779 [details]
> libgcrypt-1.6.1_5.diff
> 
> Thanks, it was fixed.

http://people.freebsd.org/~pi/logs/security__libgcrypt-10a-1409850078.txt
http://people.freebsd.org/~pi/logs/security__libgcrypt-91a-1409850078.txt
http://people.freebsd.org/~pi/logs/security__libgcrypt-84i-1409850078.txt

Builds. Tested with vpnc on AMD based amd64 CPU with 10.0p7, works.

So I'm committing this.
Comment 37 commit-hook freebsd_committer freebsd_triage 2014-09-04 17:29:04 UTC
A commit references this bug:

Author: pi
Date: Thu Sep  4 17:28:35 UTC 2014
New revision: 367293
URL: http://svnweb.freebsd.org/changeset/ports/367293

Log:
  security/libgcrypt: fix build with GCC on 8.x/amd64, 2nd attempt

  Thanks to tijl@ for spotting the Makefile bug.

  PR:		192555
  Submitted by:	Carlos Jacobo Puga Medina <cpm@fbsd.es>
  Approved by:	maintainer (timeout)

Changes:
  head/security/libgcrypt/Makefile