Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 512314 - net-libs/cyassl-2.9.4 injects CFLAGS: -g -O0 -funroll-loops -fomit-frame-pointer -fwrapv and maybe many more
Summary: net-libs/cyassl-2.9.4 injects CFLAGS: -g -O0 -funroll-loops -fomit-frame-poin...
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Anthony Basile
URL: https://github.com/cyassl/cyassl/issu...
Whiteboard:
Keywords: PATCH
Depends on:
Blocks: 495848
  Show dependency tree
 
Reported: 2014-06-03 19:45 UTC by Jeroen Roovers (RETIRED)
Modified: 2014-06-14 22:26 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log after ebuild cyassl-2.9.4.ebuild clean compile (build.log,124.01 KB, text/plain)
2014-06-08 16:48 UTC, Anthony Basile
Details
net-libs:cyassl-2.9.4:20140608-142658.log (net-libs:cyassl-2.9.4:20140608-142658.log,112.39 KB, text/plain)
2014-06-08 23:05 UTC, Jeroen Roovers (RETIRED)
Details
net-libs:cyassl-2.9.4-r1:20140613-210221.log.xz (net-libs:cyassl-2.9.4-r1:20140613-210221.log.xz,7.77 KB, application/x-xz)
2014-06-14 21:39 UTC, Jeroen Roovers (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeroen Roovers (RETIRED) gentoo-dev 2014-06-03 19:45:05 UTC
src_configure():

checking whether C compiler accepts -g... yes
checking whether C compiler accepts -ggdb... yes
checking whether C compiler accepts -O0... yes
...
   * C Flags:                    -g -ggdb -O0 -Wno-pragmas -Wall -Wno-strict-aliasing -Wextra -Wunknown-pragmas --param=ssp-buffer-size=1 -Waddress -Warray-bounds -Wbad-function-cast -Wchar-subscripts -Wcomment -Wfloat-equal -Wformat-security -Wformat=2 -Wmaybe-uninitialized -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wnormalized=id -Woverride-init -Wpointer-arith -Wpointer-sign -Wredundant-decls -Wshadow -Wsign-compare -Wstrict-overflow=1 -Wswitch-enum -Wundef -Wunused -Wunused-result -Wunused-variable -Wwrite-strings -fwrapv -fPIE -mschedule=8000 -march=2.0 -ggdb -Wall -O2 -pipe -Wno-comment


The other flags should be all right and CXXFLAGS is (strangely) unaffected.
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-03 19:50:02 UTC
Well, that should be an easy fix. All that ax_enable_debug does is add those compiler flags:

Index: cyassl-2.9.4.ebuild
===================================================================
RCS file: /var/cvsroot/gentoo-x86/net-libs/cyassl/cyassl-2.9.4.ebuild,v
retrieving revision 1.2
diff -u -B -r1.2 cyassl-2.9.4.ebuild
--- cyassl-2.9.4.ebuild 31 May 2014 13:12:54 -0000      1.2
+++ cyassl-2.9.4.ebuild 3 Jun 2014 19:48:55 -0000
@@ -18,7 +18,7 @@
 CRYPTO_OPTS="aes-gcm aes-ccm aes-ni blake2 camellia dsa ecc hc128 hkdf md2 md4 nullcipher psk leanpsk pkcs7 rabbit ripemd scep sha512 supportedcurves"
 CERT_OPTS="ocsp crl crl-monitor savesession savecert sessioncerts testcert"
 EXTRAS="atomicuser pkcallbacks sep maxfragment truncatedhmac tlsx"
-DEBUG="debug errorstrings memory test"
+DEBUG="errorstrings memory test"

 #Note: sniffer is broken at the configure.ac level.  Its not too important and we'll disable it for this release.
 #IUSE="-dtls examples extra fortress ipv6 httpd mcapi pwdbased sni sniffer static-libs threads zlib ${CACHE_SIZE} ${CRYPTO_OPTS} ${CERT_OPTS} ${EXTRAS} ${DEBUG}"
@@ -116,7 +116,6 @@
                $(use_enable truncatedhmac)         \
                $(use_enable tlsx)                  \
                                             \
-               $(use_enable debug)                 \
                $(use_enable errorstrings)          \
                $(use_enable memory)                \
                                                    \
Comment 2 Anthony Basile gentoo-dev 2014-06-04 14:02:53 UTC
I kept the USE=debug flag but fixed the behavior.  Apparently giving either --enable-debug or --disable-debug will add the flags.  If you simply don't sent it the flag, it doesn't add the debug flags.
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-04 14:28:08 UTC
(In reply to Anthony Basile from comment #2)
> I kept the USE=debug flag but fixed the behavior.  Apparently giving either
> --enable-debug or --disable-debug will add the flags.  If you simply don't
> sent it the flag, it doesn't add the debug flags.

That sounds like a common PEBKAC interpreting what AC_ARG_ENABLE actually does (where action-if-true is assumed to be the --enable-foo case, whereas $enableval ought to be evaluated instead). Upstream might like to be told.
Comment 4 Anthony Basile gentoo-dev 2014-06-04 15:15:14 UTC
(In reply to Jeroen Roovers from comment #3)
> (In reply to Anthony Basile from comment #2)
> > I kept the USE=debug flag but fixed the behavior.  Apparently giving either
> > --enable-debug or --disable-debug will add the flags.  If you simply don't
> > sent it the flag, it doesn't add the debug flags.
> 
> That sounds like a common PEBKAC interpreting what AC_ARG_ENABLE actually
> does (where action-if-true is assumed to be the --enable-foo case, whereas
> $enableval ought to be evaluated instead). Upstream might like to be told.

Yes, that's precisely what's up.  And I'm working on it.
Comment 5 Anthony Basile gentoo-dev 2014-06-04 20:19:30 UTC
(In reply to Anthony Basile from comment #4)
> Yes, that's precisely what's up.  And I'm working on it.


https://github.com/cyassl/cyassl/issues/85
Comment 6 Anthony Basile gentoo-dev 2014-06-05 22:34:34 UTC
(In reply to Anthony Basile from comment #5)
> (In reply to Anthony Basile from comment #4)
> > Yes, that's precisely what's up.  And I'm working on it.
> 
> 
> https://github.com/cyassl/cyassl/issues/85

Fixed upstream.
Comment 7 Anthony Basile gentoo-dev 2014-06-08 16:47:55 UTC
jer, how are you getting this?

CFLAGS+="-g -ggdb -O0 -funroll-loops -fomit-frame-pointer"


1) When I do ebuild cyassl-2.9.4.ebuild clean configure, I get the following...

   * Installation prefix:       /usr
   * System type:               pc-linux-gnu
   * Host CPU:                  x86_64
   * C Compiler:                x86_64-pc-linux-gnu-gcc
   * C Flags:                    -Wno-pragmas -Wall -Wno-strict-aliasing -Wextra -Wunknown-pragmas --param=ssp-buffer-size=1 -Waddress -Warray-bounds -Wbad-function-cast -Wchar-subscripts -Wcomment -Wfloat-equal -Wformat-security -Wformat=2 -Wmaybe-uninitialized -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wnormalized=id -Woverride-init -Wpointer-arith -Wpointer-sign -Wredundant-decls -Wshadow -Wsign-compare -Wstrict-overflow=1 -Wswitch-enum -Wundef -Wunused -Wunused-result -Wunused-variable -Wwrite-strings -fwrapv -fPIE -O3 -pipe -fstack-check
   * C++ Compiler:              x86_64-pc-linux-gnu-g++
   * C++ Flags:                 -O3 -pipe -fstack-check
   * CPP Flags:                  -fvisibility=hidden -DHAVE_LIBZ
   * LIB Flags:                  -z relro -z now 
   * Debug enabled:             no
   * Warnings as failure:       no
   * make -j:                   7
   * VCS checkout:              no


2) When I grep the build.log I don't see any -ggdb or -g.
Comment 8 Anthony Basile gentoo-dev 2014-06-08 16:48:57 UTC
Created attachment 378522 [details]
build.log after ebuild cyassl-2.9.4.ebuild clean compile
Comment 9 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-08 23:05:47 UTC
Created attachment 378542 [details]
net-libs:cyassl-2.9.4:20140608-142658.log
Comment 10 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-08 23:08:17 UTC
cyassl-2.9.4 # grep -E '(fomit|funroll)' configure.ac
OPTIMIZE_CFLAGS="-Os -fomit-frame-pointer"
OPTIMIZE_FAST_CFLAGS="-O2 -fomit-frame-pointer"
OPTIMIZE_HUGE_CFLAGS="-funroll-loops -DTFM_SMALL_SET -DTFM_HUGE_SET"
Comment 11 Anthony Basile gentoo-dev 2014-06-09 12:47:18 UTC
(In reply to Jeroen Roovers from comment #9)
> Created attachment 378542 [details]
> net-libs:cyassl-2.9.4:20140608-142658.log

In both logs I do see -funroll-loops -fomit-frame-pointer.  I don't see a major problem with either for these being the default since the user can override them with their own CFLAGS.

Only in your log do I see -ggdb.  How are you getting that.  Can I have the exact steps to reproduce because I just can't seem to hit it here.

Niether log has -O0 or -g.
Comment 12 Anthony Basile gentoo-dev 2014-06-09 12:58:38 UTC
Can other arche teams take a look at this.
Comment 13 Rick Farina (Zero_Chaos) gentoo-dev 2014-06-09 14:04:10 UTC
My actual cflags:

CFLAGS="-Os -pipe -march=native -frecord-gcc-switches"

Without USE=debug:

   * C Flags:                    -Wno-pragmas -Wall -Wno-strict-aliasing -Wextra -Wunknown-pragmas --param=ssp-buffer-size=1 -Waddress -Warray-bounds -Wbad-function-cast -Wchar-subscripts -Wcomment
 -Wfloat-equal -Wformat-security -Wformat=2 -Wmaybe-uninitialized -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wnormalized=id -Woverride-init -Wpointer-ari
th -Wpointer-sign -Wredundant-decls -Wshadow -Wsign-compare -Wstrict-overflow=1 -Wswitch-enum -Wundef -Wunused -Wunused-result -Wunused-variable -Wwrite-strings -fwrapv -fPIE -Os -pipe -march=native -frecord-gcc-switches


With USE=debug:

   * C Flags:                    -g -ggdb -O0 -Wno-pragmas -Wall -Wno-strict-aliasing -Wextra -Wunknown-pragmas --param=ssp-buffer-size=1 -Waddress -Warray-bounds -Wbad-function-cast -Wchar-subscripts -Wcomment -Wfloat-equal -Wformat-security -Wformat=2 -Wmaybe-uninitialized -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wnormalized=id -Woverride-init -Wpointer-arith -Wpointer-sign -Wredundant-decls -Wshadow -Wsign-compare -Wstrict-overflow=1 -Wswitch-enum -Wundef -Wunused -Wunused-result -Wunused-variable -Wwrite-strings -fwrapv -fPIE -Os -pipe -march=native -frecord-gcc-switches


A lot of cflags are being injected in here for sure, QA's official policy is that this doens't block stabilization of security bugs (but we would be happy if this is fixed)
Comment 14 Anthony Basile gentoo-dev 2014-06-09 14:16:42 UTC
(In reply to Rick Farina (Zero_Chaos) from comment #13) 
> A lot of cflags are being injected in here for sure, QA's official policy is
> that this doens't block stabilization of security bugs (but we would be
> happy if this is fixed)

Is the fix to remove just -funroll-loops -fomit-frame-pointer ?
Comment 15 Rick Farina (Zero_Chaos) gentoo-dev 2014-06-09 14:27:46 UTC
(In reply to Anthony Basile from comment #14)
> (In reply to Rick Farina (Zero_Chaos) from comment #13) 
> > A lot of cflags are being injected in here for sure, QA's official policy is
> > that this doens't block stabilization of security bugs (but we would be
> > happy if this is fixed)
> 
> Is the fix to remove just -funroll-loops -fomit-frame-pointer ?

Looks like it's injecting :

-Wno-pragmas -Wall -Wno-strict-aliasing -Wextra -Wunknown-pragmas --param=ssp-buffer-size=1 -Waddress -Warray-bounds -Wbad-function-cast -Wchar-subscripts -Wcomment
 -Wfloat-equal -Wformat-security -Wformat=2 -Wmaybe-uninitialized -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wnormalized=id -Woverride-init -Wpointer-ari
th -Wpointer-sign -Wredundant-decls -Wshadow -Wsign-compare -Wstrict-overflow=1 -Wswitch-enum -Wundef -Wunused -Wunused-result -Wunused-variable -Wwrite-strings -fwrapv -fPIE

so I'd personally say no, the fix is not just to remove -funrool-loops and -fomit-frame-pointer.

I see 34 extra cflagss, not 2.  Maybe some of them are desired or even required for cyassl, I wouldn't know, but there are definitely 34 extra cflags added that the user didn't request, and it would be cool to figure out why, and prevent that if possible.
Comment 16 Anthony Basile gentoo-dev 2014-06-09 15:08:00 UTC
(In reply to Rick Farina (Zero_Chaos) from comment #15)
> (In reply to Anthony Basile from comment #14)
> > (In reply to Rick Farina (Zero_Chaos) from comment #13) 
> > > A lot of cflags are being injected in here for sure, QA's official policy is
> > > that this doens't block stabilization of security bugs (but we would be
> > > happy if this is fixed)
> > 
> > Is the fix to remove just -funroll-loops -fomit-frame-pointer ?
> 
> Looks like it's injecting :
> 
> -Wno-pragmas -Wall -Wno-strict-aliasing -Wextra -Wunknown-pragmas
> --param=ssp-buffer-size=1 -Waddress -Warray-bounds -Wbad-function-cast
> -Wchar-subscripts -Wcomment
>  -Wfloat-equal -Wformat-security -Wformat=2 -Wmaybe-uninitialized
> -Wmissing-field-initializers -Wmissing-noreturn -Wmissing-prototypes
> -Wnested-externs -Wnormalized=id -Woverride-init -Wpointer-ari
> th -Wpointer-sign -Wredundant-decls -Wshadow -Wsign-compare
> -Wstrict-overflow=1 -Wswitch-enum -Wundef -Wunused -Wunused-result
> -Wunused-variable -Wwrite-strings -fwrapv -fPIE
> 
> so I'd personally say no, the fix is not just to remove -funrool-loops and
> -fomit-frame-pointer.
> 
> I see 34 extra cflagss, not 2.  Maybe some of them are desired or even
> required for cyassl, I wouldn't know, but there are definitely 34 extra
> cflags added that the user didn't request, and it would be cool to figure
> out why, and prevent that if possible.


Oh you mean the -W flags too?  These are compile time warnings, and shouldn't affect the final elfs.  For example -Wswitch-enum just warns if in there is no case for an enum, etc.   I know there's the issue of future proofing your code, ie, today's gcc warnings are tomorrows errors, so on upgrading gcc your code no longer compiles.  In practice, this doesn't happen that often, and may even be something you want.
Comment 17 Rick Farina (Zero_Chaos) gentoo-dev 2014-06-09 16:12:35 UTC
Yes, adding all those warnings isn't needed, and honestly it seems best to find where all that is added and remove it.

Also, as stated by multiple parties on irc, it is undesirable for a use flag to modify cflags.  if all USE=debug does is change the cflags then it's not needed at all.  We don't need things like -ggdb being injected, we all know if we want that or not.
Comment 18 Anthony Basile gentoo-dev 2014-06-09 16:39:51 UTC
(In reply to Rick Farina (Zero_Chaos) from comment #17)
> if all USE=debug does is change the cflags then it's not
> needed at all

that is not all it does
Comment 19 Anthony Basile gentoo-dev 2014-06-09 20:49:57 UTC
Can the teams please check cyassl-2.9.4-r1.  I've removed all the -W flags and all bug -fwrapv.  The latter can change the behavior of arithmetic and therefore the way crypto is done.  I also have some reservations about removing -fomit-frame-pointer on x86 since it does free up %ebp which, when hardening is used and -fstack-check, could lead to asm problems --- I tested and it isn't a problem when fastmath is off.

Also I will reintroduce the -W flags in the future under USE=debug.  There are numerous examples throughout the tree of this and it is a correct use of the flag.
Comment 20 Anthony Basile gentoo-dev 2014-06-09 20:51:01 UTC
(In reply to Anthony Basile from comment #19)
>   I've removed all the -W flags and all bug -fwrapv.  

That should read:

I've removed all the -W flags and the -f flags, except -fwrapv.
Comment 21 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-09 22:17:33 UTC
(In reply to Anthony Basile from comment #19)
> Can the teams please check cyassl-2.9.4-r1.  I've removed all the -W flags
> and all bug -fwrapv.  The latter can change the behavior of arithmetic and
> therefore the way crypto is done.  I also have some reservations about
> removing -fomit-frame-pointer on x86 since it does free up %ebp which, when
> hardening is used and -fstack-check, could lead to asm problems --- I tested
> and it isn't a problem when fastmath is off.

You should have kept the -W flags as they don't affect compiling.

> Also I will reintroduce the -W flags in the future under USE=debug.

Please don't. That's not what USE=debug should mean.

> There are numerous examples throughout the tree of this and it is a correct use of the flag.

No, it isn't. Those "numerous examples" are bugs that should be fixed.
Comment 22 Anthony Basile gentoo-dev 2014-06-09 23:17:58 UTC
(In reply to Jeroen Roovers from comment #21)
> (In reply to Anthony Basile from comment #19)
> > Can the teams please check cyassl-2.9.4-r1.  I've removed all the -W flags
> > and all bug -fwrapv.  The latter can change the behavior of arithmetic and
> > therefore the way crypto is done.  I also have some reservations about
> > removing -fomit-frame-pointer on x86 since it does free up %ebp which, when
> > hardening is used and -fstack-check, could lead to asm problems --- I tested
> > and it isn't a problem when fastmath is off.
> 
> You should have kept the -W flags as they don't affect compiling.
> 
> > Also I will reintroduce the -W flags in the future under USE=debug.
> 
> Please don't. That's not what USE=debug should mean.
> 
> > There are numerous examples throughout the tree of this and it is a correct use of the flag.
> 
> No, it isn't. Those "numerous examples" are bugs that should be fixed.

Is it a question of rutime debug vs build-time debug?  I'm trying to figure out why this is a bad move.

Anyhow, we can't have a blanket rule like USE flags can't modify CFLAGS because sometimes we must, eg USE=hardened might have to add -fPIC or the like.
Comment 23 Anthony Basile gentoo-dev 2014-06-10 10:46:20 UTC
Please reopen if you find more flag issues.
Comment 24 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-13 21:15:48 UTC
-funroll-loops -fomit-frame-pointer are still there.
Comment 25 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-13 21:23:19 UTC
diff -u configure.ac{.orig,}
--- configure.ac.orig   2014-06-13 23:19:14.491698529 +0200
+++ configure.ac        2014-06-13 23:22:26.868203760 +0200
@@ -96,10 +96,8 @@
 AM_PROG_CC_C_O
 LT_LIB_M

-OPTIMIZE_CFLAGS="-Os -fomit-frame-pointer"
-OPTIMIZE_FAST_CFLAGS="-O2 -fomit-frame-pointer"
-OPTIMIZE_HUGE_CFLAGS="-funroll-loops -DTFM_SMALL_SET -DTFM_HUGE_SET"
-DEBUG_CFLAGS="-g -DDEBUG -DDEBUG_CYASSL"
+OPTIMIZE_HUGE_CFLAGS="-DTFM_SMALL_SET -DTFM_HUGE_SET"
+DEBUG_CFLAGS="-DDEBUG -DDEBUG_CYASSL"

 thread_ls_on=no
 # Thread local storage
@@ -1611,7 +1609,6 @@
 esac

 # add user C_EXTRA_FLAGS back
-CFLAGS="-fwrapv $CFLAGS"
 OPTION_FLAGS="$AM_CFLAGS"

 CREATE_HEX_VERSION
Comment 26 Anthony Basile gentoo-dev 2014-06-13 21:42:22 UTC
(In reply to Jeroen Roovers from comment #25)
> diff -u configure.ac{.orig,}
> --- configure.ac.orig   2014-06-13 23:19:14.491698529 +0200
> +++ configure.ac        2014-06-13 23:22:26.868203760 +0200
> @@ -96,10 +96,8 @@
>  AM_PROG_CC_C_O
>  LT_LIB_M
> 
> -OPTIMIZE_CFLAGS="-Os -fomit-frame-pointer"
> -OPTIMIZE_FAST_CFLAGS="-O2 -fomit-frame-pointer"
> -OPTIMIZE_HUGE_CFLAGS="-funroll-loops -DTFM_SMALL_SET -DTFM_HUGE_SET"
> -DEBUG_CFLAGS="-g -DDEBUG -DDEBUG_CYASSL"
> +OPTIMIZE_HUGE_CFLAGS="-DTFM_SMALL_SET -DTFM_HUGE_SET"
> +DEBUG_CFLAGS="-DDEBUG -DDEBUG_CYASSL"
> 
>  thread_ls_on=no
>  # Thread local storage

Okay with these.  I will add this change in a bit.

> @@ -1611,7 +1609,6 @@
>  esac
> 
>  # add user C_EXTRA_FLAGS back
> -CFLAGS="-fwrapv $CFLAGS"
>  OPTION_FLAGS="$AM_CFLAGS"
> 
>  CREATE_HEX_VERSION

I added back -fwrapv.  I don't think we should remove it because it might change some crypt calculation in a corner case.
Comment 27 Anthony Basile gentoo-dev 2014-06-14 21:01:26 UTC
tree cleaning bug #495848
Comment 28 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-14 21:37:43 UTC
The problem is still there in -r1.
Comment 29 Jeroen Roovers (RETIRED) gentoo-dev 2014-06-14 21:39:01 UTC
Created attachment 378908 [details]
net-libs:cyassl-2.9.4-r1:20140613-210221.log.xz

(In reply to Anthony Basile from comment #27)
> tree cleaning bug #495848

What does that even mean?
Comment 30 Anthony Basile gentoo-dev 2014-06-14 22:26:22 UTC
(In reply to Jeroen Roovers from comment #29)
> Created attachment 378908 [details]
> net-libs:cyassl-2.9.4-r1:20140613-210221.log.xz
> 
> (In reply to Anthony Basile from comment #27)
> > tree cleaning bug #495848
> 
> What does that even mean?

# cat gentoo-x86/profiles/package.mask | grep -C 2 cyassl
# Anthony G. Basile <blueness@gentoo.org> (14 Jun 2014)
# Masked for removal in 30 days, bug #495848
net-libs/cyassl


It means that after other issues mgorny found, I decided this is not a reliable package to maintain.  Its going to be removed from the tree.  So this bug is either WONTFIX or maybe better OBSOLETE.