Skip to content

Link error with apple-clang and gfortran: ld: -lto_library library filename must be 'libLTO.dylib' #5473

Closed

Description

@Chrismarsh

This is the same problem as in #5202. However, the fix is not robust with new xcode sdk 26.

On Sequoia 15.7 with xcode 26 where XCode version jumped from 16 -> 26.

If Xcode is installed, the check here will return XCVER=26:

package-id: com.apple.pkg.Xcode
version: 26.0.0.0.1.1757562052
volume: /
location: /
install-time: 1758115875

causing the lto fix to not be applied.

ifeq (x$(XCVER), x 16)
override CEXTRALIB := $(filter-out(-lto_library, $(CEXTRALIB))) 
endif

However, XCode doesn't have to be installed to get the command line tools. In this case, there is no return value

pkgutil --pkg-info=com.apple.pkg.Xcode
No receipt for 'com.apple.pkg.Xcode' found at '/'.

causing the second check to be used. Now, weirdly, this can seemingly report either 16 or 26.

I get (aarch64)

pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
package-id: com.apple.pkg.CLTools_Executables
version: 26.0.0.0.1.1757719676
volume: /
location: /
install-time: 1758734670

whereas a colleague on x86_64 Sequoia 15.7 gets

package-id: com.apple.pkg.CLTools_Executables
version: 16.4.0.0.1.1747106510
volume: /
location: /
install-time: 1753176345
```.

In addition, I don't see `INTERPROCEDURAL_OPTIMIZATION` in any of the CMake files, so this problem doesn't exist under CMake builds.

Activity

  1. martin-frbg commented on Sep 29, 2025

    @martin-frbg
    Collaborator

    Guess Apple may not have updated the "legacy" x86_64 XCode to the same "version 26" codebase ? And the difference with respect to CMake might be that the Makefiles default to -O2, while CMake uses -O3 for "Release" builds by default

  2. Chrismarsh commented on Sep 29, 2025

    @Chrismarsh
    ContributorAuthor

    Would be my guess. x86_64 macos is not long for this world.

    CMake defaults to CMAKE_INTERPROCEDURAL_OPTIMIZATION=FALSE afaik. You have to opt in. Since there is no opt in, it isn't run, and thus no issue in this case

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions