Skip to content

Fix missing LDFLAGS when linking squid binary#2396

Open
yadij wants to merge 1 commit intosquid-cache:masterfrom
yadij:fix-missing-ldflags
Open

Fix missing LDFLAGS when linking squid binary#2396
yadij wants to merge 1 commit intosquid-cache:masterfrom
yadij:fix-missing-ldflags

Conversation

@yadij
Copy link
Copy Markdown
Contributor

@yadij yadij commented Apr 1, 2026

The auto-tools build system defines AM_LDFLAGS as the place for
tools to add linker flags automatically determined to be needed,
so as not to clobber user provide flags in LDFLAGS variable.

This AM_* variable can be replaced in the linker command line
for binary 'foo' by defining a replacement foo_LDFLAGS variable
in Makefile.am.

When third-party build and test tools use AM_LDFLAGS to pass additional
flags to our build process, the current squid_LDFLAGS ignores them.

The auto-tools build system defines AM_LDFLAGS
as the place for tools to add linker flags
automatically determined to be needed, so as
not to clobber user provide flags in LDFLAGS
variable.

This AM_* variable can be replaced in the linker
command line for binary 'foo' by defining a
replacement foo_LDFLAGS variable in Makefile.am.

When third-party build and test tool use AM_LDFLAGS
to pass flags to our build process additional flags
the current squid_LDFLAGS ignores them.
Copy link
Copy Markdown
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

Thank you for explaining the problem in the PR description.

I have adjusted the last PR description paragraph for clarity (and to polish grammar). Please check that I got the original intent right.

squid_LDFLAGS = -export-dynamic -dlopen force
squid_LDFLAGS = $(AM_LDFLAGS) -export-dynamic -dlopen force
## when static module linking is supported and enabled:
## squid_LDFLAGS = -all-static -dlopen self
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If AM_LDFLAGS addition above is proven to be needed, please keep this commented out hint in sync (or remove it).

Suggested change
## squid_LDFLAGS = -all-static -dlopen self
## squid_LDFLAGS = $(AM_LDFLAGS) -all-static -dlopen self

squid_SOURCES += $(LOADABLE_MODULES_SOURCES)
squid_LDADD += -L$(top_builddir) $(LIBLTDL)
squid_LDFLAGS = -export-dynamic -dlopen force
squid_LDFLAGS = $(AM_LDFLAGS) -export-dynamic -dlopen force
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PR description (with emphasis added by me): "AM_LDFLAGS [is] the place for tools to add linker flags automatically determined to be needed".

Autotools documentation (with emphasis added by me): "This is the variable the Makefile.am author can use to pass in additional linker flags"

AFAICT, the two quotes above contradict each other.

If autotools documentation is correct, then this PR is not needed because we (i.e. Makefile.am authors) do not define AM_LDFLAGS; we apparently do not want to "pass additional linker flags" (at this time) and cannot tell whether future "additional linker flags" (if any) would need to be added when linking squid executable.

If PR description is proven to be correct, then more Makefile.am changes are needed in this PR because, in that case, we need to add AM_LDFLAGS to all ~36 executables that use custom linking commands (e.g., testMath and testMem) and, hence, do not get AM_LDFLAGS auto-added by autotools today.

Before making widespread changes, let's determine what documentation is correct and confirm the need for this PR: In your environment, what "tool" adds "linker flags automatically determined to be needed" to AM_LDFLAGS?

@rousskov rousskov added the S-waiting-for-author author action is expected (and usually required) label Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-for-author author action is expected (and usually required)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants