Skip to content

[SR-15043] Prune needless dependencies on the real Foundation #57370

@typesanitizer

Description

@typesanitizer
Previous ID SR-15043
Radar rdar://problem/81670768
Original Reporter @typesanitizer
Type Task
Status Reopened
Resolution
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Task
Assignee None
Priority Medium

md5: d7890ff7301447fd8c98ca64587c8761

relates to:

  • SR-15044 Module caching is not working with SDK frameworks in the test suite

Issue Description:

There are a bunch of files in the test suite which import Foundation but do not use the mock-sdk argument to use our fake SDK for testing.

For example, if I add the mock-sdk argument as %clang-importer-sdk to test/IRGen/actor_class_objc.swift, the test still passes, but the time to run goes from 15.39s to 0.22s (for a single test) with a release assert compiler. I don't know what those 15 seconds are being spent doing, but it doesn't seem like a good use of time.

A quick script to figure out what places are not using mock-sdk.

cd test
rg --glob '*.swift' --count 'import Foundation' | rg -v 'Inputs' | awk -F ':' '{print $1}' | uniq | sort > Foundation-importers.txt
cat Foundation-importers.txt | xargs rg --count '(mock-sdk|clang-importer-sdk)' | awk -F ':' '{print $1}' | uniq | sort > Foundation-importers-using-mock-sdk.txt
diff Foundation-importers.txt  Foundation-importers-using-mock-sdk.txt | rg '< ' | sed 's/< //'

Here is the output

APIJSON/apigen.swift
APIJSON/non-objc-class.swift
APIJSON/spi.swift
ClangImporter/SceneKit_test.swift
ClangImporter/enum-error.swift
ClangImporter/pch-bridging-header.swift
ClangImporter/sdk-bridging-header.swift
ClangImporter/sdk.swift
Concurrency/actor_isolation_objc.swift
Concurrency/async_conformance.swift
Concurrency/async_initializer_objc.swift
Concurrency/concurrent_value_checking_objc.swift
Constraints/bridging.swift
Constraints/dynamic_lookup.swift
Constraints/invalid_decl_ref.swift
Constraints/trailing_closures_objc.swift
DebugInfo/cleanupskip.swift
DebugInfo/implicitdecl.swift
DebugInfo/overlay-import.swift
DebugInfo/returnlocation.swift
DebugInfo/test-foundation.swift
DebugInfo/thunks.swift
Driver/loaded_module_trace_foundation.swift
IDE/annotation_foundation.swift
IDE/complete_from_foundation_overlay.swift
IDE/sdk_sugar.swift
IRGen/UseObjCMethod.swift
IRGen/actor_class_objc.swift
IRGen/availability.swift
IRGen/clang_string_enum.swift
IRGen/extension_type_metadata_linking.swift
IRGen/foreign_type_metadata.swift
IRGen/objc_arc_contract.swift
IRGen/objc_deprecated_objc_thunks.swift
IRGen/objc_object_getClass.swift
IRGen/objc_retainAutoreleasedReturnValue.swift
IRGen/objc_runtime_name_attr.swift
IRGen/outlined_copy_addr_data.swift
IRGen/unmanaged_objc_throw_func.swift
Incremental/Verifier/single-file-private/AnyObject.swift
Index/index_objc_dynamic_refs.swift
Index/kinds_objc.swift
Interpreter/SDK/FoundationDiagnostics.swift
Interpreter/SDK/objc_protocol_lookup.swift
Migrator/override_migration.swift
Misc/misc_diagnostics.swift
ModuleInterface/actor_objc.swift
ModuleInterface/nsmanaged-attr.swift
ModuleInterface/static-initialize-objc-metadata-attr.swift
NameLookup/nio_shadowing.swift
Parse/omit_return_objc.swift
PrintAsObjC/availability-real-sdk.swift
PrintAsObjC/bridged-known-types.swift
PrintAsObjC/dispatch.swift
PrintAsObjC/getter_setter.swift
Profiler/coverage_deinit.swift
RemoteAST/existentials_objc.swift
RemoteAST/foreign_types.swift
RemoteAST/objc_classes.swift
SILGen/NSApplicationMain.swift
SILGen/cf_curried_init.swift
SILGen/collection_downcast.swift
SILGen/collection_upcast.swift
SILGen/duplicate_opened_archetypes.swift
SILGen/extensions_objc.swift
SILGen/function_conversion_objc.swift
SILGen/generic_objc_block_bridge.swift
SILGen/import_as_member.swift
SILGen/let_decls_objc.swift
SILGen/metatype_object_conversion.swift
SILGen/nsmanaged-witness-multi.swift
SILGen/nsmanaged-witness.swift
SILGen/objc_attr_NSManaged.swift
SILGen/objc_attr_NSManaged_multi.swift
SILGen/objc_deprecated_objc_thunks.swift
SILGen/objc_dynamic_replacement.swift
SILGen/objc_dynamic_replacement_ext.swift
SILGen/objc_extensions.swift
SILGen/objc_final.swift
SILGen/objc_imported_init.swift
SILGen/objc_keypath.swift
SILGen/objc_local.swift
SILGen/objc_nonnull_lie_hack.swift
SILGen/objc_properties.swift
SILGen/objc_selector.swift
SILGen/objc_witnesses.swift
SILGen/objc_witnesses_serialized.swift
SILGen/pointer_conversion.swift
SILGen/protocol-extension-default-arg-existential-objc.swift
SILGen/super_objc_class_method.swift
SILOptimizer/OSLogFullOptTest.swift
SILOptimizer/OSLogMandatoryOptTest.swift
SILOptimizer/access_marker_verify_objc.swift
SILOptimizer/anyhashable_to_protocol.swift
SILOptimizer/assemblyvision_remark/cast_remarks_objc.swift
SILOptimizer/bridged_casts_folding.swift
SILOptimizer/cast_folding_objc.swift
SILOptimizer/closure_lifetime_fixup_objc.swift
SILOptimizer/dead_bridging_code.swift
SILOptimizer/dead_func_objc_extension_keypath.swift
SILOptimizer/definite-init-convert-to-escape.swift
SILOptimizer/di-conditional-destroy-scope.swift
SILOptimizer/diagnose_lifetime_issues_objc.swift
SILOptimizer/infinite_recursion_objc.swift
SILOptimizer/keypath_opt_crash.swift
SILOptimizer/mandatory_inlining_dynamic_method.swift
SILOptimizer/objc_protocol_method.swift
SILOptimizer/outliner.swift
SILOptimizer/simplify_switch_enum_objc.swift
SILOptimizer/specialize_self_conforming.swift
Sema/impl_throw_objc.swift
Sema/import_and_define_class.swift
Sema/objc_attr_fixit_nsobject.swift
Sema/object_literals_ios.swift
Sema/object_literals_osx.swift
Serialization/extension_generation_number_1.swift
Serialization/extension_generation_number_2.swift
Serialization/objc_async.swift
SourceKit/Indexing/index_constructors.swift
TBD/implied_objc_symbols.swift
TypeDecoder/foreign_types.swift
TypeDecoder/objc_classes.swift
attr/attr_availability_narrow.swift
attr/attr_borrowed.swift
attr/attr_iboutlet.swift
attr/attr_nonobjc.swift
attr/attr_objc.swift
attr/attr_objcMembers.swift
attr/attr_objc_any.swift
attr/attr_objc_async.swift
attr/attr_objc_swift4.swift
decl/async/objc.swift
decl/enum/objc_enum_Error.swift
decl/ext/extension-generic-objc-protocol.swift
decl/ext/extension-generic-objc.swift
decl/init/failable.swift
expr/cast/literals_downcast_bridge.swift
expr/primary/keypath/keypath-observe-objc.swift
multifile/imported-conformance/option-set/main.swift
multifile/objc-protocol.swift
multifile/protocol-conformance-objc.swift
multifile/require-finalize-witness.swift
multifile/require-member-layout-dynamic.swift
multifile/synthesized-accessors/materialize-for-set-1/main.swift
multifile/synthesized-accessors/materialize-for-set-2/main.swift
stdlib/Foundation_NewGenericAPIs.swift
stdlib/StringDiagnostics.swift
stdlib/URLSession.swift
stmt/errors_nonobjc.swift
swift-indent/main.swift
type/opaque_return_type_obc_protocol.swift

Probably not perfect, but we should start looking at these tests and check if importing Foundation from the SDK is really necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerThe Swift compiler itself

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions