Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAKUDO_NO_PRECOMPILATION breaks NativeCall #5333

Closed
hythm7 opened this issue Aug 5, 2023 · 3 comments · Fixed by #5334
Closed

RAKUDO_NO_PRECOMPILATION breaks NativeCall #5333

hythm7 opened this issue Aug 5, 2023 · 3 comments · Fixed by #5334

Comments

@hythm7
Copy link

hythm7 commented Aug 5, 2023

The Problem

RAKUDO_NO_PRECOMPILATION=1 raku -e 'use NativeCall; sub some-sub() is native { * }; some-sub()'

Cannot resolve caller protect(Lock:U: Block:D); none of these signatures matches:
    (Lock:D: &code, *%_)
  in method setup at /home/hythm/.rakubrew/versions/moar-HEAD-HEAD-HEAD/install/share/perl6/core/sources/F94951DDD79BC6D66D51EE8FADFB5E769D00AFF9 line 296
  in method setup at /home/hythm/.rakubrew/versions/moar-HEAD-HEAD-HEAD/install/share/perl6/core/sources/F94951DDD79BC6D66D51EE8FADFB5E769D00AFF9 line 366
  in sub raku-nativecall at /home/hythm/.rakubrew/versions/moar-HEAD-HEAD-HEAD/install/share/perl6/core/sources/50A3E5C4DA760495F0E2D948EFE1C7A56E22BB27 line 46
  in block <unit> at -e line 1

Expected Behavior

Run some-sub if exists in native lib.

Actual Behavior

Error.

Environment

  • Operating system: Linux
  • Compiler version (perl6 -v or raku -v):
raku -v
Welcome to Rakudo™ v2023.06-193-g1d100f8e7.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2023.06-4-g75fe055c2.
@lizmat
Copy link
Contributor

lizmat commented Aug 5, 2023

@ugexe

@ugexe
Copy link
Member

ugexe commented Aug 5, 2023

I'm not sure what the underlying cause is, but this change results in no such error:

diff --git a/lib/NativeCall.rakumod b/lib/NativeCall.rakumod
index 3bc6197fc..48cbaa05d 100644
--- a/lib/NativeCall.rakumod
+++ b/lib/NativeCall.rakumod
@@ -255,8 +255,6 @@ sub guess-name-mangler(Routine $r, $name, Str $libname) {
     }
 }

-my Lock $setup-lock .= new;
-
 sub resolve-libname($libname) {
     CATCH { default { note $_ } }
     $libname.platform-library-name.Str
@@ -292,6 +290,8 @@ our role Native[Routine $r, $libname where Str|Callable|List|IO::Path|Distributi
         $!rettype
     }

+    my $setup-lock = Lock.new;
+
     method !setup() {
         $setup-lock.protect: {
             nqp::neverrepossess(self);

@ugexe
Copy link
Member

ugexe commented Aug 5, 2023

diff --git a/lib/NativeCall.rakumod b/lib/NativeCall.rakumod
index 3bc6197fc..bdbafe237 100644
--- a/lib/NativeCall.rakumod
+++ b/lib/NativeCall.rakumod
@@ -255,7 +255,7 @@ sub guess-name-mangler(Routine $r, $name, Str $libname) {
     }
 }

-my Lock $setup-lock .= new;
+BEGIN my Lock $setup-lock .= new;

 sub resolve-libname($libname) {
     CATCH { default { note $_ } }

This also works, but I'm unsure about using BEGIN with a lock like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants