Skip to content

Disable LTO for ZLIB#19

Merged
jviotti merged 1 commit intomainfrom
nolto-zlib
Mar 16, 2026
Merged

Disable LTO for ZLIB#19
jviotti merged 1 commit intomainfrom
nolto-zlib

Conversation

@jviotti
Copy link
Member

@jviotti jviotti commented Mar 13, 2026

Signed-off-by: Juan Cruz Viotti jv@jviotti.com

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@augmentcode
Copy link

augmentcode bot commented Mar 13, 2026

🤖 Augment PR Summary

Summary: Disables LTO when building the vendored zlib target under GCC.

Motivation: Works around a GCC LTO linker plugin issue where the zlib archive may not be rescanned for transitive dependencies, leading to link failures in LTO builds.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

# Disable LTO for zlib to work around GCC LTO linker plugin not
# properly rescanning this archive for transitive dependencies
if(HYDRA_COMPILER_GCC)
target_compile_options(zlib PRIVATE -fno-lto)
Copy link

Choose a reason for hiding this comment

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

If the project enables LTO globally (e.g., via INTERPROCEDURAL_OPTIMIZATION/CMAKE_INTERPROCEDURAL_OPTIMIZATION), it’s worth double-checking that adding -fno-lto here reliably overrides any injected -flto so zlib is truly built non-LTO in those configurations. Otherwise the GCC LTO plugin issue this comment mentions could still reproduce.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="cmake/FindZLIB.cmake">

<violation number="1" location="cmake/FindZLIB.cmake:70">
P2: Scope this LTO workaround to static zlib builds; as written it also disables LTO for shared builds that are not affected by the archive-rescan issue.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


# Disable LTO for zlib to work around GCC LTO linker plugin not
# properly rescanning this archive for transitive dependencies
if(HYDRA_COMPILER_GCC)
Copy link

@cubic-dev-ai cubic-dev-ai bot Mar 13, 2026

Choose a reason for hiding this comment

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

P2: Scope this LTO workaround to static zlib builds; as written it also disables LTO for shared builds that are not affected by the archive-rescan issue.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At cmake/FindZLIB.cmake, line 70:

<comment>Scope this LTO workaround to static zlib builds; as written it also disables LTO for shared builds that are not affected by the archive-rescan issue.</comment>

<file context>
@@ -64,6 +64,12 @@ if(NOT ZLIB_FOUND)
+
+    # Disable LTO for zlib to work around GCC LTO linker plugin not
+    # properly rescanning this archive for transitive dependencies
+    if(HYDRA_COMPILER_GCC)
+      target_compile_options(zlib PRIVATE -fno-lto)
+    endif()
</file context>
Suggested change
if(HYDRA_COMPILER_GCC)
if(HYDRA_COMPILER_GCC AND NOT BUILD_SHARED_LIBS)
Fix with Cubic

@jviotti jviotti merged commit eef9a60 into main Mar 16, 2026
36 of 38 checks passed
@jviotti jviotti deleted the nolto-zlib branch March 16, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant