Re: [PATCH 08/10] nginx{,-module}.eclass: save NGINX build config by storing ./configure flags
Peter Volkov <[email protected]> Tue, 4 Aug 2026 00:53:09 +0300
| Newsgroups | gmane.linux.gentoo.devel |
|---|---|
| Message-ID | <CAE+k_gJH-pP-rj1DvK8dXUrD8e3q0Lhvh=NqVxsyMBVYbSVEsg@mail.gmail.com> |
--00000000000017bf4606582b91d4
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Hi!
On Sat, Jul 18, 2026 at 7:45=E2=80=AFPM Zurab Kvachadze <zurabid2016@gmail.=
com>
wrote:
> +# @ECLASS_VARIABLE: _NGX_MOD_CONFIG_FLAGS_FILE
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Holds the path to the file containing NUL-separated ./configure flags
used to
> +# build www-servers/nginx.
> +_NGX_MOD_CONFIG_FLAGS_FILE=3D"${BROOT}/usr/src/nginx/configure-flags"
Take a look at table 8.2 of PMS
https://projects.gentoo.org/pms/latest/pms.html.
Eclass is referencing target build-time dependencies here; ESYSROOT is
expected
instead of BROOT.
Since the variable is global, it would be better to store only the
root-relative path:
_NGX_MOD_CONFIG_FLAGS_FILE=3D"/usr/src/nginx/configure-flags"
Then prefix it with ESYSROOT in src_* phases, or with EROOT if it is ever
used in pkg_* phases.
> nginx-module_src_configure() {
> ...
> + if [[ -f "${_NGX_MOD_CONFIG_FLAGS_FILE}" ]]; then
> + # Restore the stored configure flags into ngx_mod_flags.
> + mapfile -d '' ngx_mod_flags <
"${_NGX_MOD_CONFIG_FLAGS_FILE}"
> + # When we save compilation flags, NGINX passes all the -l
flags to
> + # modules too, including stuff like -lperl -lcrypt etc. I
am not sure
> + # what to do with this yet so for now we just pass the
following to
> + # limit unnecessary linkage.
> + ngx_mod_append_libs "$(test-flags-CC '-Wl,--as-needed')"
It looks like test-flags-CCLD is needed here.
BTW, could you please check whether --as-needed is passed before the
libraries? It currently appears
to be appended after them, in which case it has no effect on those
libraries, according to the manual:
https://sourceware.org/binutils/docs/ld/Options.html
"This option affects ELF DT_NEEDED tags for dynamic libraries mentioned on
the command line after the --as-needed option."
> @@ -673,6 +683,13 @@ nginx_src_configure() {
> "$@" \
> "${EXTRA_ECONF[@]}"
>
> + # Store the configuration flags to install to /usr/src/nginx
later for
> + # module building.
> + if use modules; then
> + printf '%s\0' "${nginx_flags[@]}" "$@"
"${EXTRA_ECONF[@]}" \
> + >> "${_NGX_CONFIG_FLAGS_FILE}"
> + fi
Maybe'>' would be better here, since this is the only place where the file
is created.
--
Peter.
--00000000000017bf4606582b91d4
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Hi!<br><br>On Sat, Jul 18, 2026 at 7:45=E2=80=AFPM Zu=
rab Kvachadze <<a href=3D"mailto:[email protected]">zurabid2016@gmai=
l.com</a>> wrote:<br>> +# @ECLASS_VARIABLE: _NGX_MOD_CONFIG_FLAGS_FIL=
E<br>> +# @INTERNAL<br>> +# @DESCRIPTION:<br>> +# Holds the path t=
o the file containing NUL-separated ./configure flags used to<br>> +# bu=
ild www-servers/nginx.<br>> +_NGX_MOD_CONFIG_FLAGS_FILE=3D"${BROOT}=
/usr/src/nginx/configure-flags"<br><br>Take a look at table 8.2 of PMS=
<a href=3D"https://projects.gentoo.org/pms/latest/pms.html"><span><span>ht=
tps://projects.gentoo.org/pms/latest/pms.html</span></span></a>.<br>Eclass =
is referencing target build-time dependencies here;=C2=A0<span aria-invalid=
=3D"spelling" class=3D"LI ng" style=3D"border-style:none;background:none">E=
SYSROOT</span> is expected<br>instead of BROOT.<br><br>Since the variable i=
s global, it would be better to store only the root-relative path:<br>_NGX_=
MOD_CONFIG_FLAGS_FILE=3D"/usr/src/nginx/configure-flags"<br>Then =
prefix it with <span aria-invalid=3D"spelling" class=3D"LI ng" style=3D"bor=
der-style:none;background:none">ESYSROOT</span> in src_* phases, or with ER=
OOT if it is ever used in pkg_* phases.<br><br>> =C2=A0nginx-module_src_=
configure() {<br>> ...<br>> + =C2=A0 =C2=A0 =C2=A0 if [[ -f "${_=
NGX_MOD_CONFIG_FLAGS_FILE}" ]]; then<br>> + =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 # Restore the stored configure flags into ngx_m=
od_flags.<br>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mapfil=
e -d '' ngx_mod_flags < "${_NGX_MOD_CONFIG_FLAGS_FILE}"=
;<br><br>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # When we =
save compilation flags, NGINX passes all the -l flags to<br>> + =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # modules too, including stuff li=
ke -lperl -lcrypt etc. I am not sure<br>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 # what to do with this yet so for now we just pass the=
following to<br>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # =
limit unnecessary linkage.<br>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 ngx_mod_append_libs "$(test-flags-CC '-Wl,--as-needed&#=
39;)"<br><br>It looks like test-flags-CCLD is needed here.<br><br>BTW,=
could you please check whether --as-needed is passed before the libraries?=
It currently appears<br>to be appended after them, in which case it has no=
effect on those libraries, according to the manual:<br><a href=3D"https://=
sourceware.org/binutils/docs/ld/Options.html">https://sourceware.org/binuti=
ls/docs/ld/Options.html</a>=C2=A0<br><br>"This option affects ELF DT_N=
EEDED tags for dynamic libraries mentioned on the command line after the --=
as-needed option."<br><br>> @@ -673,6 +683,13 @@ nginx_src_configur=
e() {<br>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "=
;$@" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\<br>> =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "${EXTRA_ECONF[@]=
}"<br>><br>> + =C2=A0 =C2=A0 =C2=A0 # Store the configuration fl=
ags to install to /usr/src/nginx later for<br>> + =C2=A0 =C2=A0 =C2=A0 #=
module building.<br>> + =C2=A0 =C2=A0 =C2=A0 if use modules; then<br>&g=
t; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf '%s\0'=
"${nginx_flags[@]}" "$@" "${EXTRA_ECONF[@]}"=
\<br>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
=C2=A0 =C2=A0 >> "${_NGX_CONFIG_FLAGS_FILE}"<br>> + =C2=
=A0 =C2=A0 =C2=A0 fi<br><br></div><div>Maybe'>' would be better =
here, since this is the only place where the file is created.<br><br>--<br>=
</div><div>Peter.</div></div>
--00000000000017bf4606582b91d4--