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

89 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 015e6407e2 Document and verify bit. 2020-10-26 11:57:44 +01:00
Rolf Bjarne Kvinge 6240e848f3 [mtouch] Move mtouch's GenerateMain to shared Target code.
This means moving a lot of supporting code to shared code as well.
2020-10-23 11:46:09 +02:00
Rolf Bjarne Kvinge f513501443 [mmp] Move mmp's GenerateMain to shared Target code.
This means moving some supporting code to shared code as well.
2020-10-23 11:46:09 +02:00
Rolf Bjarne Kvinge 58d546f2eb
[tools] Remove unnecessary conditional code (#9705)
The conditional code was only there to make the code compile; now it compiles so
no need for the condition anymore.
2020-09-28 08:36:47 +02:00
Rolf Bjarne Kvinge 8cc314654f
[dotnet] Add support for the static registrar. (#9615) 2020-09-11 14:08:48 +02:00
Rolf Bjarne Kvinge 37a6569aee
[registrar] Make the registrar code non-conditional. (#9609)
Some appextension mtouch code had to be moved to shared code. This code is currently
only used for iOS/tvOS/watchOS, but it will eventually be applicable to macOS as
well.

This makes it possible to re-use the registrar code in dotnet-linker.
2020-09-10 08:31:12 +02:00
Rolf Bjarne Kvinge eb5206f082
[dotnet-linker] Add OptimizeGeneratedCodeSubStep into the pipeline. (#9608)
Fixes these linkall tests:

    Linker.Shared.OptimizeGeneratedCodeTest
        [FAIL] IsARM64CallingConvention :   optimized: no ldsfld instruction
        Expected: 0
        But was:  1
            at Linker.Shared.BaseOptimizeGeneratedCodeTest.IsARM64CallingConvention() in /Users/rolf/work/maccore/main/xamarin-macios/tests/linker/BaseOptimizeGeneratedCodeTest.cs:line 527
    
    [FAIL] SetupBlockPerfTest :   At least 6x speedup
        Expected: greater than 6
        But was:  1.0876440665344851d
            at Linker.Shared.BaseOptimizeGeneratedCodeTest.SetupBlockPerfTest() in /Users/rolf/work/maccore/main/xamarin-macios/tests/linker/BaseOptimizeGeneratedCodeTest.cs:line 120

And linkall is now green for .NET/Debug.
2020-09-10 08:30:45 +02:00
Rolf Bjarne Kvinge f1e22e369d
[tools] Refactor the Optimizations class to have no conditionally compiled code. (#9596)
Refactor the Optimizations class to have no conditionally compiled code, which makes
it re-usable from our dotnet-linker code.

Also return any errors or warnings instead of showing/throwing them, which makes
the caller able to show them using whatever means is easiest for the caller.

One test needed an update to the list of valid optimizations, because we now have
a per-platform map of valid optimizations, instead of just a iOS/tvOS/watchOS vs
macOS split ('remove-unsupported-il-for-bitcode' is only valid for watchOS, and now
we say so, while we previously said it was a valid optimization for iOS and tvOS
as well, even though we'd warn about it and do nothing if you tried to set it).
2020-09-08 20:26:28 +02:00
Rolf Bjarne Kvinge 827591eccc
[tools] Extract the code to parse, validate and process exception marshalling arguments into the Application class. (#9492)
So that it's easier to re-use it from our .NET linker code.
2020-08-25 19:55:50 +02:00
Rolf Bjarne Kvinge b4da54ea6d Merge remote-tracking branch 'origin/main' into dotnet-partial-static-registrar 2020-08-24 17:56:42 +02:00
Rolf Bjarne Kvinge d7ab847697
[dotnet] Implement support for our different link modes. (#9460)
* [mmp] Rename LinkMode.All to LinkMode.Full.

So that we can continue to use Enum.Parse<LinkMode> to parse 'Full' as the link mode.

* [dotnet] Implement support for our different link modes.

Tell the managed linker what to do with each input assembly depending the selected
link mode (link all, link sdk, don't link).
2020-08-24 17:50:42 +02:00
Rolf Bjarne Kvinge 1f326e82bb [dotnet-linker] Rework Application creation to happen earlier.
Refactor Application creation to happen earlier, and to split out the cache
creation. This way we can create the Application instance before processing
the configuration, and as we process any configuration we can set properties
on the Application instance.
2020-08-21 10:32:56 +02:00
Rolf Bjarne Kvinge f43316114e [mmp] Add a few guards for code that shouldn't be executed under .NET. 2020-08-21 10:32:55 +02:00
Rolf Bjarne Kvinge 43fecd6f54 [mtouch/mmp] Improve lookup of System.Void.
If we can't find the mscorlib assembly in the list of loaded assemblies, try to load
it explicitly. If we still can't find it the mscorlib assembly, look for System.Void
in any assembly. This shouldn't be a performance bottleneck, because we cache the
System.Void type, which means the lookup is only done once.

This makes System.Void lookup work when building with .NET as well, since there's
no mscorlib.dll there.

This is required when running mtouch and mmp to generate the partial static registrar
code for .NET.
2020-08-21 10:32:55 +02:00
Rolf Bjarne Kvinge f6cf39c72b [dotnet-linker] Add a DotNetResolver.
This is just a stub to make code compile, it's not needed at runtime.
2020-08-14 18:33:29 +02:00
Rolf Bjarne Kvinge 33ecd581ac
[mtouch/mmp] Move Application.BuildTarget, Application.IsDeviceBuild and Application.IsSimulatorBuild to shared code. (#9363)
Also add a 'None' build target for the BuildTarget enum for when we're
building for neither simulator nor device (i.e. macOS). This means the default
value will change (since 'Simulator' is no longer the first value), but as far
as I can tell we're always assigning a specific value and not relying on the
default, so this should not make any difference.

This will be needed when the .NET code starts using these classes.
2020-08-13 15:33:13 +02:00
Rolf Bjarne Kvinge 0601d17507
[mtouch] Move Driver.IsFrameworkAvailableInSimulator to shared Application code. (#9365)
This will be needed when the .NET code starts using these classes.
2020-08-13 15:27:57 +02:00
Rolf Bjarne Kvinge b1e5a3faf8
[mtouch/mmp] Move a few Application.Is* properties to shared code. (#9364)
This will be needed when the .NET code starts using these classes.
2020-08-13 15:27:13 +02:00
Rolf Bjarne Kvinge 855c2b09fc
[mtouch] Fix the MT0091 (now called MT0180) after recent code changes. Fixes xamarin/maccore@2280. (#9342)
Also fix a confusion between the M?0179 and M?0180 error message vs error number.

Fixes https://github.com/xamarin/maccore/issues/2280.
2020-08-10 15:49:50 -04:00
Rolf Bjarne Kvinge 2ab8d3f4f8
[mtouch/mmp] Move Application.RequiresXcodeHeaders to shared code. (#9321) 2020-08-10 17:39:33 +02:00
Rolf Bjarne Kvinge 916e79b8d2
[mtouch/mmp] Move Driver's LOCAL_BUILD_DIR and FRAMEWORK_LOCATION_VARIABLE constants to Application instance fields. (#9320) 2020-08-10 10:47:35 +02:00
Rolf Bjarne Kvinge d8665ddd63
[mtouch/mmp] Remove the Error91LinkerSuggestion and implement it using two different error codes. (#9319)
* It makes the error message localizable.
* It makes the implementation shared between mtouch and mmp.
2020-08-10 10:41:25 +02:00
Rolf Bjarne Kvinge 264fa44f6f
[mtouch/mmp] Move the Driver.PRODUCT constant to an Application.ProductName instance field. (#9280)
A few changes are required to have an Application instance at hand when we need to
get the ProductName from it.

This is necessary for .NET, since there will be a single linker library for all platforms,
which means we can't use a constant.
2020-08-06 16:10:06 +02:00
Rolf Bjarne Kvinge 6f0ed03515 [dotnet-linker] Make an Application instance available from the linker configuration, and add more properties to the compat Application type.
This way it's easier to reuse existing mtouch/mmp code that need an Application instance.
2020-06-30 19:01:07 +02:00
Rolf Bjarne Kvinge 392200d930
[mtouch/mmp] Share numerous command-line arguments. (#8599)
* [mtouch/mmp] Share Application.IsDualBuild, Is32Build and Is64Build.

* [mtouch/mmp] Share --tls-provider and --http-message-handler.

* [mtouch/mmp] Share --force.

* [mtouch/mmp] Share --cache.

* [mtouch/mmp] Share --nolink, --linksdkonly, --linkplatform and --linkskip.

* [mtouch/mmp] Share --i18n.

* [mtouch/mmp] Share --xml.

* [mtouch/mmp] Share --registrar and --runregistrar.

* [mtouch/mmp] Share --warn-on-type-ref.

* [mtouch/mmp] Share --sdk.

* [mtouch/mmp] Share --debug.

* [mtouch/mmp] Share --reference, and deprecate -r|--ref and -a|--assembly.

* [mtouch/mmp] Share --targetver, and deprecate mmp's --minos.

* [msbuild] Adjust tests after switching to use --reference instead of -r.

* Update according to review.

* [mmp] Remove --registrar:il.

The IL generator was what MonoMac had before the dynamic/static registrar code
got shared between MonoTouch and MonoMac. The IL registrar been gone for
years, and as far as I know nobody ever used --registrar:il, even though it
was provided as a compatibility option in the beginning (we still had the IL
registrar around for a while after adding the static+dynamic registrars, until
it was completely replaced by the dynamic registrar).

So just remove this option, if anyone ever used it they can replace it with
--registrar:dynamic.

* [mtouch/mmp] Keep bundler-specific code in its corresponding file.
2020-05-19 15:30:38 +02:00
Rolf Bjarne Kvinge 76fc9dc3bf
Improve our error handling code. (#8591)
* Move much of ErrorHandler.cs into a partial class in ErrorHandler.tools.cs,
  which is referenced by mtouch and mmp (but not our runtime).
* Add ErrorHandler.runtime.cs for runtime-specific bits, including a simpler
  version of ErrorHandler.Show. In particular this gets rid of the call to
  Environment.Exit, which should never happen at runtime.
* Rename MonoTouchException and MonoMacException to ProductException, which
  allows us to remove a lot of ifdefs.
* This required moving Application.LoadSymbols and Target.LoadSymbols to
  shared mtouch/mmp code.
2020-05-14 16:45:05 +02:00
Rolf Bjarne Kvinge 3e1862ada9
[mtouch/mmp] Make --setenv available to mmp as well. (#8572)
The actual implementation will be added in a later PR, when the code to
generate main is unified between mtouch and mmp.
2020-05-13 08:50:20 +02:00
Rolf Bjarne Kvinge a4910bb0fa
[mtouch/mmp] Share --package-debug-symbols. (#8574) 2020-05-13 08:40:07 +02:00
Rolf Bjarne Kvinge 3ce9ac43d8
[mtouch/mmp] Share the mono native code. (#8564)
Also move the mono native code to the Application class from the Target
class, since it's per-Application, not per-Target.
2020-05-12 12:10:50 +02:00
Rolf Bjarne Kvinge 5193dfbf9a
[mtouch/mmp] Share --debugtrack code. (#8565) 2020-05-12 09:20:53 +02:00
Rolf Bjarne Kvinge 3d2981c130
[mtouch/mmp] Share Application.MonoGCParams. (#8566) 2020-05-12 09:20:20 +02:00
Rolf Bjarne Kvinge ea25433d75
[mtouch/mmp] Share EnableProfiling. (#8563) 2020-05-11 16:42:21 +02:00
Rolf Bjarne Kvinge b18466f7f2
[mtouch/mmp] Share Abi code. (#8562) 2020-05-11 16:27:19 +02:00
Rolf Bjarne Kvinge 44653d7553
[mtouch/mmp] Share the RegistrarMode enum. (#8553) 2020-05-11 08:57:41 +02:00
Rolf Bjarne Kvinge 48b7ef4696
[mtouch/mmp] Pass the path to mscorlib explicitly to the partial static registrar code instead of relying on resolving it successfully. (#8525)
This makes the code simpler when we have to add support for .NET.

This requires modifying the linker to accept a null FrameworkDirectory.
2020-05-07 08:37:17 +02:00
Rolf Bjarne Kvinge 83e77173dc
[mtouch] Detect the right build target for the partial static registrar. (#8508) 2020-05-05 15:35:35 +02:00
Rolf Bjarne Kvinge acfb101a78
[mtouch/mmp] Share the Application.References field. (#8507) 2020-05-05 15:35:02 +02:00
Rolf Bjarne Kvinge 1de5368593
[mtouch/mmp] Simplify namespace handling now that we don't support Classic anymore. (#8410)
Also consolidate and sort the list of namespaces.
2020-04-17 12:26:38 +02:00
Rolf Bjarne Kvinge 28eddda439
Extract the ApplePlatform and LinkMode enums into their own files. (#8411) 2020-04-17 09:45:18 +02:00
Rolf Bjarne Kvinge 9b82c1c311
[mmp] Only iOS has dual bitness now, no need to check for Xamarin.Mac. (#8076) 2020-03-10 20:23:17 +01:00
Sebastien Pouliot d83e13edf1
[mtouch][mmp] Add a `--warn-on-type-ref=X` option (#7949)
Using this option it's possible to test for the presence of a type
reference in both pre-linked and post-linked assemblies.

This makes it possible to detect if
* a 3rd party assemblies are using some specific type you would like to avoid;
* a type reference has been removed during the build (e.g. linker)

Notes:
* Custom attributes are encoded differently and not included in the assembly type references metadata.
* Assembly that define a type `X` do not have a reference (but the definition) of the type (and won't be reported).

If either the pre or post-linked warnings are not useful then it's possible
 to add `-nowarn:150x` to exclude the results.

E.g.
* `-nowarn:1502` would not report references in pre-linked assemblies;
* `-nowarn:1503` would not report references in post-linked assemblies;

Finally `-warnaserror:150x` can be used to stop a build that would not
satisfy either the pre or post-linked condition.

* `-warnaserror:1502` would not report references in pre-linked assemblies;
* `-warnaserror:1503` would not report references in post-linked assemblies;

_side note_ same as https://github.com/xamarin/xamarin-macios/pull/7925
except that this one uses the localized mtouch/mmp errors only in master (so far)
2020-02-20 22:25:23 -05:00
Waleed Chaudhry f85556c1e5
[mtouch] Fix tests broken by localization (#7798) 2020-02-06 11:14:10 -05:00
Waleed Chaudhry 00985a55e2
[Localization] mtouch/mmp C# (#7710) 2020-01-31 15:02:52 -05:00
Manuel de la Pena 8d83ec2bca
[Mtouch] Make sure that the given SDK version and the iOS version do match. (#7717)
We need to make sure that the iOS SDK and the iOS version do match the
ones present in Xcode.

* Add new variables to track the target version.
* Add method to get the target version.
* Modify mtouch to check agains the target framework rather than the
SDK.

This will allow to keep track of three independent things:

1. The SDK max version.
2. The Simulator max version.
3. The target version of the device.

This had to be added becuase 13.2 has targets to 13.2 but simulators for
13.3

Fixes: https://github.com/xamarin/xamarin-macios/issues/7705
2020-01-22 10:57:27 -05:00
Chris Hamons 7950155faf [mmp] Set ThrowManagedException in debug apps if unset (#7667)
- https://github.com/xamarin/xamarin-macios/issues/5738
- There are a number of managed exceptions Apple can throw at you during
debugging, such as expanding a NSColor in the wrong colorspace
- Throwing a managed exception is a nicer debugging experience, and
during debug we don't care about any performance penality.
2020-01-08 08:00:41 -05:00
Rolf Bjarne Kvinge 6075a9aa5b
[mmp] Remove support for 32-bit apps. Partial fix for #6300. (#6642)
Partial fix for https://github.com/xamarin/xamarin-macios/issues/6300.
2019-07-24 09:01:14 -07:00
monojenkins 2d8396d0a0 [mtouch/mmp] Make the mono native mode a Target-specific variable. (#6037)
The arm64_32 slice for watchOS apps will always use the 'unified' mode, while
the armv7k can be both 'unified' and 'compat' depending on the deployment
target, so we need to keep track of this per Target.

This PR does not change anything related to arm64_32, that will come in a
later PR.
2019-05-10 15:40:17 +02:00
Rolf Bjarne Kvinge aa4eaf7c92
Make a copy of the static registrar and the runtime headers for Xamarin.Mac/Classic. (#5945)
* [registrar] Make a copy of the static registrar for Xamarin.Mac/Classic.

Make a copy of the static registrar for Xamarin.Mac/Classic, one which is
compatible with the binary artifacts we ship for Xamarin.Mac/Classic
(libxammac, XamMac.dll).

This way the static registrar can evolve in the future, without breaking
Xamarin.Mac/Classic.

* [runtime] Make a copy of the runtime headers too.

* Update comment.

* [mmp] Delay creating a Target instance until we know if we're a Classic or Unified app.

Otherwise the wrong static registrar might be created.
2019-04-25 18:08:10 +02:00
Rolf Bjarne Kvinge 5571877312 [mtouch] Use a custom symbol writer to ensure only pdb file names are written to assemblies.
We need our 32-bit and 64-bit assemblies to be identical so that we can avoid
duplicating the .dll in fat apps.

One difference used to be that the .dll contained the full path to the
corresponding .pdb ([1]), but we changed cecil to only write the filename
([2]). Unfortunately this change breaks something else, so it has to be
reverted ([3]).

This implements a different solution: we provide a custom symbol writer to
Cecil, which only writes the filename of the pdb in the .dll, not the full
path.

[1]: https://bugzilla.xamarin.com/show_bug.cgi?id=54578
[2]: https://github.com/jbevain/cecil/issues/372
[3]: https://github.com/jbevain/cecil/pull/554

(cherry picked from commit 53874c863996656eaba43a5582731b93eb6f53b7)

# Conflicts:
#	tools/mtouch/mtouch.csproj
2019-02-13 14:59:34 +01:00
Rolf Bjarne Kvinge 019fcb6a83 [mmp/mtouch] Share some code. 2019-02-11 13:49:38 +01:00