Summary: | dev-libs/libgcrypt fails to compile with clang -O2, requesting -O0 | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Pengcheng Xu <i> |
Component: | Current packages | Assignee: | Kristian Fiskerstrand (RETIRED) <k_f> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | alonbl, bsd+disabled, crypto+disabled, jiegec, jstein, nigoro.dev, prefix |
Priority: | Normal | Keywords: | UPSTREAM |
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
URL: | https://dev.gnupg.org/T3293 | ||
See Also: |
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=220937 https://github.com/gentoo/gentoo/pull/7766 |
||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | |||
Bug Blocks: | 408963 | ||
Attachments: | build.log ffor libgcrypt |
Description
Pengcheng Xu
2017-08-31 01:35:11 UTC
(In reply to i from comment #0) > Created attachment 491126 [details] > build.log ffor libgcrypt > > I'm using the default -O2. With GCC the package builds fine, but not with > clang. If I set CFLAGS="-O0 -pipe" in /etc/portage/env explicitly for this > package it builds successfully with clang. On first look this seems like an issue that should be resolved with upstream on https://dev.gnupg.org . Libgcrypt uses a gcc pragma that clang doesn't know to force O0 /var/tmp/portage/dev-libs/libgcrypt-1.8.1/work/libgcrypt-1.8.1/random/jitterentropy-base.c:53:13: warning: unknown pragma ignored [-Wunknown-pragmas] #pragma GCC optimize ("O0") and then asserts /var/tmp/portage/dev-libs/libgcrypt-1.8.1/work/libgcrypt-1.8.1/random/jitterentropy-base.c:60:4: error: "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy-base.c." #error "The CPU Jitter random number generator must not be compiled with optimizations. See documentation. Use the compiler switch -O0 for compiling jitterentropy-base.c." ^ 1 warning and 1 error generated. So the behavior is exactly as upstream intends when trying to use -02 for this snippet of code. (In reply to Kristian Fiskerstrand from comment #1) > (In reply to i from comment #0) > > Created attachment 491126 [details] > > build.log ffor libgcrypt > > > > I'm using the default -O2. With GCC the package builds fine, but not with > > clang. If I set CFLAGS="-O0 -pipe" in /etc/portage/env explicitly for this > > package it builds successfully with clang. > > On first look this seems like an issue that should be resolved with upstream > on https://dev.gnupg.org . > > Libgcrypt uses a gcc pragma that clang doesn't know to force O0 > /var/tmp/portage/dev-libs/libgcrypt-1.8.1/work/libgcrypt-1.8.1/random/ > jitterentropy-base.c:53:13: warning: unknown pragma ignored > [-Wunknown-pragmas] > #pragma GCC optimize ("O0") fwiw, a viable alternative to using this pragma for clang might be the optnone function attribute, iirc gcc's equivalent is optimize( 0 ) since 4.4 if wanting consistency. Would in any case require a fallback to the pragma behavior for older gcc versions. But downstream is not the place to do this, as messing with the rng is scary enough and validation of the output is necessary. This issue is already reported upstream at https://dev.gnupg.org/T3293 and this https://dev.gnupg.org/T1431 *** Bug 640468 has been marked as a duplicate of this bug. *** -fhenious-gnu-extensions doesn't work, so how about a tc-is-clang && replace-flags -O* -O0 for the time being in src_configure? This works for me. (cc-ing relevant teams) (In reply to Fabian Groffen from comment #6) > -fhenious-gnu-extensions doesn't work, so how about a > tc-is-clang && replace-flags -O* -O0 > for the time being in src_configure? This works for me. Why not provide a patch upstream with the necessary changes to make it work with clang c.f comment 2? I have nothing against that, but as I don't have time to look into that (I have no idea what needs to be done, this is just a clumpsy workaround that unbreaks this package, which is a good and cheap tradeoff between user seeing a package that doesn't compile and user not getting as much optimisation he/she asked for. Upstream supports an option '--enable-O-flag-mangling', configure-time. The only thing it do - it disables '-O*' (just seds it out) for sensitive places (rng, cipher), but it's explicitly disabled in our ebuild. (In reply to Vladimir Smirnov from comment #10) > Upstream supports an option '--enable-O-flag-mangling', configure-time. The > only thing it do - it disables '-O*' (just seds it out) for sensitive places > (rng, cipher), but it's explicitly disabled in our ebuild. That idea I like :) I've added a use-flag for it instead of hardcoding the disable in 1.8.2-r1 The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=09bbba541c60d161e6c164312372cddb9d04f6c7 commit 09bbba541c60d161e6c164312372cddb9d04f6c7 Author: Kristian Fiskerstrand <k_f@gentoo.org> AuthorDate: 2018-01-13 12:58:54 +0000 Commit: Kristian Fiskerstrand <k_f@gentoo.org> CommitDate: 2018-01-13 12:59:46 +0000 dev-libs/libgcrypt: Add use-flag for o-flag-mangling Bug: https://bugs.gentoo.org/629410 Package-Manager: Portage-2.3.13, Repoman-2.3.3 dev-libs/libgcrypt/libgcrypt-1.8.2-r1.ebuild | 77 ++++++++++++++++++++++++++++ dev-libs/libgcrypt/metadata.xml | 3 ++ 2 files changed, 80 insertions(+)} (In reply to Larry the Git Cow from comment #12) > The bug has been referenced in the following commit(s): > > https://gitweb.gentoo.org/repo/gentoo.git/commit/ > ?id=09bbba541c60d161e6c164312372cddb9d04f6c7 > > commit 09bbba541c60d161e6c164312372cddb9d04f6c7 > Author: Kristian Fiskerstrand <k_f@gentoo.org> > AuthorDate: 2018-01-13 12:58:54 +0000 > Commit: Kristian Fiskerstrand <k_f@gentoo.org> > CommitDate: 2018-01-13 12:59:46 +0000 > > dev-libs/libgcrypt: Add use-flag for o-flag-mangling > > Bug: https://bugs.gentoo.org/629410 > > Package-Manager: Portage-2.3.13, Repoman-2.3.3 > > dev-libs/libgcrypt/libgcrypt-1.8.2-r1.ebuild | 77 > ++++++++++++++++++++++++++++ > dev-libs/libgcrypt/metadata.xml | 3 ++ > 2 files changed, 80 insertions(+)} @grobian, can you sync prefix, please? On Darwin I still only see 1.8.1. Maybe dropping the prefix version would be enough. The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=4d94d5305bd45ff7d8524603500aef9918b52ca8 commit 4d94d5305bd45ff7d8524603500aef9918b52ca8 Author: Fabian Groffen <grobian@gentoo.org> AuthorDate: 2018-03-13 19:31:57 +0000 Commit: Fabian Groffen <grobian@gentoo.org> CommitDate: 2018-03-13 19:31:57 +0000 dev-libs/libgcrypt: sync, bug #629410 Bug: https://bugs.gentoo.org/629410 Package-Manager: Portage-2.3.18-prefix, Repoman-2.3.6 dev-libs/libgcrypt/Manifest | 22 +------ dev-libs/libgcrypt/libgcrypt-1.8.2-r2.ebuild | 86 ++++++++++++++++++++++++++++ dev-libs/libgcrypt/metadata.xml | 11 ++-- 3 files changed, 95 insertions(+), 24 deletions(-)} Thanks! Works for me on prefix standalone (Linux) and on High Sierra. Closing. The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0821fda75de8ca5548e1b9f5f055c96047f14e6f commit 0821fda75de8ca5548e1b9f5f055c96047f14e6f Author: Yuta Satoh <nigoro.dev@gmail.com> AuthorDate: 2018-04-01 12:32:33 +0000 Commit: Patrice Clement <monsieurp@gentoo.org> CommitDate: 2018-04-11 22:47:19 +0000 profiles/arch/amd64-fbsd/clang/package.use.force: add dev-libs/libgcrypt. If CC=clang, it requires the o-flag-munging flag to pass a compile phase. Bug: https://bugs.gentoo.org/629410 Closes: https://github.com/gentoo/gentoo/pull/7766 profiles/arch/amd64-fbsd/clang/package.use.force | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)} The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=eadc4f710b6783d509cb6d9b2b5b475069e16391 commit eadc4f710b6783d509cb6d9b2b5b475069e16391 Author: Mike Gilbert <floppym@gentoo.org> AuthorDate: 2022-04-16 19:32:25 +0000 Commit: Mike Gilbert <floppym@gentoo.org> CommitDate: 2022-04-16 19:34:26 +0000 dev-libs/libgcrypt: always enable O-flag-munging Exposing this as a USE flag is mostly pointless, and results in silly bug reports from users who disable it by accident. Users can disable it using EXTRA_ECONF if so desired. Bug: https://bugs.gentoo.org/629410 Bug: https://bugs.gentoo.org/707330 Closes: https://bugs.gentoo.org/838472 Signed-off-by: Mike Gilbert <floppym@gentoo.org> dev-libs/libgcrypt/libgcrypt-1.10.1.ebuild | 3 +-- dev-libs/libgcrypt/libgcrypt-1.8.8.ebuild | 5 ++--- dev-libs/libgcrypt/libgcrypt-1.8.9.ebuild | 3 +-- dev-libs/libgcrypt/libgcrypt-1.9.4-r1.ebuild | 3 +-- dev-libs/libgcrypt/metadata.xml | 1 - 5 files changed, 5 insertions(+), 10 deletions(-) |