#1539 closed defect (fixed)

Failed to configure with clang if installed CUDA

Reported by: okkez@… Owned by: Ruslan Ermilov <ru@…>
Priority: major Milestone:
Component: other Version: 1.13.x
Keywords: Cc:
uname -a: Linux enerian 4.15.0-2-amd64 #1 SMP Debian 4.15.11-1 (2018-03-20) x86_64 GNU/Linux
nginx -V: HEAD

Description

I met following errors when compile nginx using clang.

$ CC=clang ./auto/configure
checking for OS  
 + Linux 4.15.0-2-amd64 x86_64
checking for C compiler ... found
 + using Clang C compiler
 + clang version: 4.0.1-10 (tags/RELEASE_401/final)
unknown
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for gcc builtin 64 bit byteswap ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
checking for EPOLLEXCLUSIVE ... found
checking for O_PATH ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for prctl(PR_SET_KEEPCAPS) ... found
checking for capabilities ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for nobody group ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for sched_setaffinity() ... found
checking for SO_SETFIB ... not found
checking for SO_REUSEPORT ... found
checking for SO_ACCEPTFILTER ... not found
checking for SO_BINDANY ... not found
checking for IP_TRANSPARENT ... found
checking for IP_BINDANY ... not found
checking for IP_BIND_ADDRESS_NO_PORT ... found
checking for IP_RECVDSTADDR ... not found
checking for IP_SENDSRCADDR ... not found
checking for IP_PKTINFO ... found
checking for IPV6_RECVPKTINFO ... found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE ... found
checking for TCP_FASTOPEN ... found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for eventfd() ... found
checking for int size ... 4 bytes
checking for long size ... 8 bytes
checking for long long size ... 8 bytes
checking for void * size ... 8 bytes
checking for uint32_t ... found
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ...
./auto/configure: error: can not detect sig_atomic_t size

clang -v in my environment:

$ clang -v
clang version 4.0.1-10 (tags/RELEASE_401/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8.0.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8.0.1
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8.0.1
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /usr/lib/cuda, version unknown

I've created following patch to resolve error:

diff -r 1ad1cdfe7409 auto/cc/clang
--- a/auto/cc/clang     Tue Apr 10 17:11:10 2018 +0300
+++ b/auto/cc/clang     Tue Apr 24 17:21:41 2018 +0900
@@ -5,7 +5,7 @@
 # clang
 
 
-NGX_CLANG_VER=`$CC -v 2>&1 | grep 'version' 2>&1 \
+NGX_CLANG_VER=`$CC -v 2>&1 | grep 'clang version' 2>&1 \
                            | sed -e 's/^.* version \(.*\)/\1/'`
 
 echo " + clang version: $NGX_CLANG_VER"

Change History (3)

comment:1 Changed 19 months ago by ru

This was broken in 325b3042edd6.

comment:2 Changed 19 months ago by ru

Try this patch:

# HG changeset patch
# User Ruslan Ermilov <ru@nginx.com>
# Date 1524567899 -10800
#      Tue Apr 24 14:04:59 2018 +0300
# Node ID e4d7d8dd65bd7c2437c740f316ddb9123dbac8d8
# Parent  5b84c8dc4cf5e909673adc24e044a7644da7f8d5
Configure: fixed clang version detection (closes #1539).

While 325b3042edd6 fixed it on MINIX, it broke it on systems
that output the word "version" on several lines with "cc -v".
The fix is to only consider "clang version" or "LLVM version"
as clang version, but this time only using sed(1).

diff --git a/auto/cc/clang b/auto/cc/clang
--- a/auto/cc/clang
+++ b/auto/cc/clang
@@ -6,7 +6,8 @@
 
 
 NGX_CLANG_VER=`$CC -v 2>&1 | grep 'version' 2>&1 \
-                           | sed -e 's/^.* version \(.*\)/\1/'`
+                           | sed -n -e 's/^.*clang version \(.*\)/\1/p' \
+                                    -e 's/^.*LLVM version \(.*\)/\1/p'`
 
 echo " + clang version: $NGX_CLANG_VER"
 

comment:3 Changed 19 months ago by Ruslan Ermilov <ru@…>

  • Owner set to Ruslan Ermilov <ru@…>
  • Resolution set to fixed
  • Status changed from new to closed

In 7273:ceab908790c4/nginx:

Configure: fixed clang version detection (closes #1539).

While 325b3042edd6 fixed it on MINIX, it broke it on systems
that output the word "version" on several lines with "cc -v".
The fix is to only consider "clang version" or "LLVM version"
as clang version, but this time only using sed(1).

Note: See TracTickets for help on using tickets.