Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix breakage on MoarVM

MoarVM's open op does not handle writing to a pipe (openpipe does), but nqp-p
does not have openpipe. Since it is hard to conditionally use compile ops I
switched to using shell(), which just means that we have to write the C file
down first.
  • Loading branch information...
commit 4d10d4266ce8d17eb3750b302567dfcf0bf491ca 1 parent 9111883
@FROGGS authored
Showing with 17 additions and 13 deletions.
  1. +17 −13 lib/Inline/C.pm
View
30 lib/Inline/C.pm
@@ -11,26 +11,30 @@ has $!code = "#ifdef WIN32
#endif
$code";
has $!libname;
+has $!dll;
method postcircumfix:<( )>(Mu \args) {
unless $!setup {
$!setup = 1;
my $basename = IO::Spec.catfile( $*TMPDIR, 'inline' );
$!libname = $basename ~ "_" ~ $r.name;
- $!libname = $basename ~ 1000.rand while $!libname.IO.e;
- my $o = $*VM<config><o>;
- my $so = $*VM<config><load_ext>;
-
- my $cmd = "$*VM<config><cc> -c $*VM<config><cc_shared> $*VM<config><cc_o_out>$!libname$o $*VM<config><ccflags> -xc -";
- if my Mu $CC := nqp::open(nqp::unbox_s($cmd), nqp::unbox_s("wp")) or die $! {
- nqp::printfh($CC, nqp::unbox_s($!code));
- nqp::closefh($CC);
- my $l_line = "$*VM<config><ld> $*VM<config><ld_load_flags> $*VM<config><ldflags> " ~
- "$*VM<config><libs> $*VM<config><ld_out>$!libname$so $!libname$o";
- shell($l_line);
- }
+ $!libname = $basename ~ 1000.rand.Int while $!libname.IO.e;
+ my $cfg = $*VM.config;
+ my $o = $cfg<obj> // $cfg<o>;
+ $!dll = $cfg<dll> ?? $!libname.path.directory ~ '/' ~ $!libname.path.basename.fmt($cfg<dll>) !! $!libname ~ $cfg<load_ext>;
+ my $ccout = $cfg<ccout> // $cfg<cc_o_out>;
+ my $ccshared = $cfg<ccshared> // $cfg<cc_shared>;
+ my $cflags = $cfg<cflags> // $cfg<ccflags>;
+ my $ldshared = $cfg<ldshared> // $cfg<ld_load_flags>;
+ my $ldlibs = $cfg<ldlibs> // $cfg<libs>;
+ my $ldout = $cfg<ldout> // $cfg<ld_out>;
+
+ "$!libname.c".IO.spurt: $!code;
+
+ shell "$cfg<cc> -c $ccshared $ccout$!libname$o $cflags -xc $!libname.c";
+ shell "$cfg<ld> $ldshared $cfg<ldflags> $ldlibs $ldout$!dll $!libname$o";
}
- &trait_mod:<is>($r, native => $!libname);
+ &trait_mod:<is>($r, native => $!dll);
$r(|args);
}
Please sign in to comment.
Something went wrong with that request. Please try again.