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

undefined symbol: sysinfo #8038

Closed
trtiwari opened this issue Feb 8, 2019 · 4 comments
Closed

undefined symbol: sysinfo #8038

trtiwari opened this issue Feb 8, 2019 · 4 comments
Labels

Comments

@trtiwari
Copy link

trtiwari commented Feb 8, 2019

Hi,
I am trying to compile sysinfo with emscripten:

#include <emscripten/bind.h>
#include <sys/sysinfo.h>
int main()
{
    int days, hours, mins;
    struct sysinfo sys_info;

    if(sysinfo(&sys_info) != 0)
        perror("sysinfo");

    // Uptime
    days = sys_info.uptime / 86400;
    hours = (sys_info.uptime / 3600) - (days * 24);
    mins = (sys_info.uptime / 60) - (days * 1440) - (hours * 60);

    printf("Uptime: %ddays, %dhours, %dminutes, %ldseconds\n",
                      days, hours, mins, sys_info.uptime % 60);

    // Load Averages for 1,5 and 15 minutes
    printf("Load Avgs: 1min(%ld) 5min(%ld) 15min(%ld)\n",
          sys_info.loads[0], sys_info.loads[1], sys_info.loads[2]);

    // Total and free ram.
    printf("Total Ram: %ldk\tFree: %ldk\n", sys_info.totalram / 1024,
                                        sys_info.freeram / 1024);

    // Shared and buffered ram.
    printf("Shared Ram: %ldk\n", sys_info.sharedram / 1024);
    printf("Buffered Ram: %ldk\n", sys_info.bufferram / 1024);

    // Swap space
    printf("Total Swap: %ldk\tFree: %ldk\n", sys_info.totalswap / 1024,
                                           sys_info.freeswap / 1024);

    // Number of processes currently running.
    printf("Number of processes: %d\n", sys_info.procs);

    return 0;
}
EMSCRIPTEN_BINDINGS(my_module) {
	function("main",&main);
}

I compile it using:

emcc --bind -o wasm.js wasm.cpp

However, it always generates the following compilation error:

error: undefined symbol: sysinfo

However, I do see the sys/sysinfo.h header file at ~/emsdk/emscripten/1.38.26/system/include/libc/sys

I've noticed the same issue with many other libc header files - sys/personality.h, sys/quota.h, etc, where the header files do exist in emscripten but the compiler still generates undefined symbol errors.

Am I missing a compiler flag, or are these functions not supported?

@kripken
Copy link
Member

kripken commented Feb 8, 2019

We don't have full POSIX support, so stuff like sysinfo is just not yet implemented. For sysinfo specifically, we can't tell the actual system-level values of those things, like swap, so at best we could just report them as "0" probably.

@trtiwari
Copy link
Author

trtiwari commented Feb 8, 2019

I see, do you know if there is any way to get any sort of information on the device it is running on? Uname doesn't report everything too.
Thanks!

@kripken
Copy link
Member

kripken commented Feb 8, 2019

The question is what APIs are present. In node.js maybe they do give APIs that let you do this? On the web, which is most of our focus, it carefully sandboxes things so you can't tell stuff like swap space etc. (however, there might be APIs for specific things, like the number of cpus?)

@stale
Copy link

stale bot commented Feb 8, 2020

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Feb 8, 2020
@stale stale bot closed this as completed Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants