Граф коммитов

147 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 384884f549
[mtouch/mmp] Fix code to report a warning, not only create it. (#13297) 2021-11-08 16:17:00 +01:00
Rolf Bjarne Kvinge 10f833b032
[dotnet] Implement support for the MtouchFloat32 MSBuild property. Fixes #12524. (#12882)
Implement support for the MtouchFloat32 MSBuild property, and do so in a way
that allows us to change the default in the future, if we so wish.

Fixes https://github.com/xamarin/xamarin-macios/issues/12524.
2021-10-01 08:31:11 +02:00
Rolf Bjarne Kvinge 4dad2ca2d7
[tools] Keep passing 'direct-icalls' to the AOT compiler for legacy Xamarin. Fixes #12810. (#12812)
Fixes https://github.com/xamarin/xamarin-macios/issues/12810.
Fixes https://github.com/mono/mono/issues/21210.
2021-09-23 15:31:29 +02:00
Rolf Bjarne Kvinge c4a67e585c
[msbuild/tools] Add a better error message for when we fail to convert between iOS and macOS versions for Mac Catalyst. (#12767)
New commits in xamarin/Xamarin.MacDev:

* xamarin/Xamarin.MacDev@9e6e29f [Xamarin.MacDev] Return valid iOS/macOS versions when converting betweeen iOS and macOS versions for Mac Catalyst.

Diff: 41d91e0de0..9e6e29f2a4
2021-09-21 16:19:04 +02:00
Rolf Bjarne Kvinge 892f0caac2
[dotnet-linker] Remove workaround for a dotnet/runtime issue wrt the AOT compiler. (#12528)
* [dotnet-linker] Remove workaround for a dotnet/runtime issue wrt the AOT compiler.

The dotnet/runtime issue has been fixed.

Ref: https://github.com/dotnet/runtime/issues/55733

* [tests] Set the _BundlerVerbosity property instead of MtouchExtraArgs/MonoBundlingExtraArgs to increase verbosity.

This fixes a problem where a test project would try to set the
MtouchExtraArgs/MonoBundlingExtraArgs properties, and it would fail because
the MtouchExtraArgs/MonoBundlingExtraArgs properties were already set from the
command line (and in MSBuild, properties that are set from command line
arguments can't be changed later).

In particular we have logic to pass --dlsym:+nunit.framework.dll for
monotouch-test, and that would just be ignored.
2021-09-15 18:10:30 +02:00
Rolf Bjarne Kvinge e3cac56a70
[tools] Pass the right arguments to the AOT compiler for Mac Catalyst. Fixes #12484. (#12498)
* [xharness] Add LLVM test case for Mac Catalyst.

* [tests] Add make target to build monotouch-test using LLVM on Mac Catalyst.

* [tools] Pass the right arguments to the AOT compiler for Mac Catalyst. Fixes #12484.

Mac Catalyst is just special.

Fixes https://github.com/xamarin/xamarin-macios/issues/12484.
2021-08-23 09:47:27 +02:00
Filip Navara c00e3a9878
Remove obsolete code (#12478) 2021-08-19 15:00:51 -04:00
Rolf Bjarne Kvinge 104ab12bdd
[dotnet/msbuild] Fix publishing user frameworks and dynamic libraries from binding projects. (#12396)
We extract frameworks from third-party libraries when running the linker, and
we need to store this information on disk and the reload it after the linker
has executed, and add it to the existing MSBuild variables that keep track of
the user frameworks and dynamic libraries that have to be copied to the app
bundle.

Fixes the framework-test tests.
2021-08-11 09:58:00 +02:00
Rolf Bjarne Kvinge 4371133cf7
[dotnet] Remove workaround for private symbols for AOT. (#12334)
* [dotnet] Remove workaround for private symbols for AOT.

* [tools] Make Application.AotArguments a list of string.

This is just a simple refactoring to make Application.AotArguments a list of
strings instead of a comma-separated list of values.

* [tools] Only use direct-icalls when linking mono statically.

Ref: https://github.com/dotnet/runtime/issues/55000

* [mtouch] Fix aot arguments comparison.

* [tests] Adjust mtouch test according to mtouch changes.

* [tests] Add minimum OS version to the Mac Catalyst variation of the MySimpleApp test case.
2021-08-09 09:45:58 +02:00
Rolf Bjarne Kvinge eafe528591
[runtime/tools] Implement finding native support libraries when linking statically. Fixes #10950, #11145 and #12100. (#12323)
* Add support for Mono Components.

* Modify how we look up symbols from native libraries shipped with Mono: we keep
  track of which native libraries we linked with, and depending on how we linked
  to those assemblies, we look the symbols up at runtime in either the current executable
  (if linking statically), or the actual library (where the P/Invoke says they're
  supposed to be).

* This means that we have to propagate how libmono is linked from the MSBuild code
  to the Application class so that our existing logic is able to correctly determine
  which native mono lib to use.

* Modify how we list the P/Invokes we need to preserve by taking into account the
  list of native libraries from Mono we have to link with (for .NET). For legacy
  Xamarin, I've reverted the logic to how it was before we started adding .NET support.

Fixes https://github.com/xamarin/xamarin-macios/issues/10950.
Fixes https://github.com/xamarin/xamarin-macios/issues/11145.
Fixes https://github.com/xamarin/xamarin-macios/issues/12100.
2021-08-03 17:06:58 +02:00
Rolf Bjarne Kvinge 0549af9736
[dotnet] Add support for the interpreter + AOT when needed. Fixes #11421 and #11724. (#12211)
* Add support for the interpreter everywhere.
* Add support for the AOT compiler everywhere we didn't support it before,
  because the interpreter needs it (at least System.Private.CoreLib.dll must
  be AOT-compiled when using the interpreter).
* Do FullAOT compilation on Mac Catalyst/ARM64 if we're not using the
  interpreter, since we can't use the JIT.
* Fix monotouch-test to be green on Mac Catalyst/ARM64.

Fixes https://github.com/xamarin/xamarin-macios/issues/11724.
Fixes https://github.com/xamarin/xamarin-macios/issues/11421.
2021-07-27 07:39:43 +02:00
Rolf Bjarne Kvinge f1d8c760cc [tools] Disable direct-pinvoke for AOT-compiled code on Mac Catalyst.
Using 'direct-pinvoke' will tell the AOT compiler to emit a direct call to the
native function declared in the DllImport, which doesn't work when we want to
redirect to a different native funcion (in our xamarin_pinvoke_override/PINVOKE_OVERRIDE
implementation).

This fixes our exception marshalling tests in monotouch-test.
2021-07-22 10:37:28 +02:00
Rolf Bjarne Kvinge b341fc3551 [tools] Implement interpreter + AOT compilation for simulator + Mac Catalyst.
The interpreter requires running the AOT compiler for System.Private.CoreLib.dll,
so the first step in implementing the interpreter is to implement support for the
AOT compiler as well.

For .NET the logic is now as follows:

* If the interpreter is enabled, AOT compile System.Private.CoreLib.dll.
* If the interpreter is disabled, AOT everything on device + Mac Catalyst on ARM64.
2021-07-22 10:36:21 +02:00
Rolf Bjarne Kvinge 24351db16c [runtime/tools] Implement finding native mono lib for Mac Catalyst.
This also meant propagating how libmono is linked from the MSBuild code to the Application
class so that our existing logic is able to correctly determine which native mono
lib to use.
2021-07-22 10:36:21 +02:00
Rolf Bjarne Kvinge 2116ba59de [tools] Pass the AOTCompiler property to the ComputeAOTArguments linker steps.
So that the ComputeAOTArguments can compute the llvm-path value to pass to the AOT
compiler (the llvm-path value states where the opt and llc command-line tools are,
and they're next to the AOT compiler).
2021-07-16 17:11:14 +02:00
Rolf Bjarne Kvinge f864ff3de7 [tools] Move another IsUptodate overload to the FileCopier file to increase code sharing 2021-06-18 10:24:29 +02:00
Rolf Bjarne Kvinge 427c5447db
[tools] Make exception marshalling the default for CoreCLR (and make it an error to choose otherwise). (#11535)
* Make 'throw Objective-C exception' the default for managed exception marshalling.
* Make 'throw managed exception' the default for Objective-C exception marshalling.
* Disallow the 'unwind through native frames' option: CoreCLR won't do it.
* Disallow the 'unwind through managed frames' option: it's the safeset
  option by far, and also matches the reverse case.
* Disallow the 'disable' option: this is also not safe, let's try to go the
  safe route with CoreCLR.
* Change the default in native code too.

Partial fix for #10940.
2021-05-13 20:59:18 +02:00
Rolf Bjarne Kvinge add11fbe39
[mmp] Use the resolver (and configure it correctly) when using --runregistrar. (#11288)
* Extract the code we use to configure the assembly resolver during a normal
  mmp run to make it usable for --runregistrar.
* Configure the assembly resolver we use for --runregistrar.
* Pass the assembly resolver to the registrar so that it's actually used.
* Adjust the System.Void lookup to look everywhere even if we find a corlib,
  since behavior changes a bit now that we're using an assembly resolver:
	* Previous behavior:
		1. In .NET mode, look for a corlib named System.Private.CoreLib, and fail to find it.
		2. Look in all the loaded assemblies for System.Void (and find it in System.Runtime.dll).
	* Broken behavior as a result of the resolver changes:
		1. Find corlib as System.Private.CoreLib.dll
		2. Fail to find System.Void in System.Private.CoreLib.dll, since we'd only look in corlib.
	* New behavior
		1. Find corlib as System.Private.CoreLib.dll
		2. Fail to find System.Void in System.Private.CoreLib.dll, but find it in System.Runtime.dll,
		   since we're now looking in all the loaded assemblies.

This is required to make VSMac's usage of --runregistrar
2021-04-22 14:47:47 +02:00
Rolf Bjarne Kvinge 405441f544
[mtouch] It seems watchOS simulators can automatically choose the right architecture from fat apps. (#11241)
* [mtouch] It seems watchOS simulators can automatically choose the right architecture from fat apps.

So we can build a fat simulator app, and not depend on mlaunch copying in the
specific architecture at launch time.

A partial fix for https://github.com/xamarin/maccore/issues/2411.

* Bump maccore.

New commits in xamarin/maccore:

* xamarin/maccore@d11721f55e [Xamarin.Hosting] Xcode seems to have changed some logic with regards to getting the primary instruments server. (#2416)
* xamarin/maccore@d27297a098 [Xamarin.Hosting] Don't copy single-arch executable over a fat executable. (#2417)
* xamarin/maccore@6c305d4aa7 [Xamarin.Hosting] Launching may succeed even if the launch request fails. Don't fail in that case. (#2415)
* xamarin/maccore@bccc91d6a0 Support ARM64 and ARM64e simulators (#2418)

Diff: c89fd6a694..d11721f55e
2021-04-21 08:00:02 +02:00
Rolf Bjarne Kvinge 9153edebda
[runtime] Redirect to our objc_msgSend wrapper functions when needed for .NET code. (#10932)
This makes the mono_dllmap_insert function unnecessary for .NET, so remove it.

Ref: https://github.com/dotnet/runtime/issues/48110
Ref: https://github.com/dotnet/runtime/issues/43204
Ref: #10504
2021-03-24 09:17:35 +01:00
mathieubourgeois a921ee2fb1
Xamarin.Mac native Apple Silicon targetting support (#10115)
* Add support for Xamarin.Mac arm64

* Add compile product definition task

Xamarin.Mac can be provided with a ProductDefinition file for the generated pkg. Normally, providing a product definition was optional. However, with Apple Silicon, we have an extra issue : `productbuild` needs to know what architectures your package target. If not provided with them, it will guess to the best of its abilities. However, on Catalina and lower, the guess is x86_64, even if you have an arm64 slice. To fix this, we add a new task to compile the product definition and use this file to create the pkg. If you provide your own Product Definition, we can check and warn if the architectures don't match what we expect. If the file doesn't exist or there is no architecture, we set it ourselves based on our target architectures.

* Don't reference dynamic objC_send on arm64

When building in debug, we currently try to link dynamic objC_send symbols when targeting a 64-bit architecture. However, this is actually only defined on Intel architectures, not on arm64, so we end up failing because we're referring symbols that don't exist. Rework the `GetRequiredSymbols` to take an abi, and tag those symbols to only be valid on i386/x86_64, so they don't get referred at all when building on arm64, but still get referred in x86_64.

* Fix improper delete/move with already existing directories

* Fix stret requirement for Xamarin.Mac in arm64.

The generator supposes that we're running in x64 mode, refactor to take into account the possibility of running in arm64.

* Implement OS version generation in Product.plist, based on MinimumSystemVersion of the app

* Re-generalize some mmp registrar rules

`Microsoft.macOS.registrar` was missed by the current rule set

* Fix mmp tests

* Set E7072 as not translated

Tests were failing otherwise

* Rename Xamarin.Mac lib/x86_64 folder to 64bits (currently all targeted archs are the same)

* Fix style issues

* Fix `ToLower` usage for invariant usage

* Fix xtro-sharpie test
2021-03-17 21:48:02 -04:00
Rolf Bjarne Kvinge 32e4d05195
[dotnet] Add support for specifying the VM with the _XamarinRuntime property. (#10881)
Use a private property (prefixed with underscore) for now, until we can decide
on a better/general name.

Also add a variation to xharness to build monotouch-test with CoreCLR
(building works fine, but it crashes at startup, which is expected at this
point).
2021-03-16 18:32:04 +01:00
Rolf Bjarne Kvinge 883bfdff2f
[dotnet-linker] Disable Objective-C exception marshalling by default for macOS and Mac Catalyst. (#10725)
* [dotnet-linker] Disable Objective-C exception marshalling by default for macOS and Mac Catalyst.

* Apply suggestions from code review

Co-authored-by: Filip Navara <filip.navara@gmail.com>
2021-02-26 07:39:55 +01:00
Rolf Bjarne Kvinge cf2b3c4ec3
[dotnet-linker] Use dlsym for System.Net.Security and System.Net.Quic. (#10660) 2021-02-18 20:30:45 +01:00
Rolf Bjarne Kvinge 1e14e07e25
[tools] Sprinkle more Mac Catalyst decisions/support (#10663) 2021-02-18 17:25:45 +01:00
Rolf Bjarne Kvinge 7c6c8e02e3
[msbuild] Use the macOS SDK to build Mac Catalyst apps instead of the iOS SDK (#10644)
* Bump Xamarin.MacDev.

New commits in xamarin/Xamarin.MacDev:

* xamarin/Xamarin.MacDev@1e738e9 [Xamarin.MacDev] Extract the code to convert between Mac Catalyst versions to a separate file. (#89)
* xamarin/Xamarin.MacDev@a3bb12c [Xamarin.MacDev] Add methods to map between iOS and macOS versions for Mac Catalyst. (#88)

Diff: 02d6d05be3..1e738e9f7f

* [msbuild] Use the macOS SDK to build Mac Catalyst apps instead of the iOS SDK

From a native compilation perspective, compilating a Mac Catalyst is the macOS SDK
+ a dash of iOS, so use the native macOS SDK to compile, and then do the corresponding
adjustments elsewhere.

At the same time document which version we want for the sdk version and the deployment
target in mtouch, and adjust the code accordingly (sdk version: macOS version; deployment
target: iOS version).

* Update resource files

* Add new entry to canary test for string localization.
2021-02-17 17:25:36 +01:00
Rolf Bjarne Kvinge 73d3f9894e
[tools] Move logic to validate/initialize DeploymentTarget to shared code. (#10616)
So that it's executed for .NET as well.
2021-02-12 21:46:13 +01:00
Rolf Bjarne Kvinge 9f710fc9e5
[tools] Stop hardcoding the product name for error messages. (#10615) 2021-02-11 20:17:44 +01:00
Rolf Bjarne Kvinge bce08d0773
[tools] There's no AOT implemented for Mac Catalyst yet. (#10619) 2021-02-11 20:16:50 +01:00
Rolf Bjarne Kvinge 97225eff9f Change parsing of interpreter value to previous interpretation. 2021-02-03 12:51:59 +01:00
Rolf Bjarne Kvinge 2e0225fd87 [dotnet-linker] Implement Application.IsAOTCompiled for macOS on .NET. 2021-02-03 08:03:31 +01:00
Rolf Bjarne Kvinge fcd042a78a [tools] Make corlib check platform neutral 2021-01-28 08:09:59 +01:00
Rolf Bjarne Kvinge 17f3cedc75 [tools] Rework GetAotArguments so we get the output in different variables, like the .NET AOT task requires it 2021-01-28 08:09:59 +01:00
Rolf Bjarne Kvinge 8f36d37659 [tools] Move Driver.GetAotArguments to shared code. 2021-01-28 08:09:59 +01:00
Rolf Bjarne Kvinge 96a2d84403 [tools] Move Application.EnableMSym from mtouch to shared code. 2021-01-28 08:09:59 +01:00
Rolf Bjarne Kvinge abffb528d1 [tools] Move the various Dlsym options/logic from mtouch to shared code 2021-01-28 08:09:59 +01:00
Rolf Bjarne Kvinge c80eed5d62 [tools] Pass and parse the MtouchInterpreter value. 2021-01-28 08:09:59 +01:00
Sebastien Pouliot 77c154df35
[mtouch][mmp] Exclude extraneous framework files from being copied into apps (#10441)
Today both `mtouch` and `mmp` are copying the entire `.framework`
directories inside the `.app\[Contents\]Frameworks\` directory.

However not everything in a framework is required at runtime. The most
common unrequired files would be headers (`Headers/*.h`) and modules
(`Modules/*`).

Looking at Xcode build output we can see something like:

```
builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -exclude Headers -exclude PrivateHeaders -exclude Modules -exclude \*.tbd -bitcode-strip replace-with-marker -bitcode-strip-tool
```

which excludes a few more, less common, files.

This _builtin_ command is not available externally (for us to re-use)
but it hints that Xcode is likely using `rsync` to avoid copying part of
the files.

Note: the builtin command also _likely_ calls `bitcode_strip` too (or has
similar code embedded) and `mtouch` already does so too

There's a cost to spawning an external process, like `rsync`, which we
avoid by having our own file copier, which clones files (almost zero
cost). That does not support excluding files, but deleting files is also
very cheap. Testing shows copying a framework to be less than 1 ms, even
with with extra deletion step.

* Tweak `GetRealPath` to optionally not to warn if the path does not exists

since, in this case, it's a check we want to do after resolving the path

This fixes several (5) MTouch tests looking for specific (and no extra)
warnings

```
Unable to canonicalize the path '/Users/builder/azdo/_work/2/s/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory195/testApp.app/Frameworks/Mono.framework/CVS': No such file or directory (2).
```
2021-01-19 08:48:10 -05:00
Sebastien Pouliot 56d073317a
[tools] Do not check the existing of a file before deleting it (#10443)
because:

> If the file to be deleted does not exist, no exception is thrown.

https://docs.microsoft.com/en-us/dotnet/api/system.io.file.delete?view=net-5.0

and yes this is different from `Directory.Delete` and PR https://github.com/xamarin/xamarin-macios/pull/10441

* Fix MT0015 test failure

The MT0015 test creates a directory where a file is expected.

That's fine except the code for handling this was a bit weird. It
worked because of a `TryDelete` on the path, which avoided the
`UnauthorizedAccessException` when `File.Delete` is used on a path.
Then later there's a `Directory.Exists` check that would throw...

The code now does the `Directory.Exists` first and only call
`File.Delete` if it returns false. The throwing of the exception
is kept since the code (and test) are already present (and this
minimize changes and chance of other surprises)
2021-01-19 08:29:11 -05:00
Rolf Bjarne Kvinge 1582bf47cc
Add support for binding projects in Mac Catalyst. Fixes #10286. (#10295)
* [tests] Build test-libraries for Mac Catalyst.

* [msbuild] Add support for Mac Catalyst binding projects.

* [mtouch] Allow frameworks for Mac Catalyst apps.

* [mtouch] Put frameworks in the expected location for Mac Catalyst apps.

* [msbuild] Create the Resources directory before trying to put files in it.
2020-12-17 18:53:16 +01:00
Rolf Bjarne Kvinge ee735ea034 [mtouch] Mac Catalyst apps do not require PInvoke wrappers.
Just like simulator builds.
2020-12-03 10:43:19 +01:00
Rolf Bjarne Kvinge 42687be5d5 [tools] OS Versions are messy in Mac Catalyst 😡
In some places we have to provide the macOS version, and in other places the
iOS version. Add a map and the corresponding code to convert between the two,
and use them when needed.
2020-12-03 10:43:19 +01:00
Rolf Bjarne Kvinge cdf97ba554 [tools] Put assemblies and other app bundle content in the correct app bundle location depending on the platform we're targetting.
This makes it so that assemblies end up in the Contents/MonoBundle/ subdirectory
as opposed to in the root app directory for catalyst.
2020-12-03 10:42:27 +01:00
Rolf Bjarne Kvinge 183f40c407 [tools] Use the same constants for catalyst as for iOS for now 2020-12-03 10:42:27 +01:00
Rolf Bjarne Kvinge 75876f24c9 [tools] Select the mono native mode for catalyst. 2020-12-03 10:42:27 +01:00
Rolf Bjarne Kvinge 0d5f4a31a8 [msbuild/tools] The (Sdk)Platform for Catalyst is 'MacCatalyst'. 2020-12-03 10:42:26 +01:00
Rolf Bjarne Kvinge 6e906ec7e6 [tools] Catalyst apps are not simulator apps. 2020-12-03 10:42:26 +01:00
Rolf Bjarne Kvinge 5f25d80c16 [tools] Use the same defaults for exception marshalling for catalyst as we use for Xamarin.Mac. 2020-12-03 10:42:26 +01:00
Rolf Bjarne Kvinge 4e69f99ce9 [tools] Use the same GC configuration for catalyst as we use for Xamarin.Mac
Since that's the closest runtime environment.
2020-12-03 10:42:26 +01:00
Rolf Bjarne Kvinge d394761aea [tools] x86_64 is a valid ABI for catalyst! 2020-12-03 10:42:26 +01:00