Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

App::perlbrew - Compiling Perl with thread support

by kcott (Chancellor)
on Feb 15, 2012 at 03:11 UTC ( #953822=perlquestion: print w/replies, xml ) Need Help??
kcott has asked for the wisdom of the Perl Monks concerning the following question:

G'day Monks,

I'm currently using Perl 5.14.2 via App::perlbrew. This version of Perl was not compiled with thread support - I'd like to change this. I've researched online documentation and formulated a plan of attack. I still have a few questions - see the individual steps below. I'd appreciate any other advice or comments.

The steps I'm planning to follow are:

1. Backup home directory and /usr/local/bin/. I believe this captures everything I'd need to restore the current setup. Is this correct?

2. Upgrade Perlbrew (I have v0.30; latest is v0.41).

perlbrew self-upgrade

3. Rename current Perlbrew Perl.

perlbrew alias create perl-5.14.2 perl-5.14.2_NO_THREADS

I note this has an -f option (i.e. perlbrew alias [-f] create <name> <alias>) but can't find any documentation as to its purpose. Can anyone tell me what it does?

4. Install Perl 5.14.2 with thread support.

perlbrew install -v perl-5.14.2 -Dusethreads --as perl-5.14.2_WITH +_THREADS

I've guessed the position of the -v option - am I right? I see other options for install documented in perlbrew. Do I need any of these?

5. Default to newly installed threaded Perl.

perlbrew switch perl-5.14.2_WITH_THREADS

6. Local tasks such as resetting my /usr/local/bin/perl symlink and testing existing applications still work.

Additional information which may be of use:

System: Apple Mac Pro running Mac OS X 10.7.3

Users: just me

$ perl -V Summary of my perl5 (revision 5 version 14 subversion 2) configuration +: Platform: osname=darwin, osvers=11.2.0, archname=darwin-2level uname='darwin ganymede 11.2.0 darwin kernel version 11.2.0: tue au +g 9 20:54:00 pdt 2011; root:xnu-1699.24.8~1release_x86_64 x86_64 ' config_args='-de -Dprefix=/Users/ken/perl5/perlbrew/perls/perl-5.1 +4.2' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=und +ef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing +-pipe -fstack-protector', optimize='-O3', cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fs +tack-protector' ccversion='', gccversion='4.2.1 (Based on Apple Inc. build 5658) ( +LLVM build 2336.1.00)', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +6 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-prot +ector' libpth=/usr/lib libs=-ldbm -ldl -lm -lutil -lc perllibs=-ldl -lm -lutil -lc libc=, so=dylib, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -fst +ack-protector' Characteristics of this binary (from libperl): Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP PERL_PRESERVE_IVUV USE_64_BIT_ALL USE_64_BIT_I +NT USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF Built under darwin Compiled at Oct 23 2011 21:06:51 %ENV: PERL5LIB="/Users/ken/local/lib/perl" PERLBREW_BASHRC_VERSION="0.30" PERLBREW_HOME="/Users/ken/.perlbrew" PERLBREW_PATH="/Users/ken/perl5/perlbrew/bin:/Users/ken/perl5/perl +brew/perls/perl-5.14.2/bin" PERLBREW_PERL="perl-5.14.2" PERLBREW_ROOT="/Users/ken/perl5/perlbrew" PERLBREW_VERSION="0.30" @INC: /Users/ken/local/lib/perl /Users/ken/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/d +arwin-2level /Users/ken/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2 /Users/ken/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/darwin-2lev +el /Users/ken/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2 . $ perlbrew list * perl-5.14.2 /opt/local/bin/perl (5.12.3) <--- MacPorts Perl /usr/bin/perl (5.12.3) <--- System Perl /usr/local/bin/perl (5.14.2) <--- Perlbrew Perl (symlink) $ ls -l /usr/local/bin/perl lrwxr-xr-x 1 root wheel 52 29 Oct 04:30 /usr/local/bin/perl -> /Use +rs/ken/perl5/perlbrew/perls/perl-5.14.2/bin/perl $ which perl /Users/ken/perl5/perlbrew/perls/perl-5.14.2/bin/perl

Update: s/-Duseithreads/-Dusethreads/ (thanks ikegami).

Update 2014: I wrote this post in early 2012. Beyond the immediate replies at that time, there've been responses in both 2013 and 2014 with additional and updated information. It's good to see this node is still being read (and, hopefully, found to be useful). Here's my latest perlbrew install command (for Perl v5.18.1):

$ perlbrew install -v +/perl-5.18.1.tar.gz -Dusethreads --as perl-5.18.1t

-- Ken

Replies are listed 'Best First'.
Re: App::perlbrew - Compiling Perl with thread support
by ikegami (Pope) on Feb 15, 2012 at 09:59 UTC

    perl-5.14.2_WITH_THREADS isn't listed as a recognized install. It looks like your install wasn't successful. Which is probably why you *didn't* switch to it as you claim. (You may have issued the command, but you weren't switched.)

    By the way, it's "-Dusethreads" (no "i").

    By the way, I call my installs 5.14.2 and 5.14.2t. No need for the leading "perl-", no need for some long descriptor.

      Thanks for taking the time to respond.

      I wrote "The steps I'm planning to follow are: ...". It looks like most, if not all, of your first paragraph is based on an assumption that I have completed (or at least attempted) these steps. I haven't performed any of the steps shown: the order of these steps and the details of any individual step may change based on responses to my post (in fact, thanks to your next point, one has changed already).

      By the way, it's "-Dusethreads" (no "i").

      Thanks for the correction. I've updated my post.

      I found instances of useithreads in perlthrtut, perl -V output and but I haven't seen usethreads anywhere. Could you point me to documentation where -D values are described?

      By the way, I call my installs 5.14.2 and 5.14.2t. No need for the leading "perl-", no need for some long descriptor.

      Thanks for the advice. The perl- prefix was based on usage throughout perlbrew. The suffixes are just a matter of personal preference.

      -- Ken

        It looks like most, if not all, of your first paragraph is based on an assumption that I have completed (or at least attempted) these steps.

        Oops yeah, thought you were listing the steps that lead to the "incorrect" output at the end. Aside from the "i" everything looks fine. (I've never created an alias before, so I'm just assuming there.)

        See the INSTALL file in the root directory of the Perl distribution for info on common configuration items. You can find the distributions on CPAN: perl. (The other monk gave a link to the very very latest version of the file, which might not be accurate for the version of Perl you are installing.)

        Some tweaks aren't documented, though. You'd only know it's even possible to change them by looking at the code itself, though. e.g. I use -DPERL_SUB_DEPTH_WARN=1000 to reduce the risk of warnings when dealing with deep trees.

        My perlbrew install wrapper:

        #!/usr/bin/env perl # install_perl 5.x.y # install_perl 5.x.yd Build with debug symbols (-g) # install_perl Build with thread support # install_perl 5.x.ydt Build with debug symbols (-g) and thread supp +ort use strict; use warnings; ( my ($build) = @ARGV ) == 1 or die; my $ccache = $ENV{CCACHE} || ( `which ccache` ? 'ccache' + : '' ); my $perlbrew_root = $ENV{PERLBREW_ROOT} || "$ENV{HOME}/perl5/perlbrew" +; unlink("$perlbrew_root/build.log"); my $version = $build; my $threaded = $version =~ s/t\z//; my $debug = $version =~ s/d\z//; my @args; push @args, "-v"; push @args, $version; push @args, "--as=$build"; push @args, "-DPERL_SUB_DEPTH_WARN=1000"; push @args, "-Dcc=$ccache cc" if $ccache; push @args, "-Doptimize=-g" if $debug; push @args, "-Dusethreads" if $threaded; exec("perlbrew", "install", @args) or die $!;

        (ccache is probably of no benefit, but I got in the habit of using it when bisecting.)

Re: App::perlbrew - Compiling Perl with thread support
by salva (Abbot) on Mar 01, 2014 at 12:49 UTC
    perlbrew install-multiple 5.14.2 --both=thread
    compiles both perl-5.14.2 and perl-5.14.2-thread-multi

      Thanks for the updated information, salva.

      The install-multiple command was not available when I originally wrote the OP. I'm not sure when it was introduced: the oldest perlbrew doco I can find on CPAN, perlbrew v0.56 (dated ~9 months after this thread was started), did not have it.

      It's good to see this 2-year old thread is still being read. I've added a short "Update 2014" to the OP.

      -- Ken

Re: App::perlbrew - Compiling Perl with thread support
by 7stud (Deacon) on Jan 12, 2013 at 10:53 UTC

    Here is perlbrew(0.58) help, section "install":

        install options perl-<version>
        install options <version>
            Build and install the given version of perl.
            Version numbers usually look like "5.x.xx", or "perl-5.xx.x-RCx" for
            release candidates.
            The specified perl is downloaded from the offical CPAN website or
            from the mirror site configured before.
            To configure mirror site, invoke `mirror` command.
        install options perl-blead
        install options blead
            A special way to install the blead version of perl, which is
            downloaded from this specific URL regardless of mirror settings:
        install options /path/to/perl/git/checkout/dir
            Build and install from the given git checkout dir.
        install options /path/to/perl-5.14.0.tar.gz
            Build and install from the given archive file.
        install options
            Build and install from the given URL. Supported URL schemes are
            "http://", "https://", "ftp://" and "file://".
        Options for "install" command:
            -f --force     Force installation
            -j $n          Parallel buildng and testing. ex. C<perlbrew install -j 5 perl-5.14.2>
            -n --notest    Skip testing
               --as        Install the given version of perl by a name.
                           ex. C<perlbrew install perl-5.6.2 --as legacy-perl>
            -D,-U,-A       Switches passed to perl Configure script.
                           ex. C<perlbrew install perl-5.10.1 -D usemymalloc -U uselargefiles>
            --sitecustomize $filename
                           Specify a file to be installed as
        By default, all installations are configured after their name like this:
            sh Configure -de -Dprefix=$PERLBREW_ROOT/perls/<name>

    Therefore, the command to install perl 5.16.0 with thread support and to give that perl the name "perl-5.16.0t" should be this:

    $ perlbrew install --as perl-5.16.0t -Dusethreads perl-5.16.0

    And in fact, I tried that command on Mac OSX 10.6.8, and I was able to successfully install a perl named perl-5.16.0t:

    $ perlbrew list * perl-5.16.0 #this perl was already installed perl-5.16.0t #this is the new install $perlbrew use perl-5.16.0t $perlbrew list perl-5.16.0 * perl-5.16.0t

    And here's a test program:

    use strict; use warnings; use 5.012; use threads; use threads::shared; my $counter :shared; $counter = 1; my $name = 'Joe'; sub do_stuff { my $thread_id = shift; sleep rand 10; say "thread number $thread_id"; say "count: $counter"; $counter++; say $name; $name = "Cathy"; } my @threads; for my $thread_number (1..10) { push @threads, threads->create('do_stuff', $thread_number); } for (@threads) { $_->join; } --output:-- thread number 5 count: 1 Joe thread number 9 count: 2 Joe thread number 3 count: 3 Joe thread number 7 count: 4 Joe thread number 10 count: 5 Joe thread number 4 count: 6 Joe thread number 6 count: 7 Joe thread number 8 count: 8 Joe thread number 1 count: 9 Joe thread number 2 count: 10 Joe

    To set perl-5.16.0t as the default when you start up a shell:

    $ perlbrew switch perl-5.16.0t

    It's possible that the -f option for the perlbrew alias command is the same as for the install command. But in any case, options are optional--that is what the brackets around the option mean--so if you don't know what an option does, then don't use that option.

    perlbrew help also says this:

    Generic command options: -q --quiet Be quiet on informative output message. -v --verbose Tell me more about it.

    The -v option isn't used to specify the perl version, so you can omit it.

      Thanks for the info. This was actually resolved 11 months ago. The thread went to depth of Re^6 so perhaps you didn't see all the discussion.

      -- Ken

Re: App::perlbrew - Compiling Perl with thread support
by karlgoethebier (Monsignor) on Mar 01, 2014 at 11:46 UTC

      Thanks for the additional information, Karl.

      It's good to see this 2-year old thread is still being read. I've added a short "Update 2014" to the OP.

      -- Ken

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://953822]
Approved by ww
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2018-03-24 16:21 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (299 votes). Check out past polls.