bliako has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monkees!

I need to compile perl from source with custom compiler living in /usr/local/gcc82 (with subdirs bin, include, lib etc.). The reason is that I am embedding CUDA code (which is C) via Inline::C which needs this specific compiler. And XS code must be compiled with same compiler as its perl. (Indeed I get segmentation fault when doing otherwise). So I need perl compiled with this specific compiler and I am doing this on Linux.

I prefer to let perlbrew do the compilation and installation. Is there a simple way to do it? Alternatively, I need to do it manually.

Replies are listed 'Best First'.
Re: Compile perl with custom compiler path, perlbrew solution preferred
by Fletch (Bishop) on Jun 13, 2024 at 20:12 UTC

    When doing this from vanilla source via hand you'd just pass -Dcc=/usr/local/gcc82/bin/gcc yadda yadda yadda. It looks like (cribbing from this SO answer) there's an PERLBREW_CONFIGURE_FLAGS environment variable you could add those settings to when you run perlbrew and that might do it.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      thank you. It worked as expected. It was prompting me to answer many questions and did not use the sane defaults as usual, I guess the presence of the FLAGS triggers this behaviour. I had to add -d to the FLAGS. And because another such perl existed, I also had to give it a different name:

      PERLBREW_CONFIGURE_FLAGS='-d -Dcc=/usr/local/gcc82/bin/gcc' perlbrew i +nstall 5.38.2 --as 5.38.2.gcc82

      And I can confirm that any C code embedded via Inline::C is compiled with the expected compiler.

Re: Compile perl with custom compiler path, perlbrew solution preferred
by cavac (Prior) on Jun 18, 2024 at 13:38 UTC