Skip to content

cmake: rework binutils ld hack to not read LOCATION property#20839

Closed
vszakats wants to merge 1 commit intocurl:masterfrom
vszakats:cm-simplify-dupes
Closed

cmake: rework binutils ld hack to not read LOCATION property#20839
vszakats wants to merge 1 commit intocurl:masterfrom
vszakats:cm-simplify-dupes

Conversation

@vszakats
Copy link
Copy Markdown
Member

@vszakats vszakats commented Mar 6, 2026

Instead hook up the upstream target name as-is to the local wrapper
target.

To:

  • make the hack work regardless of how the upstream target was created.
  • make it work the same way in curl-config.cmake.
    Before this patch it had no guard for IMPORTED targets even though
    find_dependencies() is not guaranteed to create the target expected
    if it already existed and was potentially created differently.

Depends-on: #20840
Follow-up to 4f1646e #20486 #20419


@vszakats vszakats marked this pull request as draft March 6, 2026 14:44
@vszakats vszakats changed the title cmake: try simplifying the dupe lib hack (for binutils ld) cmake: make the binutils ld hack not need LOCATION access Mar 6, 2026
@vszakats vszakats changed the title cmake: make the binutils ld hack not need LOCATION access cmake: rework the binutils ld hack to not need LOCATION access Mar 6, 2026
@vszakats vszakats changed the title cmake: rework the binutils ld hack to not need LOCATION access cmake: rework binutils ld hack to not need LOCATION access Mar 6, 2026
@vszakats vszakats changed the title cmake: rework binutils ld hack to not need LOCATION access cmake: rework binutils ld hack to not read LOCATION property Mar 6, 2026
@vszakats vszakats marked this pull request as ready for review March 6, 2026 15:47
vszakats added a commit to vszakats/curl that referenced this pull request Mar 6, 2026
To allow simplifying the binutils ld hack, by chaining the original
imported target to curl's local duplicate target. Also to allow linking
to dependencies' native imported targes via their CMake Configs, which
may similarly be chained by default.

Fixing (seen on Linux with simplified binutils hack via curl#20839):
```
 Requires:
 Requires.private: libzstd openssl zlib
 Libs: -L${libdir} -lcurl
-Libs.private:  -lcrypto -lssl -lz -lzstd
+Libs.private:  -lOpenSSL::Crypto -lZLIB::ZLIB -lcrypto -lssl -lz -lzstd
 Cflags: -I${includedir}
 Cflags.private: -DCURL_STATICLIB
Error: Process completed with exit code
```
Ref: https://github.com/curl/curl/actions/runs/22768301699/job/66041980258?pr=20839

Cherry-picked from curl#20814
Cherry-picked from curl#20839
vszakats added a commit that referenced this pull request Mar 16, 2026
To allow simplifying the binutils ld hack, by chaining the original
imported target to curl's local duplicate target. Also to allow linking
to dependencies' native imported targets via their CMake Configs, which
will always be hooked up to a `CURL::` interface, and may also be
chained upstream.

Fixing (seen on Linux with simplified binutils hack via #20839):
```
 Requires:
 Requires.private: libzstd openssl zlib
 Libs: -L${libdir} -lcurl
-Libs.private:  -lcrypto -lssl -lz -lzstd
+Libs.private:  -lOpenSSL::Crypto -lZLIB::ZLIB -lcrypto -lssl -lz -lzstd
 Cflags: -I${includedir}
 Cflags.private: -DCURL_STATICLIB
Error: Process completed with exit code
```
Ref: https://github.com/curl/curl/actions/runs/22768301699/job/66041980258?pr=20839

Note this makes it possible to run into an infinite loop because CMake
allows cyclic dependencies. It isn't added by curl's CMake script nor by
any dependencies as defined by default, but may happen in theory with
custom-created targets. In such case CMake automatically stops with
an error at 1000 iterations. I find it overkill to add custom protection
for it.

Cherry-picked from #20814
Cherry-picked from #20839

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

Development

Successfully merging this pull request may close these issues.

1 participant