Carthage icon indicating copy to clipboard operation
Carthage copied to clipboard

Fix 'objdump' call not working with Xcode 13.3 command line tools

Open mikchmie opened this issue 4 years ago • 21 comments

Fixes #3253

mikchmie avatar Feb 01 '22 10:02 mikchmie

@mikchmie thanks! Will this still work with previous versions of Xcode or macOS?

tmspzz avatar Feb 01 '22 10:02 tmspzz

I'm checking it right now. So far I've checked options' syntax in following versions of `objdump:

  • Apple LLVM version 13.1.6 (clang-1316.0.19.2) - Xcode 13.3
  • Apple LLVM version 13.0.0 (clang-1300.0.29.30) - Xcode 13.2.1
  • Apple LLVM version 12.0.5 (clang-1205.0.22.9) - Command_Line_Tools_macOS_10.12_for_Xcode_8.3.2

and it looks the same (with two dashes --).

@tmspzz What is the minimum version of Xcode that Carthage supports?

mikchmie avatar Feb 01 '22 10:02 mikchmie

~~Looks like the syntax was changed in LLVM 10 in 2019.~~

~~Last LLVM 9 docs capture:~~ ~~https://web.archive.org/web/20190616123225/http://www.llvm.org:80/docs/CommandGuide/llvm-objdump.html~~ ~~First LLVM 10 docs capture:~~ ~~https://web.archive.org/web/20190812120449/http://llvm.org:80/docs/CommandGuide/llvm-objdump.html~~

mikchmie avatar Feb 01 '22 10:02 mikchmie

I've also found LLVM's historic documentation and looks like the change actually happened in LLVM 9 (released 19 Sep 2019). I suppose this is a more reliable way to pinpoint the moment of change, than the WaybackMachnie.

LLVM 8.0.1 docs (-macho): https://releases.llvm.org/8.0.1/docs/CommandGuide/llvm-objdump.html

LLVM 9.0.0 docs (--macho): https://releases.llvm.org/9.0.0/docs/CommandGuide/llvm-objdump.html

According to Wikipedia it means that this new syntax would work in Xcode 11.4+.

mikchmie avatar Feb 01 '22 10:02 mikchmie

@tmspzz If that's necessary I can add a fallback to the chain, e.g.:

return task.launch(standardInput: nil)
    .flatMapError { _ -> SignalProducer<TaskEvent<Data>, TaskError> in
        // Fallback for 'objdump' in LLVM <9.0.0 (Xcode <11.4) which uses `-` as option prefix instead of `--`
        Task("/usr/bin/xcrun", arguments: [
            "objdump",
            "-macho",
            "-private-header",
            "-non-verbose",
            url.resolvingSymlinksInPath().path,
            ]
        ).launch(standardInput: nil)
    }

mikchmie avatar Feb 01 '22 12:02 mikchmie

I tried this patch with Xcode 13.2.1 and binary xcframework didn't land in ./Carthage/Build/<Platform>/ as per #3253

krzyzanowskim avatar Feb 02 '22 20:02 krzyzanowskim

@krzyzanowskim As far as I can tell XCFrameworks (*.xcframework) will never land in ./Carthage/Build/<Platform>/ - instead they should be placed in ./Carthage/Build/ - as they usually contain binaries for multiple platforms. Only "basic" frameworks (*.framework) land in ./Carthage/Build/<Platform>/.

mikchmie avatar Feb 02 '22 20:02 mikchmie

@mikchmie you're right. I just noticed I face a different issue, where the Xcode project that supposes to use .xcframework, links to a non-existing framework from ./Carthage/Build/<Platform>/

krzyzanowskim avatar Feb 02 '22 20:02 krzyzanowskim

@tmspzz Are there any plans to fix the issue mentioned in this PR (either by merging my PR or some other way)? Xcode 13.3 Release Candidate has already been released, so it won't be long before it's fully released to the public and will give Carthage users trouble.

mikchmie avatar Mar 09 '22 12:03 mikchmie

@tmspzz since Xcode 13.3 is released, we are having trouble with it. Are you planning to resolve this issue in the nearest future?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 27 '22 21:04 stale[bot]

Is the project itself "stale"? Are there any active maintainers who could make Carthage compatible with latest Xcode versions?

mikchmie avatar Apr 28 '22 07:04 mikchmie

We're also waiting for this fix.

  • https://github.com/Carthage/Carthage/issues/3269

CraigSiemens avatar Apr 29 '22 00:04 CraigSiemens

Same! Would be happy to help support this.

vilu avatar Apr 29 '22 06:04 vilu

Our current workaround is to copy over the frameworks ourself. We've already got a script running Carthage so we added this at the end.

# carthage build ...

mkdir -p Carthage/Build/iOS
destination=$(mktemp -d)
tar_path=$(find "$HOME/Library/Caches/org.carthage.CarthageKit/binaries/GoogleMaps" -iname "GoogleMaps*.gz")
tar -xf "$tar_path" -C "$destination"
find "$destination" -d -iname "*.framework" -exec cp -R {} Carthage/Build/iOS \;
rm -r "$destination"

CraigSiemens avatar Apr 29 '22 17:04 CraigSiemens

@tmspzz could you please provide feedback here? Is there anything that you would like us to add / change / explain in order to move this forward?

To summarise The earliest LLVM version Carthage relies on for this particular command requires LLVM 3.8.0 which is already supporting the usage of the double-dash prefix.

In more detail

  • objdump is not accepting single-dash prefixed parameters starting with LLVM 13.1.6 which is bundled with the Command Line Tools of Xcode 13.3
  • The new syntax for objdump requires a double-dash prefix for parameters
  • This causes Carthage to fail silently when trying to check out binary dependencies
  • The new syntax is already supported since LLVM 3.8.0 bundled with Xcode 7.2.1
  • LLVM 3.7.0 does not have the -private-header option which is needed here, so LLVM 3.8.0 is the earliest version that this step has to support

Ro-M avatar May 20 '22 07:05 Ro-M

@Ro-M Thanks for the summary 👍 Just 2 tiny corrections:

  • objdump is not accepting single-dash prefixed parameters starting with LLVM 13.1.6 which is bundled with the Command Line Tools of Xcode 13.3

For the sake of clarity let's stick to one versioning system (the one described as LLVM in table on Wikipedia). 13.1.6 comes from the Clang version string which Apple's builds print as their version. The official LLVM version is 13.0.0.

  • The new syntax is already supported since LLVM 3.8.0 bundled with Xcode 7.2.1

Actually it's bundled since Xcode 7.3. Xcode 7.2.1 used LLVM 3.7.0

mikchmie avatar May 20 '22 19:05 mikchmie

This change fixes my issue on Xcode 13.4 as well. Hope it gets merged and released soon.

irmakcan avatar Jun 06 '22 22:06 irmakcan

Hey dudes, did carthage bite the dust? Is somebody planning to merge it? Not usable anymore with Xcode 13.3 - 14. May be also just call otool -h as higher level abstraction?

mneuwert avatar Sep 15 '22 09:09 mneuwert

@mneuwert I'm not sure about the current plans from the maintainers. As for this PR I would like to move this forward but need direction as to what's missing here. We currently are using a fork of carthage that also includes this change. For the future we are looking into carthage alternatives that have a more active support 😞

Ro-M avatar Oct 12 '22 08:10 Ro-M

@giginet Could you review this PR?

mikchmie avatar Jan 04 '23 12:01 mikchmie