Skip to content

Support bootstrapping with Xcode #40838

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 3 commits into from
Jan 17, 2022

Conversation

cbjeukendrup
Copy link
Contributor

@cbjeukendrup cbjeukendrup commented Jan 13, 2022

A /${CMAKE_CFG_INTDIR} was missing in a path. With Ninja, this does not matter because then it is always "". But with Xcode, it is "Debug", "Release", etc.. This causes SR-15705, which is also the error mentioned in #40833.

Edit: fixed the other problems too (see comments), now it fully works.

@WowbaggersLiquidLunch

This comment has been minimized.

@CodaFi CodaFi requested a review from compnerd January 13, 2022 22:51
@cbjeukendrup cbjeukendrup force-pushed the try_fix_xcode_bootstrapping_build branch from 7b33141 to 115f9c6 Compare January 13, 2022 23:31
@cbjeukendrup
Copy link
Contributor Author

cbjeukendrup commented Jan 13, 2022

I was able to fix the other problem too! So now, bootstrapping also works with Xcode!

Both "bootstrapping" and "bootstrapping-with-hostlibs" are working.

@cbjeukendrup cbjeukendrup changed the title One step towards supporting bootstrapping with Xcode Support bootstrapping with Xcode Jan 13, 2022
A `/${CMAKE_CFG_INTDIR}` was missing in a path. With Ninja, this does not matter because then it is always "". But with Xcode, it is "Debug", "Release", etc..
@cbjeukendrup cbjeukendrup force-pushed the try_fix_xcode_bootstrapping_build branch from 115f9c6 to e77d731 Compare January 14, 2022 00:38
Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

This seems fine to me from the CMake perspective, no idea about the Xcode builds.

# Therefore, it fails to create the static library. As a workaround,
# we create just a dummy source file.
if (XCODE)
set(dummy_source_file "${build_dir}/dummy.cpp")
Copy link
Member

Choose a reason for hiding this comment

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

I think I would be happier with a random SHA sum as the filename rather than something which could collide. What happens with only objects in the archive?

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 found a more elegant solution, that works too: creating an empty script phase. That is probably nicer than creating a dummy file. (And if we generated a random SHA sum for the dummy file name every time that CMake runs, wouldn't that cause dummy files to pile up in the build dir?)

Without a dummy file or script phase, Xcode would completely ignore the library target, not even mentioning it in the logs. (It does appear in the Xcode GUI, but is never built.)

Copy link
Member

@compnerd compnerd Jan 17, 2022

Choose a reason for hiding this comment

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

I wasn't suggesting a random SHA sum :) You could generate a SHA sum of the target name. The empty files in the build tree don't really matter - they would get cleaned up when you clean up the build tree (and only impact the Xcode builds).

Xcode does not compile libraries that contain only object files; it just skips them completely, not even mentioning them in the logs. Therefore, it fails to create the static library that would contain all SwiftCompilerSources object files. As a workaround, we add a dummy script phase to the target, to force that it gets compiled.
@cbjeukendrup cbjeukendrup force-pushed the try_fix_xcode_bootstrapping_build branch from e77d731 to 5ad98aa Compare January 14, 2022 01:57
@WowbaggersLiquidLunch
Copy link
Contributor

@swift-ci please smoke test

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

thanks!

@CodaFi
Copy link
Contributor

CodaFi commented Jan 16, 2022

@swift-ci test macOS platform

@CodaFi CodaFi merged commit 18407d8 into swiftlang:main Jan 17, 2022
@cbjeukendrup cbjeukendrup deleted the try_fix_xcode_bootstrapping_build branch January 17, 2022 16:53
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.

5 participants