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

Error when building on Mac OS X #128

Closed
kazzkiq opened this issue Mar 3, 2016 · 10 comments
Closed

Error when building on Mac OS X #128

kazzkiq opened this issue Mar 3, 2016 · 10 comments

Comments

@kazzkiq
Copy link

kazzkiq commented Mar 3, 2016

When I run the make command from readme.md tutorial, I get this message:

/Users/kazzkiq/lwan/common/lwan.c:660:25: warning: implicit declaration of
      function 'accept4' is invalid in C99 [-Wimplicit-function-declaration]
        int client_fd = accept4((int)main_socket, NULL, NULL, SOCK_NONBL...
                        ^
/Users/kazzkiq/lwan/common/lwan.c:660:63: error: use of undeclared identifier
      'SOCK_NONBLOCK'
        int client_fd = accept4((int)main_socket, NULL, NULL, SOCK_NONBL...
                                                              ^
1 warning and 1 error generated.
make[2]: *** [common/CMakeFiles/lwan-common.dir/lwan.c.o] Error 1
make[1]: *** [common/CMakeFiles/lwan-common.dir/all] Error 2
make: *** [all] Error 2

Cmake v 3.4.1
Python v 2.7.10

The commands I used to run LWAN were:

git clone git://github.com/lpereira/lwan
cd lwan
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make

Did I miss any step?

@lpereira
Copy link
Owner

lpereira commented Mar 3, 2016

Lwan is unfortunately not compatible with OS X. I don't own a Mac, so I can't support it myself.

@lpereira
Copy link
Owner

lpereira commented Mar 5, 2016

Help is appreciated to make it work on OS X, though. Could you please try changing the call to accept4() to a call to accept() (just omit the last parameter) and report if it works or not?

Lwan should build -- although it isn't working -- on FreeBSD, which OS X is quite similar to. So it shouldn't be too much work to at least get it building on a Mac.

@kazzkiq
Copy link
Author

kazzkiq commented Mar 6, 2016

@lpereira I've tried to replace accept4() by accept() and got this error:

[  2%] Built target generate_mime_types_table
Scanning dependencies of target lwan-common
[  5%] Building C object common/CMakeFiles/lwan-common.dir/lwan.c.o
[  7%] Building C object common/CMakeFiles/lwan-common.dir/lwan-cache.c.o
/Users/kazzkiq/lwan/common/lwan-cache.c:81:8: error: unknown type name
      'clockid_t'; did you mean 'clock_t'?
static clockid_t detect_fastest_monotonic_clock(void)
       ^~~~~~~~~
       clock_t
/usr/include/sys/_types/_clock_t.h:30:33: note: 'clock_t' declared here
typedef __darwin_clock_t        clock_t;
                                ^
/Users/kazzkiq/lwan/common/lwan-cache.c:89:12: error: use of undeclared
      identifier 'CLOCK_MONOTONIC'
    return CLOCK_MONOTONIC;
           ^
/Users/kazzkiq/lwan/common/lwan-cache.c:92:67: warning: unused parameter 'cache'
      [-Wunused-parameter]
static ALWAYS_INLINE void clock_monotonic_gettime(struct cache_t *cache,
                                                                  ^
1 warning and 2 errors generated.
make[2]: *** [common/CMakeFiles/lwan-common.dir/lwan-cache.c.o] Error 1
make[1]: *** [common/CMakeFiles/lwan-common.dir/all] Error 2
make: *** [all] Error 2

Doing some further research it seems OSX doesn't have POSIX clock_* implemented, that would explain those errors.

As I have a very basic knowledge on C development I can't argue about further solutions for this issue. But on an overlook it seems the errors happening on OSX are just due to different API implementations and thus should not be a big deal to fix in the future (hopefully).

@lampmanyao
Copy link
Contributor

I am working on this, except the coro_swapcontext() routine.

@lampmanyao
Copy link
Contributor

That's a lot of work to do. I can build lwan on OSX now. But I got a segment fault when I run lwan without lwan.conf and access 127.0.0.1:8080. Even it can't be debug with lldb.
That's another problem, I run lwan with the default lwan.conf, I got an errer: Error on config file "lwan.conf", line 21: Invalid section name or module not found: serve_files.
Anyway, I am still working on this. ;)

@lpereira
Copy link
Owner

Pretty nice, @lampmanyao! That looks like where I am while trying to run it under FreeBSD: it runs, but segfaults after a few requests. Sometimes it's the first request, sometimes it takes a few dozen requests.

Sometimes prints requests with an "UNKNOWN" method are printed, which is quite unexpected; are you seeing this as well?

@lampmanyao
Copy link
Contributor

@lpereira It is not the same problem. The segfaults i have fixed, but now, i got a Bus error (10) and all thread are stopped by signal SIGSTOP.

@lampmanyao
Copy link
Contributor

@lpereira it's the exactly segfault like you said. Do you figure it out?
@kazzkiq I will push the patch to my Resp, maybe you can solve this problem.

@lpereira
Copy link
Owner

I haven't had time to investigate any further, unfortunately. Please make a PR with the patch to build it on OS X, maybe someone will be able to take a shot at debugging this as well. Thanks again!

@lpereira
Copy link
Owner

I'm closing this issue as Lwan is building on OS X now. It also has a OS X build bot so I'm notified in case something breaks. Feel free to reopen the issue or create a new one.

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

No branches or pull requests

3 participants