Bug 46329 - gnuplot compiled with -march=pentiumpro outputs broken PostScript
Summary: gnuplot compiled with -march=pentiumpro outputs broken PostScript
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: Greg Lewis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-12-17 14:50 UTC by Hidenori Ishikawa
Modified: 2003-06-16 21:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hidenori Ishikawa 2002-12-17 14:50:01 UTC
gnuplot port (ports/math/gnuplot) compiled with "-march=pentiumpro" on
FreeBSD 4.7-RELEASE environment (the system gcc-2.95.4 compiler)
outputs broken PostScript file.
Actually, the PostScript file itself is readable, but the scale factor
of hight becomes 0.050 where it should be 0.100 as width.
This is really due to COMPILER BUG when "-march=pentiumpro" is
enabled.

Fix: 

The responsible source code in gnuplot program is
gnuplot-3.7.2/term/post.trm
line 948-949 where
-- gnuplot-3.7.2/term/post.trm (line 944-952) --
	if (!ps_common_encap)
		fprintf(gpoutfile,"%%%%Page: %d %d\n",ps_page,ps_page);
	fprintf(gpoutfile,"gnudict begin\ngsave\n");
	fprintf(gpoutfile,"%d %d translate\n",ps_common_xoff, ps_common_yoff);
(here)	fprintf(gpoutfile,"%.3f %.3f scale\n", (ps_common_encap ? 0.5 : 1.0)/PS_SC,
	                                       (ps_common_encap ? 0.5 : 1.0)/PS_SC);
	if (!ps_common_portrait) {
		fprintf(gpoutfile,"90 rotate\n0 %d translate\n", (int)(-PS_YMAX));
	}
-- end --
The line pointed out with (here) should output "0.100, 0.100 scale\n" to
gpoutfile, when ps_common_encap == 1.
But due to compiler bug, the output becomes "0.050, 0.100 scale\n".
Since second and third argument of fprintf() is EXACTLLY THE SAME,
the output should be the same as well.
But somehow, evaluation of the parenthesis in second argument
(ps_common_encap ? 0.5 : 1.0) 
failes, hence produces broken output.
The squashed image is due to the scaling factor mismatch of height and 
width produced above.

The easiest workaround is to disable "-march=pentiumpro" option,
i.e. set NO_CPU_CFLAGS when compiling gnuplot port.

But, this is a compiler bug, so I think it is more important to
check the lexical analyzer of gcc on 4.7-RELEASE platform.
How-To-Repeat: Compile gnuplot port (ports/math/gnuplot) on FreeBSD 4.7-RELEASE
envrionment with "-march=pentiumpro" option, i.e. with something like
CPUTYPE=i686.

Execute following commands on gnuplot console.
-- from here --
set output "test.ps"
set term postscript
plot sin(x)
-- end --
Take a look at the output PostScript "test.ps" with some means.
The output should be squashed in a half height.
Comment 1 Ying-Chieh Liao freebsd_committer freebsd_triage 2003-01-02 09:08:16 UTC
Responsible Changed
From-To: freebsd-ports->chuckr

over to maintainer
Comment 2 Kris Kennaway freebsd_committer freebsd_triage 2003-06-08 01:33:38 UTC
Responsible Changed
From-To: chuckr->freebsd-ports-bugs

Chuck no longer maintains this port
Comment 3 Ying-Chieh Liao freebsd_committer freebsd_triage 2003-06-08 04:22:08 UTC
State Changed
From-To: open->feedback

still a problem in gnuplot 3.7.3 ? and with FreeBSD 4.8 ?
Comment 4 Greg Lewis freebsd_committer freebsd_triage 2003-06-09 22:54:39 UTC
Responsible Changed
From-To: freebsd-ports-bugs->glewis

I took maintainership of this port.
Comment 5 Greg Lewis freebsd_committer freebsd_triage 2003-06-16 21:15:15 UTC
State Changed
From-To: feedback->closed

Committed a patch, thanks!