Bug 76875 - security/cryptopp crashes if build with default optimization -O
Summary: security/cryptopp crashes if build with default optimization -O
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-30 23:30 UTC by Thomas Melzer
Modified: 2005-06-12 08:34 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Melzer 2005-01-30 23:30:23 UTC
Building security/cryptopp with the default compile options yields to 
to a build with 'g++ -O -pipe -march=pentium -fPIC -msse2 -pipe'.
Option -O optimizes for speed and size. This produces incorrect code with some encryption algoritmns and yield to crashes.

Fix: add the following patch (which supresses optimization) to the port and all tests succeed



.include <bsd.port.pre.mk>--0qPFhKTIr2jI8Dr9cT7Nqsm915TZXL5SUmKAUjiTyjiqVSqj
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- Makefile.orig       Sun Jan 30 14:05:17 2005
+++ Makefile    Mon Jan 31 00:24:57 2005
@@ -25,7 +25,7 @@
 EXTRACT_BEFORE_ARGS=   -aq
 USE_GMAKE=             yes
 MAKEFILE=              GNUmakefile
-CXXFLAGS+=             -fPIC
+CXXFLAGS+=             -fPIC -O0
How-To-Repeat: - build port
- run cryptest v
cryptes crashes with core dump after executing 
'BlumBlumShub validation suite running...' test
Comment 1 Xin LI 2005-02-01 02:24:08 UTC
Someone please commit this patch, thanks!

å¨ 2005-01-30æ¥ç 23:27 +0000ï¼Thomas Melzeråéï¼
> add the following patch (which supresses optimization) to the port and all tests succeed
> 
> --- Makefile.orig       Sun Jan 30 14:05:17 2005
> +++ Makefile    Mon Jan 31 00:24:57 2005
> @@ -25,7 +25,7 @@
>  EXTRACT_BEFORE_ARGS=   -aq
>  USE_GMAKE=             yes
>  MAKEFILE=              GNUmakefile
> -CXXFLAGS+=             -fPIC
> +CXXFLAGS+=             -fPIC -O0
> 
>  .include <bsd.port.pre.mk>


Cheers,
-- 
Xin LI <delphij delphij net>  http://www.delphij.net/
Comment 2 Pav Lucistnik freebsd_committer freebsd_triage 2005-02-01 09:08:35 UTC
Works fine for me.

Your output seems to contain -march=pentium which mine system don't emit
-- can you check without it? I think it's not there by default.

-- 
Pav Lucistnik <pav@oook.cz>
              <pav@FreeBSD.org>

Bento's Law: If It Can Break, It Will Break
Bento's Corollary: If It Can Break, Kris Can Send Mail About It
Comment 3 TMelzer 2005-02-01 12:51:07 UTC
I've tested the build by supressing the -march=pentium switch. 
The port build emits the same behaviour. Build with -O crash, build with -O0
cryptest runs fine.

Further investigation have shown where the compileswitches -O and
-march=pentium 
come from. In my /etc/make.conf i have the following 2 lines 

CPUTYPE=i586
CFLAGS= -O -pipe

I use CPUTYPE=i586 because my build machine is a Pentium4 2.8 GHz machine
and 
Several of my older servers have only pentium cpus. This line lead to
-march=pentium option.
CFLAGS is the supported maximum for buildworld and kernel.

If i comment out these settings cryptopp port is compiled with

-fPIC -msse2 -pipe

Cryptest runs as expected. But if you use the CFLAGS setting above 
You have to apply my patch as cryptest breaks.

So I think the save way will be to disable optimization explicit so
that optimazation settings in make.conf can not break the port.

Regards
-- Thomas
Comment 4 Patrick Li freebsd_committer freebsd_triage 2005-06-12 08:33:44 UTC
State Changed
From-To: open->closed

Committed, Thanks!