How to pass compile options to perl using plenv or perlbrew

811 views Asked by At

I have one machine that runs Windows 10 with Bash on Ubuntu on Windows. It uses some kind of FUSE filesystem that has no proper hard link support.

Because of this, a typical perl compilation fails. If I want to compile, I need to do:

echo "dont_use_nlink='define'" >> Policy.sh
./Configure -des
make
make install

What I'd ideally want is to be able to use either perlbrew or plenv to manage my perls and pass the dont_use_nlink parameter to any perl I build. Is there any way to do this?

2

There are 2 answers

0
coffeetocode On BEST ANSWER

Fortunately, it looks like the underlying issue in Win10 WSL is fixed, and will be (hopefully) released soon.

As MichielB pointed out, -A or -D seem like they should accomplish this, but it appears from some of my testing that perl's Configure doesn't honor -A or -D arguments when -de is also passed (see "usage" in perl's metaconfig for the significance of those args). Despite clearly seeing properly formed -A and -D flags in the args list of the generated config.sh, the dont_use_nlink never gets added.

As it happens, perlbrew passes those as the defaults unless you use the special PERLBREW_CONFIGURE_FLAGS environment variable.

However, there is a workaround. You can use PERLBREW_CONFIGURE_FLAGS to use -f to pass our own configuration file. We can use the mostly-correct config.sh generated by a failed "perlbrew install" run, then tweak it and pass it in.

Steps:

  1. Run a perlbrew install that will fail, eg:

perlbrew install perl-5.24.0

  1. Copy the generated config.sh file somewhere for modification and reuse:

cp /home/USERNAME/perl5/perlbrew/build/perl-5.24.0/config.sh ~/config_dont_use_nlink.sh

  1. Edit the file to and insert dont_use_nlink='define'. If you're being tidy and filing it alphabetically, it'll go between dlsrc and doubleinfbytes:

dlsrc='dl_dlopen.xs' dont_use_nlink='define' doubleinfbytes='0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f'

  1. Run perlbrew install, but set an environment variable that will cause "-f" to be passed through to the new perl's Configure script:

PERLBREW_CONFIGURE_FLAGS="-de -f /home/USERNAME/config_dont_use_nlink.sh" perlbrew install perl-5.24.0

That compiles for me on a mostly-clean WSL on Win10 build 14393, and has nearly all tests pass (with the remainder looking like stuff with WSL bugs already filed).

1
dasgar On

I haven't looked at Windows 10 or the new bash shell for Windows, so I don't know how compatible that new Windows bash environment is with perlbrew or plenv.

An alternative approach would be to leverage versions of portable Strawberry Perl. A while back, David Farrell wrote berrybrew to mimic perlbrew on Windows using portable Strawberry Perl rather than compiling Perl from source code. He wrote a blog post about it and put his stuff out on GitHub (berrybrew). Later, Steve Bertrand wanted to add more functionality and eventually ended up forking the project. You can read more about it on his blog post and his forked project is out on GitHub (see here).

Unless you're needing/wanting to build Perl versions from source code, using berrybrew may provide you with the functionality that you're looking for.