F-Stack / f-stack

F-Stack is an user space network development kit with high performance based on DPDK, FreeBSD TCP/IP stack and coroutine API.
http://www.f-stack.org
Other
3.86k stars 896 forks source link

Error in nginx make #586

Open AbhirupaGit opened 3 years ago

AbhirupaGit commented 3 years ago

After building f-stack when i try to build the nginx app I get the following error

549 | gettimeofday(struct timeval tv, struct timezone tz) | ^~~~ In file included from src/event/modules/ngx_ff_module.c:73: /usr/include/x86_64-linux-gnu/sys/time.h:66:12: note: previous declaration of ‘gettimeofday’ was here 66 | extern int gettimeofday (struct timeval *restrict tv, | ^~~~ make[1]: [objs/Makefile:849: objs/src/event/modules/ngx_ff_module.o] Error 1 make[1]: Leaving directory '/data/f-stack/app/nginx-1.16.1' make: [Makefile:8: build] Error 2

vincentmli commented 3 years ago

@AbhirupaGit I could compile most recent f-stack and nginx fine on my ubuntu 18.04, maybe you could share more detail on what OS and version, and steps when you got the error?

rutvora commented 3 years ago

Hello, I am facing the same issue. I am running an Ubuntu Server 20.04 on a KVM. It is a fresh install, with no other configurations. Directly cloned f-stack repo and followed instructions. This happens on both master and dev branches.

elvisli commented 3 years ago

Have the same issue on Ubuntu20.04. comment out the function definition solves the issue:

//int //gettimeofday(struct timeval tv, struct timezone tz) //{ // if (unlikely(inited == 0)) { // return SYSCALL(gettimeofday)(tv, tz); // } // // return ff_gettimeofday(tv, tz); //}

jm-zh commented 2 years ago

I am facing the same issue. I commented out this function and ran into another problem: 124 | static int (real_gettimeofday)(struct timeval tv, struct timezone *tz); | ^~~~~ cc1: all warnings being treated as errors make[1]: [objs/Makefile:849: objs/src/event/modules/ngx_ff_module.o] Error 1 make[1]: Leaving directory '/data/f-stack/app/nginx-1.16.1' make: [Makefile:8: build] Error 2 I am running an Ubuntu Server 20.04 on a vmware.

AlexSilver9 commented 1 year ago

Same here on Amzon Linux 2022. Worked fine on Amazon Linux 2.

You need to change the method to match the new signature in modern system headers:

int
gettimeofday(struct timeval *tv, void *__restrict tzp)
{
    struct timezone *tz = (struct timezone *) tzp;
    if (unlikely(inited == 0)) {
        return SYSCALL(gettimeofday)(tv, tz);
    }

    return ff_gettimeofday(tv, tz);
}

From (glibc 2.31):

    The gettimeofday function no longer reports information about a
    system-wide time zone. This 4.2-BSD-era feature has been deprecated for
    many years, as it cannot handle the full complexity of the world's
    timezones, but hitherto we have supported it on a best-effort basis.
    Changes required to support 64-bit time_t on 32-bit architectures have
    made this no longer practical.

    As of this release, callers of gettimeofday with a non-null 'tzp' argument
    should expect to receive a 'struct timezone' whose tz_minuteswest and
    tz_dsttime fields are zero. (For efficiency reasons, this does not always
    happen on a few Linux-based ports. This will be corrected in a future
    release.)

    All callers should supply a null pointer for the 'tzp' argument to
    gettimeofday. For accurate information about the time zone associated
    with the current time, use the localtime function.

    gettimeofday itself is obsolescent according to POSIX. We have no plans
    to remove access to this function, but portable programs should consider
    using clock_gettime instead.
Jamlee commented 2 months ago

it will work. Example:

/*
 * It is need to modify the definition, such as Ubuntu 22.04 or later.
 *
 * int(struct timeval * restrict,  void * restrict)
 */
int
gettimeofday(struct timeval * tv,  void * tz)
{
    if (unlikely(inited == 0)) {
        return SYSCALL(gettimeofday)(tv, tz);
    }

    return ff_gettimeofday(tv, tz);
}