Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Tobias Leich authored

Showing 1 changed file with 17 additions and 13 deletions. Show diff stats Hide diff stats

  1. +17 13 lib/Inline/C.pm
30 lib/Inline/C.pm
@@ -11,26 +11,30 @@ has $!code = "#ifdef WIN32
11 11 #endif
12 12 $code";
13 13 has $!libname;
  14 +has $!dll;
14 15
15 16 method postcircumfix:<( )>(Mu \args) {
16 17 unless $!setup {
17 18 $!setup = 1;
18 19 my $basename = IO::Spec.catfile( $*TMPDIR, 'inline' );
19 20 $!libname = $basename ~ "_" ~ $r.name;
20   - $!libname = $basename ~ 1000.rand while $!libname.IO.e;
21   - my $o = $*VM<config><o>;
22   - my $so = $*VM<config><load_ext>;
23   -
24   - my $cmd = "$*VM<config><cc> -c $*VM<config><cc_shared> $*VM<config><cc_o_out>$!libname$o $*VM<config><ccflags> -xc -";
25   - if my Mu $CC := nqp::open(nqp::unbox_s($cmd), nqp::unbox_s("wp")) or die $! {
26   - nqp::printfh($CC, nqp::unbox_s($!code));
27   - nqp::closefh($CC);
28   - my $l_line = "$*VM<config><ld> $*VM<config><ld_load_flags> $*VM<config><ldflags> " ~
29   - "$*VM<config><libs> $*VM<config><ld_out>$!libname$so $!libname$o";
30   - shell($l_line);
31   - }
  21 + $!libname = $basename ~ 1000.rand.Int while $!libname.IO.e;
  22 + my $cfg = $*VM.config;
  23 + my $o = $cfg<obj> // $cfg<o>;
  24 + $!dll = $cfg<dll> ?? $!libname.path.directory ~ '/' ~ $!libname.path.basename.fmt($cfg<dll>) !! $!libname ~ $cfg<load_ext>;
  25 + my $ccout = $cfg<ccout> // $cfg<cc_o_out>;
  26 + my $ccshared = $cfg<ccshared> // $cfg<cc_shared>;
  27 + my $cflags = $cfg<cflags> // $cfg<ccflags>;
  28 + my $ldshared = $cfg<ldshared> // $cfg<ld_load_flags>;
  29 + my $ldlibs = $cfg<ldlibs> // $cfg<libs>;
  30 + my $ldout = $cfg<ldout> // $cfg<ld_out>;
  31 +
  32 + "$!libname.c".IO.spurt: $!code;
  33 +
  34 + shell "$cfg<cc> -c $ccshared $ccout$!libname$o $cflags -xc $!libname.c";
  35 + shell "$cfg<ld> $ldshared $cfg<ldflags> $ldlibs $ldout$!dll $!libname$o";
32 36 }
33 37
34   - &trait_mod:<is>($r, native => $!libname);
  38 + &trait_mod:<is>($r, native => $!dll);
35 39 $r(|args);
36 40 }

0 comments on commit 4d10d42

Please sign in to comment.
Something went wrong with that request. Please try again.