gwsystems / composite

A component-based OS
composite.seas.gwu.edu
185 stars 70 forks source link

musl compilation error: Need to define GNU source #295

Closed rskennedy closed 6 years ago

rskennedy commented 7 years ago

In attempting to compile DPDK with musl libc, we came across this compilation error (simplified) for various files:

/home/riley/clones/composite/src/components/lib/musl-1.1.11/bin/musl-gcc -nostdlib -nostdinc -I/home/riley/clones/dpdk/build/include -Werror -O3 -o eal.o -c /home/riley/clones/dpdk/lib/librte_eal/linuxapp/eal/eal.c
In file included from /home/riley/clones/dpdk/build/include/generic/rte_spinlock.h:50:0,
                 from /home/riley/clones/dpdk/build/include/rte_spinlock.h:41,
                 ...
                 from /home/riley/clones/dpdk/lib/librte_eal/linuxapp/eal/eal.c:62:
/home/riley/clones/dpdk/build/include/rte_lcore.h:54:2: error: unknown type name ‘cpu_set_t’
  typedef cpu_set_t rte_cpuset_t;

This error occurs because rte_lcore.h expects a type to be defined in sched.h., but gcc can't find it. The solution we found was to define gnu source by passing -D_GNU_SOURCE.

This problem seemed to be related to compilation for musl-libc, so it may appear in other parts of composite.

gparmer commented 6 years ago

This should be added to the DPDK issue queue, or simply added into the DPDK source (which I'm sure @rskennedy has already done).

m-peko commented 6 years ago

@rskennedy Can you please explain how exactly you have solved this compilation error? Where have you added -D_GNU_SOURCE flag?

rskennedy commented 6 years ago

@m-peko Within composite, a good place to add -D_GNU_SOURCE would be the CFLAGS because this makefile affects every component.

If you are thinking of another system, adding this flag to a top-level makefile would most likely solve the problem.

m-peko commented 6 years ago

@rskennedy Thanks for a response. I added it and it solved my problem.

gparmer commented 6 years ago

@rskennedy This is likely something that we should add to the system, right? Should we add it in CFLAGS, or should we add it locally in a component's Makefile as CFLAGS += -D_GNU_SOURCE?