Skip to content

autotools: drop adjacent duplicate LDFLAGS from libcurl.pc - #23348

Closed
vszakats wants to merge 4 commits into
curl:masterfrom
vszakats:am-drop-dupe-ldflags
Closed

vszakats wants to merge 4 commits into
curl:masterfrom
vszakats:am-drop-dupe-ldflags

Conversation

@vszakats

@vszakats vszakats commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

And from curl-config. To avoid repeat pccritic warnings for the same
potential issue.

Use POSIX uniq. It's its first use in curl's autotools code.

Also drop pccritic exception for FreeBSD 15.1, it now passes with
score 98, like the rest of BSD jobs. In this case the dupes were
originating from $LDFLAGSPC.
Ref: #23346 (comment)

Effect to libcurl.pc in the FreeBSD 15.1 CI job:

-Libs.private: -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -lnghttp2 -lidn2 -lldap -llber -lssh2 -lssh2 -lpsl -lssl -lcrypto -lssl -lcrypto -L/usr/local/lib -lgssapi_krb5 -lzstd -lbrotlidec -lbrotlidec -lbrotlicommon -lz -pthread
+Libs.private: -L/usr/local/lib -lnghttp2 -lidn2 -lldap -llber -lssh2 -lssh2 -lpsl -lssl -lcrypto -lssl -lcrypto -L/usr/local/lib -lgssapi_krb5 -lzstd -lbrotlidec -lbrotlidec -lbrotlicommon -lz -pthread

Follow-up to ce0fe71 #23346

@vszakats vszakats added the build label Oct 11, 2026
@github-actions github-actions Bot added the CI Continuous Integration label Oct 11, 2026
@vszakats

vszakats commented Oct 15, 2026 •

Copy link
Copy Markdown
Member Author

Perhaps this could be extended to adjacent -l entries; there are quite
a few of them. This would also make the output more consistent with its
cmake-generated siblings. I hadn't fully gave up on the idea to prevent
duplicates in the first place, and with lib-pairs, e.g. -lssl -lcrypto -lssl -lcrypto,
the uniq method doesn't help anyway.

Perhaps in a separate PR.

Another thought: uniq is ancient and should be present everywhere,
if it causes an issue in some envs anyway, it could be guarded like so:

if uniq </dev/null >/dev/null 2>&1; then
  LIBCURL_PC_LDFLAGS_PRIVATE=`echo $LIBCURL_PC_LDFLAGS_PRIVATE | tr ' ' '\012' | uniq | tr '\012' ' '`
fi

@jay

jay commented Oct 15, 2026

Copy link
Copy Markdown
Member

I'm skeptical of this. Couldn't there be legit reasons to repeat the libraries, like in cases of circular dependency?

@bagder

bagder commented Oct 15, 2026

Copy link
Copy Markdown
Member

Using uniq like in @vszakats' line there (without sort) only removes repeated duplicates, which I don't think ever seen actually fix anything. But I wouldn't be terribly surprised if there exists some reason somewhere to do it...

@vszakats

Copy link
Copy Markdown
Member Author

I'm skeptical of this. Couldn't there be legit reasons to repeat the libraries, like in cases of circular dependency?

No, not when they are adjacent.

@vszakats

vszakats commented Oct 15, 2026 •

Copy link
Copy Markdown
Member Author

Using uniq like in @vszakats' line there (without sort) only removes repeated duplicates, which I don't think ever seen actually fix anything. But I wouldn't be terribly surprised if there exists some reason somewhere to do it...

These duplicates don't seem intentional to me. They rather look like
side-effects of how the detection is implemented for a given
dependency, and what path the actual detection takes. Since they
do not cause linking issues, they go unnoticed.

I had to add tricks to cmp-pkg-config.sh to deal with the dupes
created by autotools, to match up with the CMake-generated
counterparts, which typically don't have them (unless required,
for binutils ld, but those are never adjacent.).

This PR as it is now only removes adjacent idendtical LDFLAGS
(typically -L<dir>), not LIBS. Though duplicate neighbouring LIBS
are also safe to deduplicate, and the CMake script does it explicitly.

(Reordering -L options is also safe. CMake dedupes -L options by keeping the first occurrence only.
However, sorting LIBS is definitely not safe, and removing
non-adjacent LIBS is also not safe.)

@vszakats vszakats closed this in 05da26e Oct 16, 2026
@vszakats
vszakats deleted the am-drop-dupe-ldflags branch October 16, 2026 10:11
vszakats added a commit that referenced this pull request Oct 18, 2026
And from `curl-config`. To reduce redundant items and to bring the lib
lists closer to their CMake-generated counterparts.

Effect to `libcurl.pc` in the FreeBSD 15.1 CI job:
```diff
-Libs.private: -L/usr/local/lib -lnghttp2 -lidn2 -lldap -llber -lssh2 -lssh2 -lpsl -lssl -lcrypto -lssl -lcrypto -L/usr/local/lib -lgssapi_krb5 -lzstd -lbrotlidec -lbrotlidec -lbrotlicommon -lz -pthread
+Libs.private: -L/usr/local/lib -lnghttp2 -lidn2 -lldap -llber -lssh2 -lpsl -lssl -lcrypto -lssl -lcrypto -L/usr/local/lib -lgssapi_krb5 -lzstd -lbrotlidec -lbrotlicommon -lz -pthread
```

Ref: #23348 (comment)
Follow-up to 05da26e #23348

Closes #23447
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build CI Continuous Integration

Development

Successfully merging this pull request may close these issues.

3 participants