Mercurial > hg > nginx-quic
annotate auto/cc/clang @ 9017:106328a70f4e
Added warning about redefinition of listen socket protocol options.
The "listen" directive in the http module can be used multiple times
in different server blocks. Originally, it was supposed to be specified
once with various socket options, and without any parameters in virtual
server blocks. For example:
server { listen 80 backlog=1024; server_name foo; ... }
server { listen 80; server_name bar; ... }
server { listen 80; server_name bazz; ... }
The address part of the syntax ("address[:port]" / "port" / "unix:path")
uniquely identifies the listening socket, and therefore is enough for
name-based virtual servers (to let nginx know that the virtual server
accepts requests on the listening socket in question).
To ensure that listening options do not conflict between virtual servers,
they were allowed only once. For example, the following configuration
will be rejected ("duplicate listen options for 0.0.0.0:80 in ..."):
server { listen 80 backlog=1024; server_name foo; ... }
server { listen 80 backlog=512; server_name bar; ... }
At some point it was, however, noticed, that it is sometimes convenient
to repeat some options for clarity. In nginx 0.8.51 the "ssl" parameter
was allowed to be specified multiple times, e.g.:
server { listen 443 ssl backlog=1024; server_name foo; ... }
server { listen 443 ssl; server_name bar; ... }
server { listen 443 ssl; server_name bazz; ... }
This approach makes configuration more readable, since SSL sockets are
immediately visible in the configuration. If this is not needed, just the
address can still be used.
Later, additional protocol-specific options similar to "ssl" were
introduced, notably "http2" and "proxy_protocol". With these options,
one can write:
server { listen 443 ssl backlog=1024; server_name foo; ... }
server { listen 443 http2; server_name bar; ... }
server { listen 443 proxy_protocol; server_name bazz; ... }
The resulting socket will use ssl, http2, and proxy_protocol, but this
is not really obvious from the configuration.
To emphasize such misleading configurations are discouraged, nginx now
warns as long as the "listen" directive is used with options different
from the options previously used if this is potentially confusing.
In particular, the following configurations are allowed:
server { listen 8401 ssl backlog=1024; server_name foo; }
server { listen 8401 ssl; server_name bar; }
server { listen 8401 ssl; server_name bazz; }
server { listen 8402 ssl http2 backlog=1024; server_name foo; }
server { listen 8402 ssl; server_name bar; }
server { listen 8402 ssl; server_name bazz; }
server { listen 8403 ssl; server_name bar; }
server { listen 8403 ssl; server_name bazz; }
server { listen 8403 ssl http2; server_name foo; }
server { listen 8404 ssl http2 backlog=1024; server_name foo; }
server { listen 8404 http2; server_name bar; }
server { listen 8404 http2; server_name bazz; }
server { listen 8405 ssl http2 backlog=1024; server_name foo; }
server { listen 8405 ssl http2; server_name bar; }
server { listen 8405 ssl http2; server_name bazz; }
server { listen 8406 ssl; server_name foo; }
server { listen 8406; server_name bar; }
server { listen 8406; server_name bazz; }
And the following configurations will generate warnings:
server { listen 8501 ssl http2 backlog=1024; server_name foo; }
server { listen 8501 http2; server_name bar; }
server { listen 8501 ssl; server_name bazz; }
server { listen 8502 backlog=1024; server_name foo; }
server { listen 8502 ssl; server_name bar; }
server { listen 8503 ssl; server_name foo; }
server { listen 8503 http2; server_name bar; }
server { listen 8504 ssl; server_name foo; }
server { listen 8504 http2; server_name bar; }
server { listen 8504 proxy_protocol; server_name bazz; }
server { listen 8505 ssl http2 proxy_protocol; server_name foo; }
server { listen 8505 ssl http2; server_name bar; }
server { listen 8505 ssl; server_name bazz; }
server { listen 8506 ssl http2; server_name foo; }
server { listen 8506 ssl; server_name bar; }
server { listen 8506; server_name bazz; }
server { listen 8507 ssl; server_name bar; }
server { listen 8507; server_name bazz; }
server { listen 8507 ssl http2; server_name foo; }
server { listen 8508 ssl; server_name bar; }
server { listen 8508; server_name bazz; }
server { listen 8508 ssl backlog=1024; server_name foo; }
server { listen 8509; server_name bazz; }
server { listen 8509 ssl; server_name bar; }
server { listen 8509 ssl backlog=1024; server_name foo; }
The basic idea is that at most two sets of protocol options are allowed:
the main one (with socket options, if any), and a shorter one, with options
being a subset of the main options, repeated for clarity. As long as the
shorter set of protocol options is used, all listen directives except the
main one should use it.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sat, 28 Jan 2023 01:29:45 +0300 |
parents | ceab908790c4 |
children |
rev | line source |
---|---|
4762
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
2 # Copyright (C) Nginx, Inc. |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
3 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
4 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
5 # clang |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
6 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
7 |
7161
325b3042edd6
Configure: fixed clang detection on MINIX.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6603
diff
changeset
|
8 NGX_CLANG_VER=`$CC -v 2>&1 | grep 'version' 2>&1 \ |
7273
ceab908790c4
Configure: fixed clang version detection (closes #1539).
Ruslan Ermilov <ru@nginx.com>
parents:
7161
diff
changeset
|
9 | sed -n -e 's/^.*clang version \(.*\)/\1/p' \ |
ceab908790c4
Configure: fixed clang version detection (closes #1539).
Ruslan Ermilov <ru@nginx.com>
parents:
7161
diff
changeset
|
10 -e 's/^.*LLVM version \(.*\)/\1/p'` |
4762
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
11 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
12 echo " + clang version: $NGX_CLANG_VER" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
13 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
14 have=NGX_COMPILER value="\"clang $NGX_CLANG_VER\"" . auto/define |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
15 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
16 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
17 CC_TEST_FLAGS="-pipe" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
18 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
19 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
20 # optimizations |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
21 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
22 #NGX_CLANG_OPT="-O2" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
23 #NGX_CLANG_OPT="-Oz" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
24 NGX_CLANG_OPT="-O" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
25 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
26 case $CPU in |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
27 pentium) |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
28 # optimize for Pentium |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
29 CPU_OPT="-march=pentium" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
30 NGX_CPU_CACHE_LINE=32 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
31 ;; |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
32 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
33 pentiumpro | pentium3) |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
34 # optimize for Pentium Pro, Pentium II and Pentium III |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
35 CPU_OPT="-march=pentiumpro" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
36 NGX_CPU_CACHE_LINE=32 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
37 ;; |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
38 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
39 pentium4) |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
40 # optimize for Pentium 4 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
41 CPU_OPT="-march=pentium4" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
42 NGX_CPU_CACHE_LINE=128 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
43 ;; |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
44 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
45 athlon) |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
46 # optimize for Athlon |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
47 CPU_OPT="-march=athlon" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
48 NGX_CPU_CACHE_LINE=64 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
49 ;; |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
50 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
51 opteron) |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
52 # optimize for Opteron |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
53 CPU_OPT="-march=opteron" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
54 NGX_CPU_CACHE_LINE=64 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
55 ;; |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
56 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
57 esac |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
58 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
59 CC_AUX_FLAGS="$CC_AUX_FLAGS $CPU_OPT" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
60 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
61 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
62 CFLAGS="$CFLAGS -pipe $CPU_OPT" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
63 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
64 if [ ".$PCRE_OPT" = "." ]; then |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
65 PCRE_OPT="-O2 -pipe $CPU_OPT" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
66 else |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
67 PCRE_OPT="$PCRE_OPT -pipe" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
68 fi |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
69 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
70 if [ ".$ZLIB_OPT" = "." ]; then |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
71 ZLIB_OPT="-O2 -pipe $CPU_OPT" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
72 else |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
73 ZLIB_OPT="$ZLIB_OPT -pipe" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
74 fi |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
75 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
76 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
77 # warnings |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
78 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
79 CFLAGS="$CFLAGS $NGX_CLANG_OPT -Wall -Wextra -Wpointer-arith" |
5459
fedf777c6b24
Configure: enable -Wconditional-uninitialized with clang.
Ruslan Ermilov <ru@nginx.com>
parents:
5187
diff
changeset
|
80 CFLAGS="$CFLAGS -Wconditional-uninitialized" |
4762
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
81 #CFLAGS="$CFLAGS -Wmissing-prototypes" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
82 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
83 # we have a lot of unused function arguments |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
84 CFLAGS="$CFLAGS -Wno-unused-parameter" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
85 |
5714
80bd391c90d1
Configure: added -Wno-deprecated-declarations on OS X.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5539
diff
changeset
|
86 # deprecated system OpenSSL library on OS X |
80bd391c90d1
Configure: added -Wno-deprecated-declarations on OS X.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5539
diff
changeset
|
87 if [ "$NGX_SYSTEM" = "Darwin" ]; then |
80bd391c90d1
Configure: added -Wno-deprecated-declarations on OS X.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5539
diff
changeset
|
88 CFLAGS="$CFLAGS -Wno-deprecated-declarations" |
80bd391c90d1
Configure: added -Wno-deprecated-declarations on OS X.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5539
diff
changeset
|
89 fi |
80bd391c90d1
Configure: added -Wno-deprecated-declarations on OS X.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5539
diff
changeset
|
90 |
4762
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
91 # stop on warning |
5539
c86dd32573c0
Configure: enabled -Werror for clang.
Ruslan Ermilov <ru@nginx.com>
parents:
5459
diff
changeset
|
92 CFLAGS="$CFLAGS -Werror" |
4762
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
93 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
94 # debug |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
95 CFLAGS="$CFLAGS -g" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
96 |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
97 if [ ".$CPP" = "." ]; then |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
98 CPP="$CC -E" |
182aee3b1bf5
Added the Clang compiler support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
99 fi |