Skip to content
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

Build without swift host tools #77815

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_SYSTEM_PROCESSOR MATCHES "ARM6
set(BOOTSTRAPPING_MODE "OFF")
endif()

# Disable bootstrapping when we aren't building SwiftSyntax
if(NOT SWIFT_BUILD_SWIFT_SYNTAX)
set(BOOTSTRAPPING_MODE "OFF")
endif()

set(SWIFT_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin")
set(SWIFT_LIBRARY_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib")
if("${SWIFT_NATIVE_SWIFT_TOOLS_PATH}" STREQUAL "")
Expand Down
14 changes: 14 additions & 0 deletions lib/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3454,6 +3454,20 @@ ParserResult<Expr> Parser::parseExprMacroExpansion(bool isExprBasic) {
if (!macroNameRef)
return status;

#if !SWIFT_BUILD_SWIFT_SYNTAX
// If we don't have swift-syntax and therefore have no support for macros,
// recognize #isolation as special and route it through
// CurrentContextIsolationExpr.
if (macroNameRef.getBaseName().userFacingName() == "isolation" &&
genericArgs.empty() &&
(!argList || argList->empty())) {
return makeParserResult(
status,
new (Context) CurrentContextIsolationExpr(
macroNameLoc.getStartLoc(), Type()));
}
#endif

return makeParserResult(
status,
MacroExpansionExpr::create(
Expand Down
4 changes: 4 additions & 0 deletions lib/Sema/TypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ std::pair<bool, bool> EvaluateIfConditionRequest::evaluate(
Evaluator &evaluator, SourceFile *sourceFile, SourceRange conditionRange,
bool shouldEvaluate
) const {
#if SWIFT_BUILD_SWIFT_SYNTAX
// FIXME: When we migrate to SwiftParser, use the parsed syntax tree.
ASTContext &ctx = sourceFile->getASTContext();
auto &sourceMgr = ctx.SourceMgr;
Expand All @@ -775,4 +776,7 @@ std::pair<bool, bool> EvaluateIfConditionRequest::evaluate(
bool isActive = (evalResult & 0x01) != 0;
bool allowSyntaxErrors = (evalResult & 0x02) != 0;
return std::pair(isActive, allowSyntaxErrors);
#else
llvm_unreachable("Must not be used in C++-only build");
#endif
}
7 changes: 5 additions & 2 deletions stdlib/cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -890,8 +890,11 @@ function(_compile_swift_files
# cross-compiling the compiler.
list(APPEND swift_compiler_tool_dep "swift-frontend${target_suffix}")

# If we aren't cross compiling, also depend on SwiftMacros.
list(APPEND swift_compiler_tool_dep SwiftMacros)
# If we aren't cross compiling and have swift-syntax, also depend on
# SwiftMacros.
if(SWIFT_BUILD_SWIFT_SYNTAX)
list(APPEND swift_compiler_tool_dep SwiftMacros)
endif()
endif()

# If there are more than one output files, we assume that they are specified
Expand Down
8 changes: 8 additions & 0 deletions stdlib/public/core/Availability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public func _stdlib_isOSVersionAtLeast(
@_semantics("availability.osversion")
@_effects(readnone)
@_unavailableInEmbedded
#if hasFeature(Macros)
@_noLocks
#endif
public func _stdlib_isOSVersionAtLeast(
_ major: Builtin.Word,
_ minor: Builtin.Word,
Expand All @@ -65,7 +67,9 @@ public func _stdlib_isOSVersionAtLeast(
@_semantics("availability.osversion")
@_effects(readnone)
@_alwaysEmitIntoClient
#if hasFeature(Macros)
@_noLocks
#endif
public func _stdlib_isOSVersionAtLeast_AEIC(
_ major: Builtin.Word,
_ minor: Builtin.Word,
Expand Down Expand Up @@ -110,7 +114,9 @@ public func _stdlib_isOSVersionAtLeast_AEIC(
@_semantics("availability.osversion")
@_effects(readnone)
@available(macOS 10.15, iOS 13.0, *)
#if hasFeature(Macros)
@_noLocks
#endif
public func _stdlib_isVariantOSVersionAtLeast(
_ major: Builtin.Word,
_ minor: Builtin.Word,
Expand Down Expand Up @@ -153,7 +159,9 @@ public func _stdlib_isVariantOSVersionAtLeast(
@_semantics("availability.osversion")
@_effects(readnone)
@_unavailableInEmbedded
#if hasFeature(Macros)
@_noLocks
#endif
public func _stdlib_isOSVersionAtLeastOrVariantVersionAtLeast(
_ major: Builtin.Word,
_ minor: Builtin.Word,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

#if !$Embedded
#if !$Embedded && hasFeature(Macros)
@DebugDescription
extension ObjectIdentifier {
var lldbDescription: String {
Expand Down
2 changes: 2 additions & 0 deletions stdlib/public/core/StringBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ extension StringProtocol {

public // SPI(Foundation)
func _toUTF16Indices(_ range: Range<Int>) -> Range<Index> {
#if hasFeature(Macros)
if Self.self == String.self {
let s = unsafeBitCast(self, to: String.self)
return s.utf16._indexRange(for: range, from: s.startIndex)
Expand All @@ -746,6 +747,7 @@ extension StringProtocol {
let s = unsafeBitCast(self, to: Substring.self)
return s._slice._base.utf16._indexRange(for: range, from: s.startIndex)
}
#endif
let lowerbound = _toUTF16Index(range.lowerBound)
let upperbound = _toUTF16Index(range.upperBound)
return Range(uncheckedBounds: (lower: lowerbound, upper: upperbound))
Expand Down
7 changes: 7 additions & 0 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,13 @@ mixin-preset=

skip-test-swiftdocc

[preset: buildbot_linux,without_host_swift]
mixin-preset=
buildbot_linux

skip-early-swiftsyntax
skip-early-swift-driver

[preset: buildbot_linux_crosscompile_wasm]
mixin-preset=buildbot_linux

Expand Down