lvmteam/lvm2

Unable to compile with CLANG+LLVM under toolchain (clang+musl)

Closed this issue · 2 comments

Hello there!
I am unable to compile LVM2 under Gentoo with GCC-free toolchain (clang+musl).

CBUILD="x86_64-gentoo-linux-musl"
CHOST="x86_64-gentoo-linux-musl"
CC="clang"
CFLAGS="-O2 -march=native -mtune=corei7 -pipe"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,--as-needed -Wl,-z,relro,-z,now -pie"

Getting alot of errors (please, see below)

daemon-server.c:248:6: warning: implicit declaration of function 'fcntl' is invalid in C99 [-Wimplicit-function-declaration]
if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK))
^
daemon-server.c:248:16: error: use of undeclared identifier 'F_SETFL'
if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK))
^
daemon-server.c:248:35: error: use of undeclared identifier 'F_GETFL'
if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK))
^
daemon-server.c:248:49: error: use of undeclared identifier 'O_NONBLOCK'
if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK))
^
daemon-server.c:335:12: warning: implicit declaration of function 'open' is invalid in C99 [-Wimplicit-function-declaration]
if ((fd = open("/dev/null", O_RDWR)) == -1) {
^
daemon-server.c:335:30: error: use of undeclared identifier 'O_RDWR'
if ((fd = open("/dev/null", O_RDWR)) == -1) {
^
daemon-server.c:520:6: warning: implicit declaration of function 'fcntl' is invalid in C99 [-Wimplicit-function-declaration]
if (fcntl(client.socket_fd, F_SETFD, FD_CLOEXEC))
^
daemon-server.c:520:30: error: use of undeclared identifier 'F_SETFD'
if (fcntl(client.socket_fd, F_SETFD, FD_CLOEXEC))
^
daemon-server.c:520:39: error: use of undeclared identifier 'FD_CLOEXEC'
if (fcntl(client.socket_fd, F_SETFD, FD_CLOEXEC))
^
daemon-server.c:641:17: warning: implicit declaration of function 'fcntl' is invalid in C99 [-Wimplicit-function-declaration]
if (!failed && fcntl(s.socket_fd, F_SETFD, 1))
^
daemon-server.c:641:36: error: use of undeclared identifier 'F_SETFD'
if (!failed && fcntl(s.socket_fd, F_SETFD, 1))
^

Please, provide some patch of instruction how to resolve this issue.
Thanks!

Maybe try to add this header file into problematic file:

#include <fcntl.h>

Closing as assuming it has helped.