Perl Inline C code inside nginx Perl module
Maxim Dounin
mdounin at mdounin.ru
Mon Apr 16 12:28:59 UTC 2018
Hello!
On Sun, Apr 15, 2018 at 07:01:42PM +0200, Ondrej Jombik wrote:
> On Fri, 13 Apr 2018, Maxim Dounin wrote:
>
> >> As you can see in my example, I am not even using or calling test_fnc()
> >> yet. But Perl code simply fails on startup with this error message:
> >>
> >> -- Unit nginx.service has begun starting up.
> >> nginx[20011]: nginx: [emerg] require_pv("inlinetest.pm") failed: "Running Mkbootstrap for inlinetest_0cff
> >> nginx[20011]: chmod 644 "inlinetest_0cff.bs"
> >> nginx[20011]: "/usr/bin/perl" "/usr/share/perl/5.24/ExtUtils/xsubpp" -typemap "/usr/share/perl/5.24/ExtUt
> >> nginx[20011]: x86_64-linux-gnu-gcc -c -I"/" -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-alias
> >> nginx[20011]: x86_64-linux-gnu-gcc: error trying to exec 'cc1': execvp: No such file or directory
> >> nginx[20011]: Makefile:332: recipe for target 'inlinetest_0cff.o' failed
> >
> > The problem is that your PATH is empty when relevant compilation
> > happens. You try to set it in the code using "$ENV{'PATH'} =
> > ...", but it doesn't work as this happens _after_ "use Inline...",
> > because "use ..." operators are executed at compile time in Perl,
> > much like BEGIN{}.
> >
> > A simple fix would be to set PATH in a BEGIN{} block at compile
> > time:
> >
> > BEGIN { $ENV{'PATH'} = '/bin/:/usr/bin/'; }
> > use Inline ...
> >
> > Alternativel, you can use nginx "env" directive to set PATH or
> > preserve it from original environment, see http://nginx.org/r/env.
>
> Thanks Maxim, it worked like a charm.
> Your help is very appreciated!
>
> I prefer using BEGIN { $ENV{'PATH'} = ... } construction, because this
> will have scope for Perl module only, while nginx "env" directive would
> be nginx-wide. Is this assumption correct?
No. Changing process environment will change the whole process
environment, regardless of how you do it. But doing this in the
perl code might be the better option since it is closer to the
code which actually needs PATH set.
[...]
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx
mailing list