Skip to content

Conversation

dabrahams
Copy link
Contributor

No description provided.

else()
message(FATAL_ERROR "Unrecognized architecture for Windows host")
endif()
else()
Copy link
Contributor

@bnbarham bnbarham Feb 2, 2024

Choose a reason for hiding this comment

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

I wonder if the current if contents is even worth keeping. SWIFT_HOST_MODULE_TRIPLE would be set when this is part of the compiler build. So we'd only be in here if standalone, in which case falling back to the module triple from -print-target-info sounds the most reasonable to me anyway. Thoughts @etcwilde / @compnerd?

(And thanks @dabrahams, this LGTM even if we don't rip out the rest of the if).

Copy link
Member

@etcwilde etcwilde Feb 2, 2024

Choose a reason for hiding this comment

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

Yeah, something like this should work for all cases, I believe.

  set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
  if(CMAKE_Swift_COMPILER_TARGET)
    list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
  endif()
  execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
  string(JSON SWIFT_HOST_MODULE_TRIPLE GET "${target_info_json}" "target" "moduleTriple")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had the same thought but didn't want to presume.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@etcwilde You probably know CMake much better than me but your version seems like a lot of code for what I did in two lines. Is there a reason to make it so elaborate?

Copy link
Member

Choose a reason for hiding this comment

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

The extra bits I added are for cross-compiling. Running -print-target-info alone will only give you the module triple for the triple that the compiler was configured to output to by default. If someone has specified the triple they want to output to, we want to ensure that the module triple reflects that. It's not always set, so we need to ensure that it is before adding it to the command.

Copy link
Member

Choose a reason for hiding this comment

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

I definitely prefer @etcwilde's approach - cross-compilation is going to be most likely the path we take to get the Windows ARM64 toolchain release setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So are y'all suggesting I replace lines 65-80 with @etcwilde's code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ask because @bnbarham approved these changes as-is, but I can't run the CI or merge myself, and I'd like to move the PR forward. If that means making the edit I just described, please LMK.

Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be good to do, I am fine to merge this as is though - it's an improvement regardless. If you'd like to put up another (or you @etcwilde), feel free :). I'll run tests and merge. Thanks @dabrahams!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I for one encourage @etcwilde to submit the improved PR once this lands.

@bnbarham
Copy link
Contributor

@swift-ci please test

@bnbarham
Copy link
Contributor

@swift-ci please test macOS platform

@bnbarham bnbarham merged commit aca425e into swiftlang:main Feb 22, 2024
dabrahams added a commit to hylo-lang/GenerateSwiftXCTestMain that referenced this pull request Mar 19, 2024
dabrahams added a commit to hylo-lang/GenerateSwiftXCTestMain that referenced this pull request Mar 19, 2024
dabrahams added a commit to hylo-lang/GenerateSwiftXCTestMain that referenced this pull request Mar 19, 2024
dabrahams added a commit to hylo-lang/GenerateSwiftXCTestMain that referenced this pull request Mar 20, 2024
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.

4 participants