buzz-language / buzz

👨‍🚀 buzz, A small/lightweight statically typed scripting language
https://buzz-lang.dev
MIT License
1.22k stars 34 forks source link

not found: no file libstd.so #150

Closed xywf221 closed 1 year ago

xywf221 commented 1 year ago
environment: linux debian
buzz version : [0.2.0](https://github.com/buzz-language/buzz/releases/tag/0.2.0)

code :

import "std";

| 👨‍🚀 buzz is a simple unambiguous scripting language
object Person {
    str name,
    int age = 18,

    fun growUp() > int {
        this.age = this.age + 1;

        return this.age;
    }
}

fun main([str] args) > void {
    Person me = Person{
        name = "Giann",
        age = 36,
    };

    print("Hello I'm {me.name} and I'm {me.age}.");
}

error

root@dmls:/tmp/buzz-0.2.0-linux-x86_64# ./bin/buzz test.buzz 
std:4:58: Syntax error: External library `` not found:     no file `./libstd.so`
    no file `./std/src/libstd.so`
    no file `/usr/share/buzz/libstd.so`
    no file `/usr/share/buzz/std/src/libstd.so`
    no file `/usr/share/local/buzz/libstd.so`
    no file `/usr/share/local/buzz/std/src/libstd.so`
    no file `/tmp/buzz-0.2.0-linux-x86_64/lib/buzz/libstd.so`
    no file `/tmp/buzz-0.2.0-linux-x86_64/lib/buzz/std/src/libstd.so`

     3 | || @param message message printed if `condition` is false
     4 | export extern fun assert(bool condition, str message) > void;
                                                                ^
     5 | 
test.buzz:1:13: Syntax error: Could not compile import or import external dynamic library `std`
     1 | import "std";
                   ^
     2 | 
     3 | object Person {

but /tmp/buzz-0.2.0-linux-x86_64/lib/buzz/libstd.so this file exists

root@dmls:/tmp/buzz-0.2.0-linux-x86_64# ls /tmp/buzz-0.2.0-linux-x86_64/lib/buzz/libstd.so 
/tmp/buzz-0.2.0-linux-x86_64/lib/buzz/libstd.so
giann commented 1 year ago

This should definitely work. I'll try to reproduce.

In the meantime could you try to build buzz on the main branch yourself following those instructions and see if that solves the problem?

This commit I just pushed will maybe help us see what's going on.

xywf221 commented 1 year ago

I compile from this machine and it works fine, but when I package the compiled file and run it on another machine I get this problem

xywf221 commented 1 year ago

I found the cause of the problem. Here the std dependency was not found

root@VM-16-4-ubuntu:/tmp/buzz-test# ldd /tmp/buzz-test/lib/buzz/libstd.so
    linux-vdso.so.1 (0x00007fff08319000)
    /$LIB/libonion.so => /lib/x86_64-linux-gnu/libonion.so (0x00007f6c26c00000)
    libbuzz.so => /lib/libbuzz.so (0x00007f6c26a2e000)
    libos.so => not found
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6c26806000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f6c26d83000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f6c26d1f000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f6c26790000)
    libmimalloc.so.2 => /lib/x86_64-linux-gnu/libmimalloc.so.2 (0x00007f6c2670a000)

Check on the machine where it was compiled again

root@dmls:/tmp/buzz-test# ldd lib/buzz/libstd.so 
    linux-vdso.so.1 (0x00007ffe1d362000)
    libbuzz.so => /tmp/buzz/zig-cache/o/d21e7899da6ea71072e7dee90cb4c5ae/libbuzz.so (0x00007f4bd33c2000)
    libos.so => /tmp/buzz/zig-cache/o/30501b96cb97d5849e75a560d63f7b84/libos.so (0x00007f4bd327c000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4bd3000000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f4bd35e8000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f4bd2f8a000)
    libmimalloc.so.2 => /lib/x86_64-linux-gnu/libmimalloc.so.2 (0x00007f4bd2f04000)
  1. There is a problem with the location of the dependency so file
  2. If opening the so fails, it shouldn't tell you that the file doesn't exist.
giann commented 1 year ago

Thanks for this. I'll remove the linux binary from the release for now.

giann commented 1 year ago

Could you try again with the updated main branch? This commit should fix the issue

xywf221 commented 1 year ago

It's ready to run now