Skip to content

build-script: Permit to build compiler-rt with LLVM_ENABLE_RUNTIMES #80174

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
Apr 22, 2025

Conversation

edymtt
Copy link
Contributor

@edymtt edymtt commented Mar 20, 2025

LLVM-21 plans to remove the legacy method for building compiler-rt in the same invocation as LLVM using LLVM_ENABLED_PROJECTS and LLVM_BUILD_EXTERNAL_COMPILER_RT.

Support the new way of building compiler-rt with a new build-script opt-in flag --llvm-build-compiler-rt-with-use-runtimes -- this will allow a staged introduction, and will ensure we can revert back to the old behaviour temporarily in case of unforeseen regression.

Since this flag is meant to be short lived, in an attempt to keep the logic simple we are gating on it only the
CMake cache entries that strictly control the compilation mode, all the other entries used for configuring are added in both modes.

Take this chance to remove some stale code from build-script-impl, and move some code in the generic CMake product to the LLVM one.

Addresses rdar://147505298

@edymtt
Copy link
Contributor Author

edymtt commented Mar 20, 2025

@swift-ci please python lint

@classmethod
def compute_cmake_args_for_runtimes(cls, host_target):
# Swift expects the old layout for the runtime directory
args_for_runtime = '-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR:BOOL=OFF'
Copy link
Member

Choose a reason for hiding this comment

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

Note that Windows has started migrating to the new layout. clang already prefers the new layout. We should file an issue to bring the other hosts in line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created #80180

if self.args.test:
# LLVMTestingSupport is not built at part of `all`
# and is required by some Swift tests
build_targets.append('LLVMTestingSupport')
Copy link
Member

Choose a reason for hiding this comment

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

This seems unrelated to this change?

Copy link
Contributor Author

@edymtt edymtt Mar 20, 2025

Choose a reason for hiding this comment

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

This is needed because with LLVM_ENABLE_RUNTIMES the new runtimes target does not have any dependencies to LLVMTestingSupport -- currently that is scheduled as a result of the compiler-rt configuration

I preferred to apply it to the old way of building compiler-rt as well to limit the number of places where I check for the flags -- it should not cause any additional rebuilds there.

Copy link
Member

Choose a reason for hiding this comment

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

However, if it is required for tests, I think that the tests should add that dependency, not compiler-rt.

Copy link
Contributor Author

@edymtt edymtt Mar 20, 2025

Choose a reason for hiding this comment

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

I would like to do that, but build-script does not schedule Swift as an external project of LLVM (like build.ps1 does) -- so I cannot put LLVMTestingSupport as a dependency of the test targets that need that.

@edymtt
Copy link
Contributor Author

edymtt commented Mar 20, 2025

@swift-ci please test

@edymtt edymtt force-pushed the edymtt/use-runtimes-build-quater branch from 3a7a408 to 442edf4 Compare March 24, 2025 21:06
@edymtt
Copy link
Contributor Author

edymtt commented Mar 24, 2025

@swift-ci please python lint

@edymtt
Copy link
Contributor Author

edymtt commented Mar 24, 2025

@swift-ci please test

@edymtt
Copy link
Contributor Author

edymtt commented Mar 25, 2025

@swift-ci please test Apple Silicon

@edymtt
Copy link
Contributor Author

edymtt commented Mar 25, 2025

@swift-ci please build toolchain

@edymtt
Copy link
Contributor Author

edymtt commented Mar 25, 2025

@swift-ci Please Test Source Compatibility

@edymtt
Copy link
Contributor Author

edymtt commented Mar 25, 2025

preset=stdlib_S_standalone_minimal_macho_x86_64,build,test
@swift-ci please test with toolchain and preset

@edymtt
Copy link
Contributor Author

edymtt commented Mar 31, 2025

@swift-ci please python lint

@edymtt edymtt mentioned this pull request Mar 31, 2025
@edymtt
Copy link
Contributor Author

edymtt commented Mar 31, 2025

@swift-ci please python lint

@@ -1398,6 +1398,11 @@ def create_argument_parser():
'separated options "-DCMAKE_VAR1=YES,-DCMAKE_VAR2=/tmp". Can '
'be called multiple times to add multiple such options.')

option('--llvm-build-compiler-rt-with-use-runtimes', toggle_true,
help='Switch to LLVM_USE_RUNTIMES as the mechanism to build compiler-rt'
Copy link
Member

Choose a reason for hiding this comment

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

s/LLVM_USE_RUNTIMES/LLVM_ENABLE_RUNTIMES.

@@ -23,6 +23,10 @@ class CMakeProduct(product.Product):
def is_verbose(self):
return self.args.verbose_build

@property
def cmake_os_sysroot(self):
Copy link
Member

Choose a reason for hiding this comment

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

Why the property function instead of setting self.cmake_os_sysroot? If we get an error for trying to use cmake_os_sysroot before calling host_cmake_options, this will still result in a failure because self._cmake_os_sysroot is still undefined so it isn't protecting us from anything.

Copy link
Contributor Author

@edymtt edymtt Mar 31, 2025

Choose a reason for hiding this comment

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

I wanted to make it discoverable that this value can now be accessed outside of this class, and I thought that adding a read only property would help convey this (instead of trawling through the code of build_with_cmake host_cmake_options)

Copy link
Contributor Author

@edymtt edymtt Mar 31, 2025

Choose a reason for hiding this comment

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

I reworked my approach to avoid the use of the property, and instead return the value I am interested in as an outcome from host_cmake_options

@edymtt
Copy link
Contributor Author

edymtt commented Mar 31, 2025

@swift-ci please test

@edymtt edymtt force-pushed the edymtt/use-runtimes-build-quater branch from bd12562 to 824fb12 Compare March 31, 2025 17:52
@edymtt
Copy link
Contributor Author

edymtt commented Mar 31, 2025

@swift-ci please python lint

@edymtt
Copy link
Contributor Author

edymtt commented Mar 31, 2025

@swift-ci please test

@edymtt
Copy link
Contributor Author

edymtt commented Mar 31, 2025

@swift-ci please build toolchain

@edymtt
Copy link
Contributor Author

edymtt commented Mar 31, 2025

@swift-ci Please Test Source Compatibility

LLVM-21 plans to remove the legacy method for building compiler-rt
in the same invocation as LLVM using `LLVM_ENABLED_PROJECTS` and
`LLVM_BUILD_EXTERNAL_COMPILER_RT`.

Support the new way of building compiler-rt with a new build-script
opt-in flag `--llvm-build-compiler-rt-with-use-runtimes` --
this will allow a staged introduction, and will ensure we can revert
back to the old behaviour temporarily in case of unforeseen regression.

Since this flag is meant to be short lived, in an attempt to keep the
logic simple we are gating on it only the
CMake cache entries that strictly control the compilation mode, all the
other entries used for configuring are added in both modes.

Take this chance to remove some stale code from `build-script-impl`, and
move some code in the generic CMake product to the LLVM one.

Addresses rdar://147505298
@edymtt edymtt force-pushed the edymtt/use-runtimes-build-quater branch from 824fb12 to 0c8171f Compare March 31, 2025 20:55
@edymtt
Copy link
Contributor Author

edymtt commented Mar 31, 2025

@swift-ci please python lint

1 similar comment
@edymtt
Copy link
Contributor Author

edymtt commented Mar 31, 2025

@swift-ci please python lint

@edymtt
Copy link
Contributor Author

edymtt commented Mar 31, 2025

@swift-ci please test

@edymtt
Copy link
Contributor Author

edymtt commented Mar 31, 2025

@swift-ci please build toolchain

@edymtt
Copy link
Contributor Author

edymtt commented Mar 31, 2025

@swift-ci Please Test Source Compatibility

@edymtt
Copy link
Contributor Author

edymtt commented Apr 1, 2025

@swift-ci please test macOS

@edymtt
Copy link
Contributor Author

edymtt commented Apr 1, 2025

@swift-ci please test Windows

@edymtt
Copy link
Contributor Author

edymtt commented Apr 1, 2025

@swift-ci please build toolchain Windows

@edymtt
Copy link
Contributor Author

edymtt commented Apr 2, 2025

@swift-ci please test macOS

1 similar comment
@edymtt
Copy link
Contributor Author

edymtt commented Apr 3, 2025

@swift-ci please test macOS

@edymtt edymtt merged commit 7b00176 into swiftlang:main Apr 22, 2025
11 checks passed
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