Skip to content

Revert "build: bootstrap SwiftPM with forked and not host clang" #67339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2023

Conversation

al45tair
Copy link
Contributor

Reverts #64629

@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

@al45tair al45tair requested a review from atrick July 17, 2023 19:49
@finagolfin
Copy link
Member

What did this pull break? It appears to work fine on the SPM CI.

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Thanks

@atrick
Copy link
Contributor

atrick commented Jul 18, 2023

What did this pull break? It appears to work fine on the SPM CI.

Hopefully @al45tair can shed a little light. Our build jobs have ben failing with missing yams symbols. I don't know why the public SPM job passed while other build bots and our local builds are failing:

ld: warning: ignoring file lib/libCYaml.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture arm64:
  "_yaml_document_end_event_initialize", referenced from:
      _$s4Yams7EmitterC9serialize4nodeyAA4NodeO_tKF in Emitter.swift.o
...

@finagolfin
Copy link
Member

The error given appears to be related to linking and makes no sense, as both say arm64:
ld: warning: ignoring file lib/libCYaml.a, building for macOS-arm64 but attempting to link with file built for macOS-arm64. My guess is that this pull is not the reason, since other builds work, but that some related linking issue is being triggered somehow.

I think this is the wrong way to fix it, in any case, as this Swift-forked clang is what should be used, and was for years.

@al45tair
Copy link
Contributor Author

My guess is that there’s some issue with the forked clang that makes the SwiftPM build fail when run from the build script. That needs to be addressed before we can switch over, because breaking it blocks other people.

I realise it’s annoying having things reverted, and I appreciate what you’re trying to do here, but I think in this case reverting until the build issue has been resolved is absolutely the right way forward. Sorry.

@al45tair al45tair merged commit 73a3d66 into main Jul 18, 2023
@al45tair al45tair deleted the revert-64629-spm-cc branch July 18, 2023 06:10
@finagolfin
Copy link
Member

I realise it’s annoying having things reverted, and I appreciate what you’re trying to do here, but I think in this case reverting until the build issue has been resolved is absolutely the right way forward. Sorry.

Sure, I was just skeptical this was the cause of the build issue, as using this clang worked for years. If reverting this has fixed your SPM build, I have no problem with this revert.

Now the question is, where is the failing build log, so we can figure out the problem? Because I don't see any CI failures with this issue.

@al45tair
Copy link
Contributor Author

I'm looking into this at the moment to try to figure out why it's happening (I can reproduce it locally). I'll let you know when I have a fix and we can try the original change again.

@al45tair
Copy link
Contributor Author

OK, since we're discussing it in the revert already I'll keep the discussion here. The issue is that CMake is entirely too clever for its own good.

When it's trying to locate the ranlib tool to use, it looks to see what compiler you're using, and if that compiler happens to be Clang, it will try to use llvm-ranlib instead of whatever else it might have found. Now, CMake also knows that if it sees Apple Clang, it mustn't use llvm-ranlib but should use the one from the toolchain instead. However the Clang we've just built in the Swift build doesn't announce itself as Apple Clang; it announces itself as just ordinary Clang. So CMake tries to use llvm-ranlib, which then causes the linker to fail with a weird error message.

@al45tair
Copy link
Contributor Author

Hence, when you changed things to use the just-built compiler, we ended up trying to use the wrong ranlib tool, resulting in a static archive that wouldn't link.

@finagolfin
Copy link
Member

OK, makes sense, was the macOS CMake also recently updated, like on linux with #67018, so that's why it's only failing now? Let me know how you think this should be fixed on macOS, as this pull works everywhere else.

@al45tair
Copy link
Contributor Author

I'm talking to @etcwilde about it at the moment. In an ideal world we'd be using libtool anyway on Darwin, so this might be a reason to fix that at the same time in CMake upstream. We'll keep you informed and circle back round to this changeset once we have things sorted out.

@al45tair
Copy link
Contributor Author

OK. I think that once swiftlang/swift-package-manager#6721 has landed, we will probably be good to have another go at your change.

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.

3 participants