jcnelson / vdev

A device-file manager for *nix
GNU General Public License v3.0
101 stars 13 forks source link

libudev-device.c:1079:21: error: 'environ' undeclared #68

Closed somasis closed 8 years ago

somasis commented 8 years ago
$ make -C hwdb CC=x86_64-pc-linux-gnu-cc CXX=x86_64-pc-linux-gnu-c++ LD=x86_64-pc-linux-gnu-ld OSTYPE=LINUX
(completed succesfully, deleted the output)
$ make -C vdevd CC=x86_64-pc-linux-gnu-cc CXX=x86_64-pc-linux-gnu-c++ LD=x86_64-pc-linux-ld OSTYPE=LINUX
(completed succesfully, deleted the output)
$ make -C libudev-compat -j1 CC=x86_64-pc-linux-gnu-cc CXX=x86_64-pc-linux-gnu-c++ LD=x86_64-pc-linux-gnu-ld OSTYPE=LINUX
make: Entering directory '/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/libudev-compat'
cp -a "hashmap.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/hashmap.h"
cp -a "mempool.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/mempool.h"
cp -a "siphash24.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/siphash24.h"
cp -a "device-nodes.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/device-nodes.h"
cp -a "set.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/set.h"
cp -a "libudev.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/libudev.h"
cp -a "hwdb-util.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/hwdb-util.h"
cp -a "macro.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/macro.h"
cp -a "utf8.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/utf8.h"
cp -a "libudev-fs.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/libudev-fs.h"
cp -a "mkdir.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/mkdir.h"
cp -a "hwdb-internal.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/hwdb-internal.h"
cp -a "sd-hwdb.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/sd-hwdb.h"
cp -a "util.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/util.h"
cp -a "log.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/log.h"
cp -a "strxcpyx.h" "/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/include/strxcpyx.h"
cp -a "MurmurHash2.h" "/var/libudev-device.c: In function 'udev_device_new_from_environment':
libudev-device.c:1079:21: error: 'environ' undeclared (first use in this function)
         for (i = 0; environ[i] != NULL; i++)
                     ^
libudev-device.c:1079:21: note: each undeclared identifier is reported only once for each function it appears in
libudev-device.c: In function 'udev_device_set_devnode':
libudev-device.c:1716:21: warning: implicit declaration of function 'asprintf' [-Wimplicit-function-declaration]
                 if (asprintf(&udev_device->devnode, "/dev/%s", devnode) < 0)
                     ^
make: *** [/var/tmp/paludis/build/sys-apps-vdev-scm/work/vdev-scm/build/libudev-compat/libudev-device.o] Error 1
jcnelson commented 8 years ago

Hi @Somasis,

Like libudev, libudev-compat requires a few extra feature macros to be defined. They are:

Vdev's buildconf.mk and libudev-compat's Makefile should enable them all via the $(DEFS) variable. It's not clear from your build output that they're enabled. Can you confirm?

Thanks!

somasis commented 8 years ago

Oh, okay, I see now. I looked more at libudev-compat's Makefile, I think I know what the issue is.

In the root buildconf.mk, DEFS is defined just fine. In vdevd's Makefile, $(DEFS) is added to all the $(CC) invocations. That's why they succeed. However, since the CC is being set in the make arguments rather than using the default, it trips up libudev-compat's Makefile, because of the way it uses the DEFS...

CFLAGS := -Wall -g -fPIC -fstack-protector -fstack-protector-all -pthread -Wno-unused-variable -Wno-unused-but-set-variable
INC := $(INC) -I$(BUILD_LIBUDEV_COMPAT_HEADERS)
DEFS := $(DEFS) -D_POSIX_C_SOURCE=200809L -D_BSD_SOURCE -D_GNU_SOURCE
CC   := cc $(CFLAGS) $(INC) $(DEFS)

So instead of tacking $(DEFS) and all that stuff on to the end of CC, it should be added separately to all the invocations of $(CC) in the Makefile.