Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --with-regex=PATH build option #1974

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,6 @@ AC_CHECK_HEADERS( \
poll.h \
priv.h \
pwd.h \
regex.h \
sched.h \
siginfo.h \
signal.h \
Expand Down Expand Up @@ -2148,9 +2147,6 @@ AC_CHECK_FUNCS(\
pthread_setschedparam \
pthread_sigmask \
putenv \
regcomp \
regexec \
regfree \
res_init \
__res_init \
rint \
Expand Down Expand Up @@ -2387,8 +2383,16 @@ AS_IF([test "x$enable_zph_qos" = "xyes"],[
[Enable support for QOS netfilter mark preservation])
])

AC_CHECK_LIB(regex, regexec, [REGEXLIB="-lregex"],[REGEXLIB=''])
AC_SUBST(REGEXLIB)
dnl Look for libregex with regcomp() API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see any regcomp() checks in added code; have I overlooked them?

AFAICT, removed code was checking for regexec(). If feasible, let's preserve that logic (in this PR). Otherwise, please adjust PR description to explain why we are changing what API we check.

SQUID_AUTO_LIB(regex,[GNU Regex],[LIBREGEX])
SQUID_CHECK_LIB_WORKS(regex,[
PKG_CHECK_MODULES([LIBREGEX],[libregex],[:],[:])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm.. what if the local install doesn't have a pkg-config file? For instance, my install of gnurx doesn't have one

Copy link
Contributor

@rousskov rousskov Dec 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kinkie, AFAICT, without pkg-config file, this PKG_CHECK_MODULES() call does nothing (but reporting) because its action-if-not-found is set to "do nothing" (i.e. :). The code below will add spaces to CPPFLAGS and LIBS (unless those LIBREGEX_FOO variables were set externally, I guess).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absent a relevant .pc file or when environment variables are preset this line has no effect.

This line exists solely for auto-detecting the cases when a libregex does provide a .pc file.

CPPFLAGS="$LIBREGEX_CFLAGS $CPPFLAGS"
LIBS="$LIBREGEX_PATH $LIBREGEX_LIBS $LIBS"
AC_CHECK_HEADERS([regex.h],[
LIBREGEX_LIBS="$LIBREGEX_PATH -lregex"
Comment on lines +2391 to +2393
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks odd that we are using LIBREGEX_LIBS to adjust LIBS and then modifying LIBREGEX_LIBS (while keeping the old value in LIBS). Why do we utilize this use-then-modify trick here?

And why does this linking-related LIBREGEX_LIBS manipulation depend on a C++ header presence (while other regex checks/adjustments do not)?

])
])

SQUID_DETECT_UDP_SND_BUFSIZE
SQUID_DETECT_UDP_RECV_BUFSIZE
Expand Down
6 changes: 6 additions & 0 deletions doc/release-notes/release-7.sgml.in
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ This section gives an account of those changes in three categories:
<sect1>New options<label id="newoptions">
<p>
<descrip>
<tag>--with-regex=PATH</tag>
<p>Added ability to build against custom installs of the
GNU Regular Expression library.
<p>Note: <em>libregex</em> is required to build Squid.
Using the <em>--without-regex</em> option will fail.

<tag>--without-gss</tag>
<p>Renamed from <em>--without-gnugss</em>.

Expand Down
16 changes: 8 additions & 8 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ squid_LDADD = \
$(XTRA_OBJS) \
$(REPL_OBJS) \
$(CRYPTLIB) \
$(REGEXLIB) \
$(ADAPTATION_LIBS) \
html/libhtml.la \
$(SNMP_LIBS) \
Expand All @@ -554,6 +553,7 @@ squid_LDADD = \
$(LIBNETFILTER_CONNTRACK_LIBS) \
$(LIBNETTLE_LIBS) \
$(LIBPSAPI_LIBS) \
$(LIBREGEX_LIBS) \
$(XTRA_LIBS)

if ENABLE_LOADABLE_MODULES
Expand Down Expand Up @@ -1171,12 +1171,12 @@ tests_testRock_LDADD = \
$(top_builddir)/lib/libmisccontainers.la \
$(top_builddir)/lib/libmiscencoding.la \
$(top_builddir)/lib/libmiscutil.la \
$(REGEXLIB) \
$(SSLLIB) \
$(LIBCPPUNIT_LIBS) \
$(LIBGNUTLS_LIBS) \
$(COMPAT_LIB) \
$(LIBNETTLE_LIBS) \
$(LIBREGEX_LIBS) \
$(XTRA_LIBS)
tests_testRock_LDFLAGS = $(AM_CPPFLAGS) $(LIBADD_DL)
else
Expand Down Expand Up @@ -1347,12 +1347,12 @@ tests_testUfs_LDADD = \
$(top_builddir)/lib/libmisccontainers.la \
$(top_builddir)/lib/libmiscencoding.la \
$(top_builddir)/lib/libmiscutil.la \
$(REGEXLIB) \
$(SSLLIB) \
$(LIBCPPUNIT_LIBS) \
$(LIBGNUTLS_LIBS) \
$(COMPAT_LIB) \
$(LIBNETTLE_LIBS) \
$(LIBREGEX_LIBS) \
$(XTRA_LIBS)
tests_testUfs_LDFLAGS = $(LIBADD_DL)
else
Expand Down Expand Up @@ -1509,13 +1509,13 @@ tests_testStore_LDADD= \
$(top_builddir)/lib/libmisccontainers.la \
$(top_builddir)/lib/libmiscencoding.la \
$(top_builddir)/lib/libmiscutil.la \
$(REGEXLIB) \
$(SSLLIB) \
CommCalls.o \
$(LIBCPPUNIT_LIBS) \
$(LIBGNUTLS_LIBS) \
$(COMPAT_LIB) \
$(LIBNETTLE_LIBS) \
$(LIBREGEX_LIBS) \
$(XTRA_LIBS)
tests_testStore_LDFLAGS = $(LIBADD_DL)

Expand Down Expand Up @@ -1685,12 +1685,12 @@ tests_testDiskIO_LDADD = \
$(top_builddir)/lib/libmisccontainers.la \
$(top_builddir)/lib/libmiscencoding.la \
$(top_builddir)/lib/libmiscutil.la \
$(REGEXLIB) \
$(SSLLIB) \
$(LIBCPPUNIT_LIBS) \
$(LIBGNUTLS_LIBS) \
$(COMPAT_LIB) \
$(LIBNETTLE_LIBS) \
$(LIBREGEX_LIBS) \
$(XTRA_LIBS)
tests_testDiskIO_LDFLAGS = $(LIBADD_DL)

Expand Down Expand Up @@ -1991,7 +1991,6 @@ tests_testHttpRange_LDADD = \
$(LIBCAP_LIBS) \
$(LIBGNUTLS_LIBS) \
$(LIBHEIMDAL_KRB5_LIBS) \
$(REGEXLIB) \
$(SSLLIB) \
$(LIBCPPUNIT_LIBS) \
$(LIBSYSTEMD_LIBS) \
Expand All @@ -2001,6 +2000,7 @@ tests_testHttpRange_LDADD = \
$(LIBNETFILTER_CONNTRACK_LIBS) \
$(LIBNETTLE_LIBS) \
$(LIBPSAPI_LIBS) \
$(LIBREGEX_LIBS) \
$(XTRA_LIBS)
tests_testHttpRange_LDFLAGS = $(LIBADD_DL)

Expand Down Expand Up @@ -2378,7 +2378,6 @@ tests_testHttpRequest_LDADD = \
$(LIBCAP_LIBS) \
$(LIBGNUTLS_LIBS) \
$(LIBHEIMDAL_KRB5_LIBS) \
$(REGEXLIB) \
$(SSLLIB) \
$(LIBCPPUNIT_LIBS) \
$(LIBSYSTEMD_LIBS) \
Expand All @@ -2388,6 +2387,7 @@ tests_testHttpRequest_LDADD = \
$(LIBNETFILTER_CONNTRACK_LIBS) \
$(LIBNETTLE_LIBS) \
$(LIBPSAPI_LIBS) \
$(LIBREGEX_LIBS) \
$(XTRA_LIBS)
tests_testHttpRequest_LDFLAGS = $(LIBADD_DL)

Expand Down Expand Up @@ -2675,7 +2675,6 @@ tests_testCacheManager_LDADD = \
$(LIBCAP_LIBS) \
$(LIBGNUTLS_LIBS) \
$(LIBHEIMDAL_KRB5_LIBS) \
$(REGEXLIB) \
$(SSLLIB) \
$(LIBCPPUNIT_LIBS) \
$(LIBSYSTEMD_LIBS) \
Expand All @@ -2685,6 +2684,7 @@ tests_testCacheManager_LDADD = \
$(LIBNETFILTER_CONNTRACK_LIBS) \
$(LIBNETTLE_LIBS) \
$(LIBPSAPI_LIBS) \
$(LIBREGEX_LIBS) \
$(XTRA_LIBS)
tests_testCacheManager_LDFLAGS = $(LIBADD_DL)

Expand Down