nginx / unit

NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
https://unit.nginx.org
Apache License 2.0
5.37k stars 323 forks source link

Make enhancements #1172

Closed ac000 closed 6 months ago

ac000 commented 6 months ago

This PR comprises three main elements centred around improving the developer experience

1) Pretty print the make/build output. 2) Allow to enable debug (-O0) builds at make time. 2) Allow to disable -Werror at make time.

The first item changes (by default) the make output from

...
cc -c -pipe -fPIC -fvisibility=hidden -W -Wall -Wextra -Wno-unused-parameter
 -Wwrite-strings -Wmissing-prototypes -g   -O -Werror -I src -I build/include   \
                      \
                     \
-o build/src/nxt_time.o \
-MMD -MF build/src/nxt_time.dep -MT build/src/nxt_time.o \
src/nxt_time.c
cc -c -pipe -fPIC -fvisibility=hidden -W -Wall -Wextra -Wno-unused-parameter
 -Wwrite-strings -Wmissing-prototypes -g   -O -Werror -I src -I build/include   \
                      \
                     \
-o build/src/nxt_malloc.o \
-MMD -MF build/src/nxt_malloc.dep -MT build/src/nxt_malloc.o \
src/nxt_malloc.c
cc -c -pipe -fPIC -fvisibility=hidden -W -Wall -Wextra -Wno-unused-parameter
 -Wwrite-strings -Wmissing-prototypes -g   -O -Werror -I src -I build/include   \
                      \
                     \
-o build/src/nxt_file.o \
-MMD -MF build/src/nxt_file.dep -MT build/src/nxt_file.o \
src/nxt_file.c
cc -c -pipe -fPIC -fvisibility=hidden -W -Wall -Wextra -Wno-unused-parameter
 -Wwrite-strings -Wmissing-prototypes -g   -O -Werror -I src -I build/include   \
                      \
                     \
-o build/src/nxt_mem_map.o \
-MMD -MF build/src/nxt_mem_map.dep -MT build/src/nxt_mem_map.o \
src/nxt_mem_map.c
...
cc -c -pipe -fPIC -fvisibility=hidden -W -Wall -Wextra -Wno-unused-parameter
 -Wwrite-strings -Wmissing-prototypes -g   -O -Werror -I src -I build/include   \
                      \
                     \
-o build/src/nxt_cgroup.o \
-MMD -MF build/src/nxt_cgroup.dep -MT build/src/nxt_cgroup.o \
src/nxt_cgroup.c
ar -r -c build/lib/libnxt.a build/src/nxt_lib.o build/src/nxt_gmtime.o build/src
/nxt_errno.o build/src/nxt_time.o build/src/nxt_malloc.o build/src/nxt_file.o bu
ild/src/nxt_mem_map.o build/src/nxt_socket.o build/src/nxt_socketpair.o build/sr
c/nxt_socket_msg.o build/src/nxt_credential.o build/src/nxt_isolation.o build/sr
c/nxt_process.o build/src/nxt_process_title.o build/src/nxt_signal.o build/src/n
xt_port_socket.o build/src/nxt_port_memory.o build/src/nxt_port_rpc.o build/src/
nxt_port.o build/src/nxt_dyld.o build/src/nxt_random.o build/src/nxt_queue.o bui
ld/src/nxt_rbtree.o build/src/nxt_mp.o build/src/nxt_mem_zone.o build/src/nxt_st
ring.o build/src/nxt_utf8.o build/src/nxt_parse.o build/src/nxt_sprintf.o build/
src/nxt_var.o build/src/nxt_tstr.o build/src/nxt_file_name.o build/src/nxt_log.o
 build/src/nxt_djb_hash.o build/src/nxt_murmur_hash.o build/src/nxt_lvlhsh.o bui
ld/src/nxt_array.o build/src/nxt_vector.o build/src/nxt_list.o build/src/nxt_buf
.o build/src/nxt_buf_pool.o build/src/nxt_recvbuf.o build/src/nxt_sendbuf.o buil
d/src/nxt_thread.o build/src/nxt_thread_mutex.o build/src/nxt_thread_cond.o buil
d/src/nxt_spinlock.o build/src/nxt_semaphore.o build/src/nxt_thread_pool.o build
/src/nxt_thread_time.o build/src/nxt_time_parse.o build/src/nxt_work_queue.o bui
ld/src/nxt_service.o build/src/nxt_log_moderation.o build/src/nxt_event_engine.o
 build/src/nxt_timer.o build/src/nxt_fd_event.o build/src/nxt_conn.o build/src/n
xt_conn_connect.o build/src/nxt_conn_accept.o build/src/nxt_conn_read.o build/sr
c/nxt_conn_write.o build/src/nxt_conn_close.o build/src/nxt_event_conn_job_sendf
ile.o build/src/nxt_conn_proxy.o build/src/nxt_job.o build/src/nxt_sockaddr.o bu
ild/src/nxt_listen_socket.o build/src/nxt_upstream.o build/src/nxt_upstream_roun
d_robin.o build/src/nxt_http_parse.o build/src/nxt_app_log.o build/src/nxt_capab
ility.o build/src/nxt_runtime.o build/src/nxt_conf.o build/src/nxt_conf_validati
on.o build/src/nxt_main_process.o build/src/nxt_signal_handlers.o build/src/nxt_
controller.o build/src/nxt_router.o build/src/nxt_router_access_log.o build/src/
nxt_h1proto.o build/src/nxt_status.o build/src/nxt_http_request.o build/src/nxt_
http_response.o build/src/nxt_http_error.o build/src/nxt_http_route.o build/src/
nxt_http_route_addr.o build/src/nxt_http_rewrite.o build/src/nxt_http_set_header
s.o build/src/nxt_http_return.o build/src/nxt_http_static.o build/src/nxt_http_p
roxy.o build/src/nxt_http_chunk_parse.o build/src/nxt_http_variables.o build/src
/nxt_application.o build/src/nxt_external.o build/src/nxt_port_hash.o build/src/
nxt_sha1.o build/src/nxt_websocket.o build/src/nxt_websocket_accept.o build/src/
nxt_http_websocket.o build/src/nxt_h1proto_websocket.o build/src/nxt_fs.o build/
src/nxt_fs_mount.o build/src/nxt_pcre2.o build/src/nxt_epoll_engine.o build/src/
nxt_poll_engine.o build/src/nxt_select_engine.o build/src/nxt_linux_sendfile.o b
uild/src/nxt_clone.o build/src/nxt_cgroup.o
cc -c -pipe -fPIC -fvisibility=hidden -W -Wall -Wextra -Wno-unused-parameter
 -Wwrite-strings -Wmissing-prototypes -g   -O -Werror -I src -I build/include \
          \
                      \
                     \
        -o build/src/nxt_main.o \
        -MMD -MF build/src/nxt_main.dep -MT build/src/nxt_main.o \
        src/nxt_main.c
cc -Wl,-E  -o build/sbin/unitd -pipe -fPIC -fvisibility=hidden -W -Wall -Wextra
-Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -g   -O -Werror \
        build/src/nxt_main.o  build/lib/libnxt.a \
        -lm -lrt  -lpthread   \
                      \
                    -lpcre2-8
sed -e "s|%%ERROR_LOG_PATH%%|/opt/unit/unit.log|" \
        -e "s|%%PID_PATH%%|/opt/unit/unit.pid|" \
        -e "s|%%SOCKET_PATH%%|unix:/opt/unit/control.unit.sock|" \
        < docs/man/man8/unitd.8.in > build/share/man/man8/unitd.8

to

...
  CC     build/src/nxt_time.o
  CC     build/src/nxt_malloc.o
  CC     build/src/nxt_file.o
  CC     build/src/nxt_mem_map.o
...
  CC     build/src/nxt_cgroup.o
  AR     build/lib/libnxt.a
  CC     build/src/nxt_main.o
  LNK    build/sbin/unitd
  MAN    build/share/man/man8/unitd.8

It shows clearly what is happening and what the output is. It vastly reduces the noise and makes things like warnings stand out much more clearly. (See the first commit message for an explanation of these types).

This style of make output is used by projects such as the Linux Kernel and git.

I'm sure you'll agree it looks much nicer and improves the developer experience.

You can still get the verbose output by passing V=1 to make, e.g

$ make V=1 ...

The next item is to enable debug builds. By this I mean builds that debuggable under the likes of GDB. We default to building with -O (-O1). This often has the issue of when debugging that things get optimised out and you can't inspect them.

With this change you can pass D=1 to make to have it build with -O0, no optimisations.

The third item allows you to disable -Werror at make time. Often having the build abort on what would normally just be a compiler warning gets in the way of development. You often make some quick change to test something, knowing you will get a warning only to have the build totally fail...

To remove this obstacle you can now pass E=0 to make which will not enable -Werror.

For me I would often be using the following

$ make D=1 E=0 ...

It is worth noting that this new functionality does require GNU make. That covers Linux & macOS (by the looks of it). On OpenIndiana/illumos, you have to use gmake (GNU make) anyway.

Everything still works as before on non GNU make.

It would perhaps not be unreasonable to mandate GNU make, on FreeBSD for example gmake is readily installable. The likes of git for example requires GNU make... but that's perhaps a discussion for another day.

hongzhidao commented 6 months ago

Hi, I'm used to the current way, and it's working well for me. I can't say whether this change is better or not, but I'd suggest inviting others to review this PR, thanks.

ac000 commented 6 months ago

On Wed, 06 Mar 2024 01:21:06 -0800 hongzhidao @.***> wrote:

Hi, I'm used to the current way, and it's working well for me.

You can still get the verbose output with make V=1 ...

I can't say whether this change is better or not, but I'd suggest inviting others to review this PR, thanks.

Cc: @callahad

This is all part of the overarching plan to present Unit as a modern C project.

ac000 commented 6 months ago

Rebased with master

$ git range-diff c10a52af...1affe53b
 -:  -------- >  1:  4eb008bb Remove unused nxt_vector_t API
 -:  -------- >  2:  353d2d05 Var: Remove a dead assignment in nxt_var_interpreter()
 -:  -------- >  3:  c2f7f296 Avoid potential NULL pointer dereference in nxt_router_temp_conf()
 1:  63656f51 =  4:  10aaf2f0 Add initial infrastructure for pretty printing make output
 2:  a9474932 =  5:  6e7a9efd Hook up make pretty printing to the Unit core and tests
 3:  544a8e04 =  6:  a98bdd5c Pretty print the Java language module compiler output
 4:  2f513260 =  7:  03942241 Pretty print the Perl language module compiler output
 5:  9ed03b02 =  8:  fed116da Pretty print the PHP language module compiler output
 6:  22f629c1 =  9:  0c5773c5 Pretty print the Python language module compiler output
 7:  591c8076 = 10:  4bb8a03b Pretty print the Ruby language module compiler output
 8:  805a47ff = 11:  75098dd9 Pretty print the wasm language module compiler output
 9:  51e011e4 = 12:  1709cfbf Enable optional 'debuggable' builds
10:  3cbae8c3 = 13:  d5e3a4a3 Allow to disable -Werror at 'make' time
11:  c10a52af = 14:  1affe53b Add a help target to the root Makefile
callahad commented 6 months ago

Is there a precedent for using the D/E/V vars in that way? I haven't personally run across that before.

ac000 commented 6 months ago

Well apart from unit-wasm, the Linux Kernel has these

    @echo  '  make V=n   [targets] 1: verbose build'
    @echo  '                       2: give reason for rebuild of target'
    @echo  '                       V=1 and V=2 can be combined with V=12'
    @echo  '  make O=dir [targets] Locate all output files in "dir", including .config'
    @echo  '  make C=1   [targets] Check re-compiled c source with $$CHECK'
    @echo  '                       (sparse by default)'
    @echo  '  make C=2   [targets] Force check of all c source with $$CHECK'
    @echo  '  make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
    @echo  '  make W=n   [targets] Enable extra build checks, n=1,2,3,c,e where'
    @echo  '        1: warnings which may be relevant and do not occur too often'
    @echo  '        2: warnings which occur quite often but may still be relevant'
    @echo  '        3: more obscure warnings, can most likely be ignored'
    @echo  '        c: extra checks in the configuration stage (Kconfig)'
    @echo  '        e: warnings are being treated as errors'
    @echo  '        Multiple levels can be combined with W=12 or W=123'

Git uses V= in the same way... I'm sure there will be others...

There is also a make help target

$ make help
Variables to control make/build behaviour:

  make V=1 ...           - Enables verbose output
  make D=1 ...           - Enables debug builds (-O0)
  make E=0 ...           - Disables -Werror

  Variables can be combined.
ac000 commented 6 months ago

So a few others indeed...

callahad commented 6 months ago

That's compelling. Ultimately, this is a developer-facing subjective / aesthetic change... I'd be inclined for us to default to accepting these kinds of changes so long as there is not a strong objection from within the team.

ac000 commented 6 months ago

Remove an erroneous blank line.

$ git range-diff 1affe53b...25a21d24
1:  1affe53b ! 1:  25a21d24 Add a help target to the root Makefile
    @@ auto/make: include $NXT_MAKEFILE

     +.PHONY: help
     +help:
    -+
     +  @echo "Variables to control make/build behaviour:"
     +  @echo
     +  @echo "  make V=1 ...           - Enables verbose output"
alejandro-colomar commented 6 months ago

I suggest adding an empty variable EXTRA_CFLAGS, and then setting CFLAGS := ... $(EXTRA_CFLAGS).

That way, it's generic, and you allow setting any extra CFLAGS at make(1) time. That's what I do in the Linux man-pages (I was going to suggest you have a look at it, but now I remember, that Makefile is GPLd :).

I usually do make EXTRA_CFLAGS=-Wfoo to test with some new warning, or similar stuff. Packagers can then use make EXTRA_CFLAGS=-Wno-error.

alejandro-colomar commented 6 months ago

Well apart from unit-wasm, the Linux Kernel has these

  @echo  '  make V=n   [targets] 1: verbose build'
  @echo  '                       2: give reason for rebuild of target'
  @echo  '                       V=1 and V=2 can be combined with V=12'
  @echo  '  make O=dir [targets] Locate all output files in "dir", including .config'
  @echo  '  make C=1   [targets] Check re-compiled c source with $$CHECK'
  @echo  '                       (sparse by default)'
  @echo  '  make C=2   [targets] Force check of all c source with $$CHECK'
  @echo  '  make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
  @echo  '  make W=n   [targets] Enable extra build checks, n=1,2,3,c,e where'
  @echo  '        1: warnings which may be relevant and do not occur too often'
  @echo  '        2: warnings which occur quite often but may still be relevant'
  @echo  '        3: more obscure warnings, can most likely be ignored'
  @echo  '        c: extra checks in the configuration stage (Kconfig)'
  @echo  '        e: warnings are being treated as errors'
  @echo  '        Multiple levels can be combined with W=12 or W=123'

Git uses V= in the same way... I'm sure there will be others...

There is also a make help target

$ make help
Variables to control make/build behaviour:

  make V=1 ...           - Enables verbose output
  make D=1 ...           - Enables debug builds (-O0)
  make E=0 ...           - Disables -Werror

  Variables can be combined.

Just FYI, GNU Make 4.4 (I think it was 4.4, don't remember the exact version) has added --debug=print, which does the same more-or-less as V=1. I stopped supporting V=1 in the Linux man-pages Makefile, at the expense that you can't see the verbose output if you have an old make(1) version. But yeah, I like using V for a project that has to support old systems.

ac000 commented 6 months ago

Just FYI, GNU Make 4.4 (I think it was 4.4, don't remember the exact version) has added --debug=print, which does the same more-or-less as V=1. I stopped supporting V=1 in the Linux man-pages Makefile, at the expense that you can't see the verbose output if you have an old make(1) version. But yeah, I like using V for a project that has to support old systems.

Interesting, but yes, 3.x is still prevalent.

Also because we still print the new output in verbose mode you can do

$ make | grep ^"  [A-Z]"

on other makes to get the same effect.

ac000 commented 6 months ago
$ git range-diff --creation-factor=100 25a21d24...900ce87f
1:  1709cfbf ! 1:  45a78697 Enable optional 'debuggable' builds
    @@ Commit message

           $ make D=1 ...

    -    Which will set -O0 instead of -O, basically disabling optimisations, we
    -    could use -Og, but the clang(1) man page says this is best and it seems
    -    to not cause any issues when debugging GCC generated code.
    +    Which will set -O0 overriding the -O, basically disabling optimisations,
    +    we could use -Og, but the clang(1) man page says this is best and it
    +    seems to not cause any issues when debugging GCC generated code.

         Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

      ## auto/cc/test ##
     @@ auto/cc/test: case $NXT_CC_NAME in
    -         # c99/gnu99 conflict with Solaris XOPEN.
              #NXT_CFLAGS="$NXT_CFLAGS -std=gnu99"

    --        NXT_CFLAGS="$NXT_CFLAGS -O"
    -         #NXT_CFLAGS="$NXT_CFLAGS -O0"
    +         NXT_CFLAGS="$NXT_CFLAGS -O"
    +-        #NXT_CFLAGS="$NXT_CFLAGS -O0"
              NXT_CFLAGS="$NXT_CFLAGS -W -Wall -Wextra"

    +         #NXT_CFLAGS="$NXT_CFLAGS -Wunused-result"
     @@ auto/cc/test: case $NXT_CC_NAME in
    -         # Do not export symbols except explicitly marked with NXT_EXPORT.
              NXT_CFLAGS="$NXT_CFLAGS -fvisibility=hidden"

    --        NXT_CFLAGS="$NXT_CFLAGS -O"
    -         #NXT_CFLAGS="$NXT_CFLAGS -O0"
    +         NXT_CFLAGS="$NXT_CFLAGS -O"
    +-        #NXT_CFLAGS="$NXT_CFLAGS -O0"
              NXT_CFLAGS="$NXT_CFLAGS -W -Wall -Wextra"

    +         #NXT_CFLAGS="$NXT_CFLAGS -Wunused-result"

      ## auto/make ##
     @@ auto/make: ifeq (\$V,1)
    @@ auto/make: ifeq (\$V,1)
     +# -g is always used, this just changes the optimisation level.
     +# On GCC this would be -Og, however according to the clang(1)
     +# man page, -O0 'generates the most debuggable code'.
    ++#
    ++# This will override the previous -0
     +ifeq (\$D,1)
     +        CFLAGS += -O0
    -+else
    -+        CFLAGS += -O
     +endif
    -+
    -+END
    -+
    -+else
    -+
    -+  cat << END >> $NXT_MAKEFILE
    -+
    -+CFLAGS += -O
     +
      END

2:  d5e3a4a3 ! 2:  5993a2e4 Allow to disable -Werror at 'make' time
    @@ Commit message

         Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

    - ## auto/cc/test ##
    -@@ auto/cc/test: case $NXT_CC_NAME in
    - 
    -         NXT_CFLAGS="$NXT_CFLAGS -Wmissing-prototypes"
    - 
    --        # Stop on warning.
    --        NXT_CFLAGS="$NXT_CFLAGS -Werror"
    --
    -         # Debug.
    -         NXT_CFLAGS="$NXT_CFLAGS -g"
    -     ;;
    -@@ auto/cc/test: case $NXT_CC_NAME in
    - 
    -         NXT_CFLAGS="$NXT_CFLAGS -Wmissing-prototypes"
    - 
    --        # Stop on warning.
    --        NXT_CFLAGS="$NXT_CFLAGS -Werror"
    --
    -         # Debug.
    - 
    -         if [ "$NXT_SYSTEM_PLATFORM" != "powerpc" ]; then
    -
      ## auto/make ##
    -@@ auto/make: else
    -         CFLAGS += -O
    +@@ auto/make: ifeq (\$D,1)
    +         CFLAGS += -O0
      endif

     +# Optionally disable -Werror with
     +#   make E=0 ...
    -+ifneq (\$E,0)
    -+        CFLAGS += -Werror
    ++ifeq (\$E,0)
    ++        CFLAGS += -Wno-error
     +endif
     +
      END

    - else
    - 
    -   cat << END >> $NXT_MAKEFILE
    - 
    --CFLAGS += -O
    -+CFLAGS += -O -Werror
    - 
    - END
    - 
    -
    - ## auto/os/test ##
    -@@ auto/os/test: case "$NXT_SYSTEM" in
    - 
    - esac
    - 
    -+NXT_TEST_CFLAGS="$NXT_TEST_CFLAGS -Werror"
    -+
    - $echo "configuring Unit $NXT_VERSION"                                         \
    -       "for $NXT_SYSTEM $NXT_SYSTEM_VERSION $NXT_SYSTEM_PLATFORM"
    + fi
3:  25a21d24 = 3:  1008e332 Add a help target to the root Makefile
-:  -------- > 4:  900ce87f Add an EXTRA_CFLAGS make variable
ac000 commented 6 months ago

Lots of small improvemnets as suggested by @alejandro-colomar

$ git range-diff 900ce87f...d609c615
 1:  10aaf2f0 <  -:  -------- Add initial infrastructure for pretty printing make output
 -:  -------- >  1:  906be106 Add initial infrastructure for pretty printing make output
 2:  6e7a9efd !  2:  6bf9d5f4 Hook up make pretty printing to the Unit core and tests
    @@ Commit message
           CC     build/src/nxt_cgroup.o
           AR     build/lib/libnxt.a
           CC     build/src/nxt_main.o
    -      LNK    build/sbin/unitd
    -      MAN    build/share/man/man8/unitd.8
    +      LD     build/sbin/unitd
    +      SED    build/share/man/man8/unitd.8

         I'm sure you'll agree that looks much nicer!

    @@ Commit message

           $ make V=1 ...

    +    Reviewed-by: Alejandro Colomar <alx@kernel.org>
         Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

      ## auto/make ##
    @@ auto/make: cat << END >> $NXT_MAKEFILE

      $NXT_BUILD_DIR/lib/$NXT_LIB_SHARED: \$(NXT_LIB_OBJS)
     -  \$(NXT_SHARED_LOCAL_LINK) -o \$@ \$(NXT_LIB_OBJS) \\
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_SHARED_LOCAL_LINK) -o \$@ \$(NXT_LIB_OBJS) \\
            $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS

    @@ auto/make: nxt_dep_post=`nxt_gen_dep_post`

      $NXT_BUILD_DIR/$nxt_obj: $nxt_src $NXT_VERSION_H
     -  \$(CC) -c \$(CFLAGS) -DNXT_NCQ_TEST=1 \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
    -+  \$(PP_CC) $NXT_BUILD_DIR/$nxt_obj
    ++  \$(PP_CC) \$@
     +  \$(v)\$(CC) -c \$(CFLAGS) -DNXT_NCQ_TEST=1 \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
        -o $NXT_BUILD_DIR/$nxt_obj \\
        $nxt_dep_flags \\
    @@ auto/make: tests:        $NXT_BUILD_DIR/tests $NXT_BUILD_DIR/utf8_file_name_test \\
      $NXT_BUILD_DIR/tests: \$(NXT_TEST_OBJS) \\
                $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC
     -  \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/tests \\
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/tests \\
            \$(CFLAGS) \$(NXT_TEST_OBJS) \\
            $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
    @@ auto/make: tests:        $NXT_BUILD_DIR/tests $NXT_BUILD_DIR/utf8_file_name_test \\
      $NXT_BUILD_DIR/utf8_file_name_test: $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\
                $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC
     -  \$(CC) \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
    -+  \$(PP_CCLNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(CC) \$(CFLAGS) \$(NXT_LIB_INCS) $NXT_LIB_AUX_CFLAGS \\
            -o $NXT_BUILD_DIR/utf8_file_name_test \\
            $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS \\
    @@ auto/make: $NXT_BUILD_DIR/utf8_file_name_test: $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS
      $NXT_BUILD_DIR/ncq_test: $NXT_BUILD_DIR/src/test/nxt_ncq_test.o \\
                $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC
     -  \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/ncq_test \\
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/ncq_test \\
            \$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_ncq_test.o \\
            $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
    @@ auto/make: $NXT_BUILD_DIR/utf8_file_name_test: $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS
      $NXT_BUILD_DIR/vbcq_test: $NXT_BUILD_DIR/src/test/nxt_vbcq_test.o \\
                $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC
     -  \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/vbcq_test \\
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/vbcq_test \\
            \$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_vbcq_test.o \\
            $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
    @@ auto/make: $NXT_BUILD_DIR/utf8_file_name_test: $NXT_LIB_UTF8_FILE_NAME_TEST_SRCS
      $NXT_BUILD_DIR/unit_app_test: $NXT_BUILD_DIR/src/test/nxt_unit_app_test.o \\
            $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC
     -  \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_app_test \\
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_app_test \\
            \$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_unit_app_test.o \\
            $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC \\
    @@ auto/make: $NXT_BUILD_DIR/unit_app_test: $NXT_BUILD_DIR/src/test/nxt_unit_app_te
            $NXT_BUILD_DIR/src/test/nxt_unit_websocket_chat.o \\
            $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC
     -  \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_websocket_chat \\
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_websocket_chat \\
            \$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_unit_websocket_chat.o \\
            $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC \\
    @@ auto/make: $NXT_BUILD_DIR/unit_websocket_chat: \\
            $NXT_BUILD_DIR/src/test/nxt_unit_websocket_echo.o \\
            $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC
     -  \$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_websocket_echo \\
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_EXEC_LINK) -o $NXT_BUILD_DIR/unit_websocket_echo \\
            \$(CFLAGS) $NXT_BUILD_DIR/src/test/nxt_unit_websocket_echo.o \\
            $NXT_BUILD_DIR/lib/$NXT_LIB_UNIT_STATIC \\
    @@ auto/make: cat << END >> $NXT_MAKEFILE
      $NXT_BUILD_DIR/sbin/$NXT_DAEMON:  $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
                    \$(NXT_OBJS)
     -  \$(NXT_EXEC_LINK) -o \$@ \$(CFLAGS) \\
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_EXEC_LINK) -o \$@ \$(CFLAGS) \\
            \$(NXT_OBJS) $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
            $NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS
    @@ auto/make: cat << END >> $NXT_MAKEFILE
      $NXT_BUILD_DIR/share/man/man8/unitd.8: docs/man/man8/unitd.8.in \\
                    $NXT_BUILD_DIR/include/nxt_auto_config.h
     -  sed -e "s|%%ERROR_LOG_PATH%%|$NXT_LOG|" \\
    -+  \$(PP_MAN) \$@
    ++  \$(PP_SED) \$@
     +  \$(v)sed -e "s|%%ERROR_LOG_PATH%%|$NXT_LOG|" \\
            -e "s|%%PID_PATH%%|$NXT_PID|" \\
            -e "s|%%SOCKET_PATH%%|$NXT_CONTROL|" \\
    @@ auto/make: END

      $NXT_BUILD_DIR/share/pkgconfig/unit.pc: src/unit.pc.in
     -  sed -e "s|@PREFIX@|$NXT_PREFIX|" \\
    -+  \$(PP_PKGPC) \$@
    ++  \$(PP_SED) \$@
     +  \$(v)sed -e "s|@PREFIX@|$NXT_PREFIX|" \\
            -e "s|@LIBDIR@|$NXT_LIBDIR|" \\
            -e "s|@CFLAGS@|-I$NXT_INCLUDEDIR|" \\
    @@ auto/make: $NXT_BUILD_DIR/share/pkgconfig/unit.pc: src/unit.pc.in

      $NXT_BUILD_DIR/share/pkgconfig/unit-uninstalled.pc: src/unit.pc.in
     -  sed -e "s|@PREFIX@|$(pwd)/$NXT_BUILD_DIR|" \\
    -+  \$(PP_PKGPC) \$@
    ++  \$(PP_SED) \$@
     +  \$(v)sed -e "s|@PREFIX@|$(pwd)/$NXT_BUILD_DIR|" \\
            -e "s|@LIBDIR@|$(pwd)/$NXT_BUILD_DIR/lib|" \\
            -e "s|@CFLAGS@|-I$(pwd)/src -I$(pwd)$NXT_BUILD_DIR/include|" \\
 3:  a98bdd5c !  3:  0d81cd07 Pretty print the Java language module compiler output
    @@ Commit message

           $ make V=1 ...

    +    Reviewed-by: Alejandro Colomar <alx@kernel.org>
         Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

      ## auto/modules/java ##
    @@ auto/modules/java: ${NXT_JAVA_MODULE}: $NXT_BUILD_DIR/lib/unit/modules/${NXT_JAV

      $NXT_BUILD_DIR/lib/unit/modules/${NXT_JAVA_MODULE}.unit.so: $nxt_objs
     -  \$(NXT_MODULE_LINK) -o \$@ $nxt_objs $NXT_JAVA_LDFLAGS $NXT_LD_OPT
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_MODULE_LINK) -o \$@ $nxt_objs $NXT_JAVA_LDFLAGS $NXT_LD_OPT

 4:  03942241 !  4:  da118b65 Pretty print the Perl language module compiler output
    @@ Commit message

           $ make V=1 ...

    +    Reviewed-by: Alejandro Colomar <alx@kernel.org>
         Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

      ## auto/modules/perl ##
    @@ auto/modules/perl: all: ${NXT_PERL_MODULE}

      $NXT_BUILD_DIR/lib/unit/modules/${NXT_PERL_MODULE}.unit.so:   $nxt_objs
     -  \$(NXT_MODULE_LINK) -o \$@ $nxt_objs $NXT_PERL_LDOPTS $NXT_LD_OPT
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_MODULE_LINK) -o \$@ $nxt_objs $NXT_PERL_LDOPTS $NXT_LD_OPT

 5:  fed116da !  5:  b58892a6 Pretty print the PHP language module compiler output
    @@ Commit message

           $ make V=1 ...

    +    Reviewed-by: Alejandro Colomar <alx@kernel.org>
         Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

      ## auto/modules/php ##
    @@ auto/modules/php: all: ${NXT_PHP_MODULE}

      $NXT_BUILD_DIR/lib/unit/modules/${NXT_PHP_MODULE}.unit.so:    $nxt_objs
     -  \$(NXT_MODULE_LINK) -o \$@ \\
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_MODULE_LINK) -o \$@ \\
        $nxt_objs ${NXT_PHP_LIB} ${NXT_PHP_LDFLAGS} $NXT_LD_OPT

 6:  0c5773c5 !  6:  c327be71 Pretty print the Python language module compiler output
    @@ Commit message

           $ make V=1 ...

    +    Reviewed-by: Alejandro Colomar <alx@kernel.org>
         Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

      ## auto/modules/python ##
    @@ auto/modules/python: all: ${NXT_PYTHON_MODULE}

      $NXT_BUILD_DIR/lib/unit/modules/${NXT_PYTHON_MODULE}.unit.so: $nxt_objs
     -  \$(NXT_MODULE_LINK) -o \$@ \\
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_MODULE_LINK) -o \$@ \\
        $nxt_objs $NXT_PYTHON_LIBS $NXT_PYTHON_LDFLAGS $NXT_LD_OPT

 7:  4bb8a03b !  7:  8805ba24 Pretty print the Ruby language module compiler output
    @@ Commit message

           $ make V=1 ...

    +    Reviewed-by: Alejandro Colomar <alx@kernel.org>
         Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

      ## auto/modules/ruby ##
    @@ auto/modules/ruby: all: ${NXT_RUBY_MODULE}

      $NXT_BUILD_DIR/lib/unit/modules/${NXT_RUBY_MODULE}.unit.so:   $nxt_objs
     -  \$(NXT_MODULE_LINK) -o \$@ $nxt_objs $NXT_RUBY_LIBS $NXT_LD_OPT
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_MODULE_LINK) -o \$@ $nxt_objs $NXT_RUBY_LIBS $NXT_LD_OPT

 8:  75098dd9 !  8:  e296a8ed Pretty print the wasm language module compiler output
    @@ Commit message

           $ make V=1 ...

    +    Reviewed-by: Alejandro Colomar <alx@kernel.org>
         Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

      ## auto/modules/wasm ##
    @@ auto/modules/wasm: all: ${NXT_WASM_MODULE}

      $NXT_BUILD_DIR/lib/unit/modules/${NXT_WASM_MODULE}.unit.so:   $nxt_objs
     -  \$(NXT_MODULE_LINK) -o \$@ \\
    -+  \$(PP_LNK) \$@
    ++  \$(PP_LD) \$@
     +  \$(v)\$(NXT_MODULE_LINK) -o \$@ \\
            $nxt_objs -L${NXT_WASM_LIB_PATH} ${NXT_WASM_LDFLAGS} $NXT_LD_OPT

 9:  45a78697 !  9:  96baa46e Enable optional 'debuggable' builds
    @@ Commit message

           $ make D=1 ...

    -    Which will set -O0 overriding the -O, basically disabling optimisations,
    -    we could use -Og, but the clang(1) man page says this is best and it
    -    seems to not cause any issues when debugging GCC generated code.
    +    Which will set -O0 overriding the previously set -O, basically disabling
    +    optimisations, we could use -Og, but the clang(1) man page says this is
    +    best and it seems to not cause any issues when debugging GCC generated
    +    code.

    +    Co-developed-by: Alejandro Colomar <alx@kernel.org>
    +    Signed-off-by: Alejandro Colomar <alx@kernel.org>
         Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

      ## auto/cc/test ##
    @@ auto/cc/test: case $NXT_CC_NAME in

      ## auto/make ##
     @@ auto/make: ifeq (\$V,1)
    -         v =
    +         v :=
      endif

     +# Optionally enable debugging builds with
    @@ auto/make: ifeq (\$V,1)
     +# -g is always used, this just changes the optimisation level.
     +# On GCC this would be -Og, however according to the clang(1)
     +# man page, -O0 'generates the most debuggable code'.
    -+#
    -+# This will override the previous -0
    ++D := 0
    ++
     +ifeq (\$D,1)
     +        CFLAGS += -O0
     +endif
10:  5993a2e4 ! 10:  c32f688c Allow to disable -Werror at 'make' time
    @@ Commit message

           $ make E=0 ...

    -    I would normally do it the other way around, but this keeps the existing
    -    default behaviour.
    +    This will set -Wno-error overriding the previously set -Werror.

    +    Co-developed-by: Alejandro Colomar <alx@kernel.org>
    +    Signed-off-by: Alejandro Colomar <alx@kernel.org>
         Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

      ## auto/make ##
    @@ auto/make: ifeq (\$D,1)

     +# Optionally disable -Werror with
     +#   make E=0 ...
    ++E := 1
    ++
     +ifeq (\$E,0)
     +        CFLAGS += -Wno-error
     +endif
11:  1008e332 ! 11:  2e398798 Add a help target to the root Makefile
    @@ Commit message

             Variables can be combined.

    +    Reviewed-by: Alejandro Colomar <alx@kernel.org>
         Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

      ## auto/make ##
    @@ auto/make: include $NXT_MAKEFILE
     +  @echo "  make E=0 ...           - Disables -Werror"
     +  @echo
     +  @echo "  Variables can be combined."
    ++
      END
12:  900ce87f ! 12:  d609c615 Add an EXTRA_CFLAGS make variable
    @@ Commit message
         Useful for quickly testing various extra warning flags.

         Suggested-by: Alejandro Colomar <alx@kernel.org>
    +    Reviewed-by: Alejandro Colomar <alx@kernel.org>
         Signed-off-by: Andrew Clayton <a.clayton@nginx.com>

      ## auto/make ##
    -@@ auto/make: PP_PKGPC = @echo '  PKGPC '
    +@@ auto/make: PP_SED       := @echo '  SED   '
      CC =          $CC
      AR =          $AR

    @@ auto/make: help:
     +  @echo "  make EXTRA_CFLAGS= ... - Add extra compiler options"
     +  @echo
        @echo "  Variables can be combined."
    + 
      END
ac000 commented 6 months ago

Rebase with master

$ git range-diff d609c615...a171b399
 -:  -------- >  1:  8032ce31 Test with root access in GitHub workflows
 -:  -------- >  2:  0cee7d1a Add GitHub workflow for wasm-wasi-component
 -:  -------- >  3:  63bc3882 .mailmap: Map Dylan's 2nd GitHub address
 -:  -------- >  4:  f6899af6 Var: Fix cacheable issue for njs variable access
 -:  -------- >  5:  5511593d Remove support for Microsoft's Visual C++ compiler
 -:  -------- >  6:  0c2d7786 Remove support for Intel's icc compiler
 -:  -------- >  7:  e79e4635 Remove support for IBM's XL C compiler
 -:  -------- >  8:  9cd11133 Remove support for Sun's Sun Studio/SunPro C compiler
 -:  -------- >  9:  806e209d Remove -W from compiler flags
 -:  -------- > 10:  1dcb5383 Expand the comment about -Wstrict-overflow on GCC
 -:  -------- > 11:  0b5223e1 Disable strict-aliasing in clang by default
 -:  -------- > 12:  c1e3f02f Compile with -fno-strict-overflow
 1:  906be106 = 13:  280a978d Add initial infrastructure for pretty printing make output
 2:  6bf9d5f4 = 14:  5d831af0 Hook up make pretty printing to the Unit core and tests
 3:  0d81cd07 = 15:  da335bec Pretty print the Java language module compiler output
 4:  da118b65 = 16:  574528f7 Pretty print the Perl language module compiler output
 5:  b58892a6 = 17:  0a0dcf91 Pretty print the PHP language module compiler output
 6:  c327be71 = 18:  caaa1d28 Pretty print the Python language module compiler output
 7:  8805ba24 = 19:  133f75fd Pretty print the Ruby language module compiler output
 8:  e296a8ed = 20:  b763ba7e Pretty print the wasm language module compiler output
 9:  96baa46e ! 21:  15072fbd Enable optional 'debuggable' builds
    @@ auto/cc/test: case $NXT_CC_NAME in

              NXT_CFLAGS="$NXT_CFLAGS -O"
     -        #NXT_CFLAGS="$NXT_CFLAGS -O0"
    -         NXT_CFLAGS="$NXT_CFLAGS -W -Wall -Wextra"
    +         NXT_CFLAGS="$NXT_CFLAGS -Wall -Wextra"

              #NXT_CFLAGS="$NXT_CFLAGS -Wunused-result"
     @@ auto/cc/test: case $NXT_CC_NAME in
    -         NXT_CFLAGS="$NXT_CFLAGS -fvisibility=hidden"
    +         NXT_CFLAGS="$NXT_CFLAGS -fno-strict-overflow"

              NXT_CFLAGS="$NXT_CFLAGS -O"
     -        #NXT_CFLAGS="$NXT_CFLAGS -O0"
    -         NXT_CFLAGS="$NXT_CFLAGS -W -Wall -Wextra"
    +         NXT_CFLAGS="$NXT_CFLAGS -Wall -Wextra"

              #NXT_CFLAGS="$NXT_CFLAGS -Wunused-result"

10:  c32f688c = 22:  d23812b8 Allow to disable -Werror at 'make' time
11:  2e398798 = 23:  f55fa70c Add a help target to the root Makefile
12:  d609c615 = 24:  a171b399 Add an EXTRA_CFLAGS make variable