CMO is enabled by default in the new driver, add
`-enable-default-cmo` in a couple of places to make
the behavior consistent across both the old and
new driver.
* Add a new flag -experimental-package-cmo that requires -experimental-allow-non-resilient-access.
* Support serializing package decls for CMO in package if enabled.
* Only applies to default mode CMO.
* Unlike the existing CMO, package CMO can be built with -enable-library-evolution as package
modules are required to be built together in the same project.
* Create hasPublicOrPackageVisibility to opt in for package decls; needed for CMO, SILVerifier,
and other call sites that verify or determine codegen.
Resolves rdar://121976014
In case of `var` initializations, SILGen creates a dynamic begin/end_access pair around the initialization store.
If it's an initialization (and not a re-assign) it's guanranteed that it's an exlusive access and we can convert the access to an `[init] [static]` access.
https://github.com/apple/swift/issues/66496
For example:
```
public static var privateFunctionPointer: (Int) -> (Int) = { $0 }
```
Fixes a verifier crash and/or undefined symbol error
rdar://99493254
This is a follow-up of 1dfb3b1a2a.
We need to be more conservative about types as for functions, because types can also "produce" symbols, like direct field offsets, etc.
rdar://96953318
So far, the swift-frontend decided by itself if CMO can be enabled. This caused problems when used with an old driver, which doesn't consider CMO.
Now, the driver decides when to use default CMO by passing this flag to swift-frontend.
If we are emitting a TBD file, the TBD file only contains public symbols of this module.
But not public symbols of imported modules which are statically linked to the current binary.
This prevents referencing public symbols from other modules which could (potentially) linked statically.
Unfortunately there is no way to find out if another module is linked statically or dynamically, so we have to be conservative.
Fixes an unresolved-symbol linker error.
rdar://89364148