Out-of-tree module building (PoC) for Linux Distro's.

Maxim Dounin mdounin at mdounin.ru
Mon Sep 30 19:54:57 UTC 2019


On Mon, Sep 30, 2019 at 11:46:02AM -0700, Auke Kok wrote:

> Hi folks,
> In Clear Linux OS, we generally prefer to build DSO modules separately
> from the server code. We do this for e.g. php modules using `phpize`.
> For nginx, this is 3/4 of the way there, except it fails on the last
> part - modules instructions clearly indicate that modules, with all
> their dependencies, need to build together. But in reality, there is no
> technical reason for this.
> For Clear Linux therefore, I've come up with the following approach and
> it works really well, and therefore I'd like this to be considered as a
> PoC for possible inclusion/consideration so other distributions can
> benefit from the simplicity that it offers to Linux distributions.
> https://github.com/clearlinux-pkgs/nginx-mainline/blob/master/0003-Add-nginx-module-build-install-script.patch
> Now, this script is mostly still a terrible hack. I'm not properly
> fetching the nginx module names for instance. However, the method of
> installing header files saves us from having to include nginx source
> code in *every* nginx module, which will prevent lots of problems later on.
> Obviously a permanent solution would be for the module build system to
> properly -I/usr/include/nginx instead of copying headers, as well.

Building nginx module requires nginx source code.  You can, 
however, build nginx modules independently - that is, without 
building other modules (except when there are dependencies), and 
even nginx itself.  There is a special "modules" target in the 
top-level Makefile as generated by configure, which builds all the 
modules configured in a particular source tree, but not nginx 
itself - and it looks like you are aware of this make target.

The most important part to make sure that nginx and independently 
built modules will work together is to keep configure arguments 
compatible between builds.  Most simple solution is to use 
`--with-compat` configure flag when building nginx itself and all 
the modules.

There are no plans to make it possible to build modules without 
nginx source code.  It is believed that nginx source code is small 
enough to make little to no difference with dedicated "header 
files only" install, and we don't want to bother with maintaining 
such an install.

Note well that simply using all *.h files might not be enough.  
For example, building with Sun C compiler uses *.il files for 
assembler code.

Maxim Dounin

More information about the nginx-devel mailing list