Perl Inline C code inside nginx Perl module
Ondrej Jombik
jombik at platon.org
Fri Apr 13 00:40:17 UTC 2018
We have some proprietary code in C language, which we cannot convert
into Perl. We would like to use this C code in Perl nginx module. Code
runs well under Perl's Inline C.
However when I try to run Inline C code in nginx Perl module, it does
not work. Not only this code does not work, in fact no Inline C code
work inside Perl nginx environment.
For example, look at this very simple Perl module inlinetest.pm:
package inlinetest;
use strict;
use nginx;
$ENV{'PATH'} = '/bin/:/usr/bin/';
use Inline Config =>
DIRECTORY => '/tmp/';
use Inline "C" => <<'...';
void test_fnc(int num)
{
fprintf(stderr, "%d\n", num);
}
...
sub handler {
$request->send_http_header('text/html');
return OK;
}
1;
Related nginx configuration is pretty standard:
perl_modules /etc/nginx/perl/;
perl_require inlinetest.pm;
server {
listen 127.0.0.1:80;
location /auth {
perl inlinetest::handler;
}
}
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
nginx[20011]: make: *** [inlinetest_0cff.o] Error 1
nginx[20011]: A problem was encountered while attempting to compile and install your Inline
nginx[20011]: C code. The command that failed was:
nginx[20011]: "make > out.make 2>&1" with error code 2
nginx[20011]: The build directory was:
nginx[20011]: /tmp/build/inlinetest_0cff
nginx[20011]: To debug the problem, cd to the build directory, and inspect the output files.
nginx[20011]: at /etc/nginx/perl/inlinetest.pm line 10.
nginx[20011]: ...propagated at /usr/share/perl5/Inline/C.pm line 869.
nginx[20011]: BEGIN failed--compilation aborted at /etc/nginx/perl/inlinetest.pm line 10.
nginx[20011]: Compilation failed in require at (eval 1) line 1."
nginx[20011]: nginx: configuration file /etc/nginx/nginx.conf test failed
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has failed
Does anyone has any idea why it fails to run under nginx Perl?
--
Ondrej JOMBIK
Platon Technologies s.r.o., Hlavna 3, Sala SK-92701
+421222111321 - info at platon.net - http://platon.net
Read our latest blog:
https://blog.platon.sk/icann-sknic-tld-problemy/
My current location: Bratislava, Slovakia
My current timezone: +0100 GMT (CET)
(updated automatically)
More information about the nginx
mailing list