Search code examples
perlperlbrewplenv

How to pass compile options to perl using plenv or perlbrew


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?


Solution

  • 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).