Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Set more sensible -O optimization on FreeBSD #16357

Closed
p5pRT opened this issue Jan 10, 2018 · 12 comments
Closed

[PATCH] Set more sensible -O optimization on FreeBSD #16357

p5pRT opened this issue Jan 10, 2018 · 12 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Jan 10, 2018

Migrated from rt.perl.org#132704 (status was 'resolved')

Searchable as RT132704$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jan 10, 2018

From @tomhukins

Created by @tomhukins

The attached patch sets a more sensible, standard optimization flag on
FreeBSD. Other platforms use a similar value to build perl, as does
FreeBSD's ports system.

Perl Info

Flags:
    category=install
    severity=low
    Type=Patch
    PatchStatus=HasPatch

Site configuration information for perl 5.24.1:

Configured by perl at Wed Oct 12 21:42:09 UTC 2016.

Summary of my perl5 (revision 5 version 24 subversion 1) configuration:
   
  Platform:
    osname=freebsd, osvers=9.3-release-p52, archname=amd64-freebsd-thread-multi
    uname='freebsd 93amd64-default-job-01 9.3-release-p52 freebsd 9.3-release-p52 amd64 '
    config_args='-sde -Dprefix=/usr/local -Dlibperl=libperl.so.5.24.1 -Darchlib=/usr/local/lib/perl5/5.24/mach -Dprivlib=/usr/local/lib/perl5/5.24 -Dman3dir=/usr/local/lib/perl5/5.24/perl/man/man3 -Dman1dir=/usr/local/lib/perl5/5.24/perl/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/mach/5.24 -Dsitelib=/usr/local/lib/perl5/site_perl -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/site_perl/man/man3 -Dsiteman1dir=/usr/local/lib/perl5/site_perl/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dusenm=n -Dcc=cc -Duseshrplib -Dinc_version_list=none -Dcf_by=perl -Dcf_email=perl@FreeBSD.org -Dcf_time=Wed Oct 12 21:42:09 UTC 2016 -Alddlflags=-L/wrkdirs/usr/ports/lang/perl5.24/work/perl-5.24.1-RC4 -L/usr/local/lib/perl5/5.24/mach/CORE -lperl -Dshrpldflags=$(LDDLFLAGS:N-L/wrkdirs/usr/ports/lang/perl5.24/work/perl-5.24.1-RC4:N-L/usr/local/lib/perl5/5.24/mach/CORE:N-lperl)
-Wl,-soname,$(LIBPERL:R) -Doptimize=-O2 -pipe -fstack-protector -fno-strict-aliasing -Ui_gdbm -Dusemultiplicity=y -Duse64bitint -Dusethreads=y -Dusemymalloc=n -Uusedtrace'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_FORTIFY_SOURCE=2',
    optimize='-O2 -pipe -fstack-protector -fno-strict-aliasing',
    cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.2.1 20070831 patched [FreeBSD]', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-lpthread -Wl,-E  -fstack-protector -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib /usr/include/gcc/4.2 /usr/lib
    libs=-lpthread -lm -lcrypt -lutil
    perllibs=-lpthread -lm -lcrypt -lutil
    libc=, so=so, useshrplib=true, libperl=libperl.so.5.24.1
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='	-Wl,-R/usr/local/lib/perl5/5.24/mach/CORE'
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib/perl5/5.24/mach/CORE -lperl -L/usr/local/lib -fstack-protector'

Locally applied patches:
    RC4


@INC for perl 5.24.1:
    lib
    /usr/local/lib/perl5/site_perl/mach/5.24
    /usr/local/lib/perl5/site_perl
    /usr/local/lib/perl5/5.24/mach
    /usr/local/lib/perl5/5.24


Environment for perl 5.24.1:
    HOME=/home/tom
    LANG=en_GB.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/tom/bin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/zsh

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jan 10, 2018

From @tomhukins

0001-Set-more-sensible-O-optimization-on-FreeBSD.patch
From 8dbb5231affc72b0d72f960351406bfdb0c3c371 Mon Sep 17 00:00:00 2001
From: Tom Hukins <tom@eborcom.com>
Date: Wed, 10 Jan 2018 18:53:24 +0000
Subject: [PATCH] Set more sensible -O optimization on FreeBSD

FreeBSD's /usr/share/mk/sys.mk specifies -O2 for architectures other
than arm and mips.  By default, compile perl with the same optimization
levels.
---
 hints/freebsd.sh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hints/freebsd.sh b/hints/freebsd.sh
index 5d69dee0eb..07eab0e252 100644
--- a/hints/freebsd.sh
+++ b/hints/freebsd.sh
@@ -343,3 +343,10 @@ case "$cc" in
   ;;
 esac
 
+case `uname -p` in
+arm|mips)
+  ;;
+*)
+  test "$optimize" || optimize='-O2'
+  ;;
+esac
-- 
2.15.1

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jan 11, 2018

From mat@cpan.org

I don't think lagging behind what FreeBSD does is a great idea. It would probably be just as good to inherit CFLAGS set by the OS and or the user using something like​:

$ make -f /dev/null -V CFLAGS
-O2 -pipe

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jan 11, 2018

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jan 11, 2018

From mat@cpan.org

It would inherit the right value depending on the architecture being built​:

$ env MACHINE_ARCH=mips64 make -f /dev/null -V CFLAGS
-O -pipe -G0
$ env MACHINE_ARCH=aarch64 make -f /dev/null -V CFLAGS
-O2 -pipe

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jan 16, 2018

From @tonycoz

On Wed, 10 Jan 2018 11​:38​:50 -0800, tomhukins wrote​:

The attached patch sets a more sensible, standard optimization flag on
FreeBSD. Other platforms use a similar value to build perl, as does
FreeBSD's ports system.

Thanks, applied as 4d8d7a4.

Tony

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jan 16, 2018

@tonycoz - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jan 16, 2018

From @jkeenan

On Tue, 16 Jan 2018 05​:19​:05 GMT, tonyc wrote​:

On Wed, 10 Jan 2018 11​:38​:50 -0800, tomhukins wrote​:

The attached patch sets a more sensible, standard optimization flag on
FreeBSD. Other platforms use a similar value to build perl, as does
FreeBSD's ports system.

Thanks, applied as 4d8d7a4.

Tony

Tony, can you elaborate a bit more on why you applied this patch despite the objection of the Perl maintainer for FreeBSD?

I'm not saying Mat is definitely correct, but I think his statements should be addressed.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jan 16, 2018

From @tomhukins

On Thu, Jan 11, 2018 at 05​:30​:13AM -0800, Mathieu Arnold via RT wrote​:

I don't think lagging behind what FreeBSD does is a great idea.

I agree there's scope for future improvement. However, reusing the
approach from other hints/*.sh files seems an improvement over the old
behaviour of building with -O everywhere.

Tom

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jan 23, 2018

From @tonycoz

On Tue, 16 Jan 2018 05​:14​:47 -0800, jkeenan wrote​:

On Tue, 16 Jan 2018 05​:19​:05 GMT, tonyc wrote​:

On Wed, 10 Jan 2018 11​:38​:50 -0800, tomhukins wrote​:

The attached patch sets a more sensible, standard optimization flag
on
FreeBSD. Other platforms use a similar value to build perl, as
does
FreeBSD's ports system.

Thanks, applied as 4d8d7a4.

Tony

Tony, can you elaborate a bit more on why you applied this patch
despite the objection of the Perl maintainer for FreeBSD?

I'm not saying Mat is definitely correct, but I think his statements
should be addressed.

I wasn't aware he was the FreeBSD maintainer.

In general we don't have Configure inherit from the environment, though someone building perl can certain do that by passing "-Dccflags=$CFLAGS" or similar on the Configure command line.

Tony

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jun 23, 2018

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release yesterday of Perl 5.28.0, this and 185 other issues have been
resolved.

Perl 5.28.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.28.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jun 23, 2018

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant