Dynamic Modules - Support CXXFLAGS

Maxim Dounin mdounin at mdounin.ru
Wed Mar 4 16:30:06 UTC 2020


Hello!

On Fri, Feb 28, 2020 at 10:14:31AM +0100, Patrik Mada wrote:

> Dear NGINX developers,
> 
> we are using C++ dynamic modules in our NGINX based servers, 
> while multiple Debian distributions have to be supported.
> On older Debian distributions it is impossible to use more 
> recent C++ standard, due to build defaulting to system provided 
> clang package.
> 
> Our developers stood before decision to either create wrappers 
> around modern C++ libraries which would be compliant with older 
> standards or write the entire logic using obsolete featureless 
> language.
> Neither of these approaches is sustainable in terms of 
> developers' productivity and long term maintenance.
> 
> Would it be possible to consider a change in dynamic modules' 
> build system, so that C++ flags may be provided?
> We propose a low intrusive changes concerning 3 files. The 
> changes are backwards compatible: if CXX is not provided by an 
> user, the build uses CC instead (as well as CFLAGS instead of 
> CXXFLAGS).
> 
> Would you be so kind and share your opinion on those? Please 
> find attachment provided bellow (the patch was created using 
> Quilt).

The most serious problem I see with this approach is that nginx 
does not try to use C++ itself, and hence it will always fail to 
properly detect and use separate C++ compiler and/or provide 
reasonable C++ compiler flags.  And, given that CXX might be set 
to something completely different from CC, it does not look like a 
problem which is easy to solve.

Further, as far as I see from your patch, it simply does not 
try provide any flags at all, except those set explicitly with 
CXXFLAGS.  While this might work in your particular case, this 
looks wrong, and certainly not in line with how things are handled 
now, with CFLAGS set based on compiler unless explicitly 
specified.

A better approach might be to either provide reasonable CFLAGS 
(and/or --with-cc-opt) for a particular system, which will make it 
compile your C++ code with the same compiler and compiler flags as 
used to compile nginx itself.  Or, if it is not possible for some 
reason, to provide a config.make script to provide instructions on 
how to compile your code independently.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx-devel mailing list