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

578 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge e61e5cce98 [mtouch] Make code sharing work on watchOS. (#1988)
* [mtouch] Only iOS has version 8 (and earlier OS versions that don't support frameworks).

* [mtouch] Update logging to be less confusing when logging about WatchKit extensions.

* [mtouch] Don't compile P/Invoke wrappers for extensions that are sharing code.

The container app already has the P/Invoke wrappers.
2017-04-11 19:20:22 +02:00
Sebastien Pouliot 54e16ab9c5 [mmp] Add new Profile subclasses for Xamarin Mac (full / system) (#1989)
The fallback to MonoMacProfile is not correct if we ask for the
platform assembly - which blocks enabling the linker for that
assembly (only)
2017-04-11 12:01:06 -04:00
Sebastien Pouliot 479394782f [mmp] Show more information when a MM2001 error occurs (#1987)
Same that was done for `mtouch` in
https://github.com/xamarin/xamarin-macios/pull/1947
2017-04-11 11:06:51 -04:00
Sebastien Pouliot ef399e8756 [mmp] Add Intents and Photos mappings for namespaces (#1983)
MonoMacNamespaces needs them to properly remove the entries from
NSObject.mac.cs.

Fix debug logs:

Unprocessed library / namespace /System/Library/Frameworks/Intents.framework/Intents
Unprocessed library / namespace /System/Library/Frameworks/Photos.framework/Photos
2017-04-11 08:18:25 -04:00
Rolf Bjarne Kvinge 651a9735ff Use Visual Studio instead of Xamarin Studio. (#1972)
* Use Visual Studio instead of Xamarin Studio.

* VS doesn't have mdtool, it has vstool.

Also there's no need to manually invoke the mdtool.exe executable anymore
(which we did because the mdtool executable had a min macOS version of 10.9,
and we used to build tests on older macOS versions [1]), since now we only run
tests on older macOS versions, we don't build those tests there.

[1] a1932b0ccd
2017-04-11 08:13:34 +02:00
Alex Soto 2a85ec1674 [mtouch] Remove workaround for bug 43462, this fixes slow builds (bug 52545) (#1976)
https://bugzilla.xamarin.com/show_bug.cgi?id=52545

Some projects took a lot of time to build with the workaround for
bug 43462 but now that it is fixed we can remove it and stop the slowness
2017-04-10 08:20:13 +02:00
Chris Hamons 0d4243d793 [macos] Fix XM projects with p/invokes into non-system frameworks (#1968)
- Broken by d20ccf5bc6
2017-04-07 11:19:39 +02:00
Rolf Bjarne Kvinge 0a89324b16 [mtouch] Copy aot data to the app even for assemblies that aren't copied. Fixes #54499. (#1964)
We want to copy the aot data for both the 32-bit and the 64-bit versions of an
assembly even if the 32-bit and 64-bit versions of the assembly are identical.

https://bugzilla.xamarin.com/show_bug.cgi?id=54499
2017-04-06 14:29:38 +02:00
Chris Hamons d20ccf5bc6 [macos] Rework framework/weak_framework handling in mmp (#1953)
- Before this mmp was not adding -framework, -weak_framework consistently on non-static registrar use cases
- GatherFrameworks was previously not ported from mtouch, and did not work as DeploymentTarget was unset in mmp
- Added verbose prints so users can determine why various framework linkages are added
- Fixed an issue where duplicate were being added due to HandleFramework shoving args by hand
- Tested with auto test and https://github.com/chamons/xm-version-regression-test manual test
2017-04-05 14:38:40 -05:00
Timothy Risi 35b71c096f [macos] Change user visible strings for new framework names (#1925) 2017-04-05 10:16:48 -08:00
Rolf Bjarne Kvinge bbbe881747 Fix how we build frameworks. Fixes #53813. (#1952)
Previously we copied any equivalent .dylib and ran install_name_tool on the
library to change the library id to make it a framework.

Unfortunately this does not work when the library contains bitcode, because
bitcode embeds linker flags (-install_name for instance), and
install_name_tool does not change those linker flags.

This means that we need to create frameworks by linking with the proper
arguments, since it's much more difficult to fixup the embedded bitcode linker
flags as well.

So change how be build Mono.framework, Xamarin.framework, and any frameworks
built from assemblies to:

* Always link instead of fixup a dylib. For Mono.framework this means
  extracting all the object files from libmonosgen-2.0.a and linking those,
  for Xamarin.framework this means linking the object files we've already
  built.

* Make sure the library is correctly named when linked (once again: bitcode
  contains embedded linker flags, so renaming the executable later breaks
  stuff as well).

I've also extracted the logic that creates Mono.framework from
libmonosgen-2.0.a to a separate shell script, to deduplicate this logic.

This required a minor change in the mono builds: we need the Mono.framework
when building the `all` target, so make sure that happens.

https://bugzilla.xamarin.com/show_bug.cgi?id=53813
2017-04-03 11:52:29 +02:00
Rolf Bjarne Kvinge b568b2541e [builds] Improve mono/llvm dependencies. (#1948)
* [builds] Improve mono/llvm dependencies.

* Create a list of all the files in the mono and llvm repositories, and save
  these lists as a Make variable (in a generated Makefile - .deps.*.mk). We
  don't list _all_ the files in each repository, because there are quite a few
  (55k for mono), and Make measurably takes a while to check all of them, so
  try to limit it to a sane subset, without risking missing changes to files
  that actually matters.

* Always create stamp files when we're done with mono builds.

* Modify the mono/llvm builds to depend on all the files in their
  repositories.

* Explicitly list the corresponding .stamp-build-* files as dependencies for
  various files that are produced by the mono builds, so that make knows how
  to build these files.

* Rewrite the *-facade-check targets to depend on the corresponding
  *_BCL_TARGETS, so that we can avoid running a submake to the same Makefile
  to execute the facade checks.

  It now takes a little while (less than a second on my machine, which is
  fine) for make to list all dependencies and get their timestamps, but if
  executing multiple submakes this adds up to a multi-second timewaste.

  So avoid the timewaste by not doing submakes, but instead use dependencies
  to enforce the required target execution ordering.

* Don't depend on nicely named intermediate targets, since won't prevent
  rebuilds:

      build-cross64: setup-cross64

  Since the `setup-cross64` file doesn't exist, `build-cross64` will always
  execute. Instead depend on the stamp file:

      build-cross64: .stamp-configure-cross64

  And now `build-cross64` will only rebuild if needed.

* Don't try to list all intermediate files as .SECONDARY dependencies, instead
  list none at all, which works as if all files were listed as dependencies.

* Some targets had to move later in the file, since variables used in dependencies:

       foo: $(VARIABLE)

  must be defined before that point in the file, as opposed to variables used in recipes:

       foo:
           $(MAKE) $(VARIABLE)

  can be defined anywhere in the Makefile.

* Simplify the targets that sign assemblies significantly.

There are a few end results:

* It's now possible to do `make install`, without doing `make all` first. This
  might seem weird, but that also ensures the more common `make all install`
  works properly.

* Remakes (without any mono/llvm changes) in build/ are much faster, because
  we now won't recurse into every mono build:

      $ time make all -C builds/ -j8
      [...]
      real  0m1.873s

  This even means that we might be able to make it a habit to remake in the
  root directory, which doesn't take forever now:

      $ time make all -j8
      [...]
      real  0m4.521s

  Unfortunately adding `make install` to the mix still does some useless
  stuff, and it ends up taking ~30 seconds to complete a full build:

      $ time make all install -j8
      [...]
      real  0m32.542s

* [msbuild] Don't verify the xml syntax of targets files unless the files change.

* [build] Don't depend on installed files.

Don't depend on installed files, because that causes a rebuild when installing
to a different directory (i.e. package creation).

* Bump maccore to get build improvements.

Rebuilds are now very fast:

    $ make all install -j8
    $ time make all install -j8
    real	0m5.735s

Less than 6s to figure out that nothing needs to be done.

And strangely flushing the disk cache doesn't make it much slower:

    $ sudo purge
    $ time make all install -j8
    real	0m7.309s

Which probably means that Make mostly reads file metadata, and not actual file
contents (which is good).
2017-03-31 20:23:38 +02:00
Rolf Bjarne Kvinge 3fed06c2be [mtouch] Don't open files for writing when it's not needed. (#1949)
This fixes a file sharing exception:

> MTOUCH: error MT1009: Could not copy the assembly '[...]/msbuild/tests/MyActionExtension/bin/iPhone/Debug/MyActionExtension.dll' to '[...]/msbuild/tests/MyTabbedApplication/obj/iPhone/Debug/mtouch-cache/32/Link/MyActionExtension.dll': Sharing violation on path [...]/msbuild/tests/MyActionExtension/bin/iPhone/Debug/MyActionExtension.pdb
2017-03-31 11:19:10 +02:00
Sebastien Pouliot 8ffb553e9e [linker] Capture and show more information when a MT2001 error occurs (#1947) 2017-03-30 14:41:56 -05:00
Sebastien Pouliot 153056cf7f [mtouch] Provide a more accurate description of the MT0091 error (#1938)
The old one makes it sounds the linker is doing magic ;-)
2017-03-30 07:36:20 -05:00
Sebastien Pouliot 0dfcb1f09f Merge branch 'master' into mono-2017-02 2017-03-28 21:31:33 -05:00
Sebastien Pouliot abaced76e3 Merge pull request #1923 from spouliot/xcode83-master
Merge xcode8.3 in master
2017-03-28 21:27:18 -05:00
Sebastien Pouliot 6c702a15e9 [apidiff] Update XML references to what we're shipping in XI 10.8 / d15-1 (#1928) 2017-03-28 18:54:57 -05:00
Timothy Risi 923225369f [mmp] Remove check for null tls_provider since only appleTLS is supported (#1926) 2017-03-28 18:17:10 -05:00
Chris Hamons 3d32ca0c16 [macos] Remove ugly ObjC spam in clang invocation (#1927) 2017-03-28 18:16:51 -05:00
Vincent Dondain c0abf32083 Fix more merge issues 2017-03-28 15:10:38 -05:00
Sebastien Pouliot 566a7a4dad [mmp] Map macOS 10.12.4 SDK with Xcode 8.3 (#1759)
This should stop errors like below to happen on wrench

```
Xamarin.Bundler.MonoMacException: The type 'AVFoundation.IAVContentKeyRecipient' (used as a parameter in AVFoundation.AVContentKeySession.Add) is not available in macOS 10.12.2 (it was introduced in macOS 10.12.4). Please build with a newer macOS SDK (usually done by using the most recent version of Xcode).
```
2017-03-28 10:06:22 -05:00
Alex Soto f833bbc6ff Add Intents and VideoToolbox to registrar and fix version check (#1733)
A fix (thanks Rolf!) in how we do SDK version checks is needed
because for some reason `new Version (3, 2, 0)` isn't the same to
`new Version (3, 2)` and we end up with a MT4134 when building the
watchOS static registrar.
2017-03-28 09:50:08 -05:00
Rolf Bjarne Kvinge 26aa29ebd0 Merge remote-tracking branch 'origin/master' into mono-2017-02 2017-03-24 18:09:24 +01:00
Marek Safar 105ee26509 Merge remote-tracking branch 'origin/master' into mono-2017-02 2017-03-23 23:13:43 +01:00
Rolf Bjarne Kvinge 563f395cac Merge remote-tracking branch 'origin/master' into framework-sdk 2017-03-23 15:33:38 +01:00
Sebastien Pouliot 88d2045014 [mtouch][mmp] Clarify that -sgen-conc is currently experimental (#1881)
Clarification to match discussion in trello [1]. Another PR [2] is
handling XS UI.

references:
[1] https://trello.com/c/FbbxRyCG/2772-qa-xi-xm-mac-and-ios-samples-with-concurrent-gc-enabled#comment-58c9d05510a888ccd219639f
[2] https://github.com/xamarin/md-addins/pull/1578
2017-03-16 18:14:42 -04:00
Timothy Risi 7cf9a64656 [mmp] Correctly handle/report unexpected exception during execution
- Add extra logging in StaticRegistrar to help track down exceptions during generation
2017-03-16 12:21:45 -08:00
Vlad Brezae af02f7b31a Make sure we pass gc options if using concurrent sgen (#1867)
When using debug simulator we don't generate main.m so we were not passing the gc options.

The MONO_GC_PARAMS variable is not in app.EnvironmentVariables (which only contains environment variables passed to mtouch using --setenv), which is why the above condition does not trigger.
2017-03-15 16:59:08 -04:00
Rolf Bjarne Kvinge f27ad3d413 [mtouch] Fix bundling frameworks in WatchKit 1 extensions.
No frameworks should be bundled in WatchKit 1 extensions, they should be
bundled in the container (iOS) app.

This broke when merging the equivalent fix for master into the framework-sdk
branch (i.e. a broken merge).
2017-03-15 18:34:32 +01:00
Rolf Bjarne Kvinge 65ad42cce0 Merge remote-tracking branch 'origin/master' into framework-sdk 2017-03-14 19:25:11 +01:00
Marek Safar f88d52b424 Fixes tuner IL optimization for get_Size to work with short branches 2017-03-14 11:54:13 +01:00
Marek Safar 706ae6ac9e Updates mmp.csproj files path 2017-03-14 11:51:08 +01:00
Marek Safar 0913aece6c Revert "[linker] Inline BinaryCompatibility.TargetsAtLeast_Desktop_V4_5[_1] (#1518)"
This reverts commit e72b654890.

because it's no longer needed with latest mono
2017-03-14 11:51:08 +01:00
Marek Safar 0bad97749e Update monomac tuner 2017-03-14 11:51:08 +01:00
Marek Safar 60bf37efad Wire up configuration to MonoTouchSweepStep 2017-03-14 11:51:08 +01:00
Marek Safar d0ea1589ee Updates mtouch.csproj 2017-03-14 11:51:08 +01:00
Marek Safar 258cbdda4b Adds pdb handling to mtouch 2017-03-14 11:51:08 +01:00
Marek Safar 9a60036917 [tuner] Update System.Core rule 2017-03-14 11:47:06 +01:00
Marek Safar c51ba190f6 [mtouch] Copy pdb debug symbols when available 2017-03-14 11:47:06 +01:00
Marek Safar 2ca93a9de3 [linker] Update list of Facade assemblies 2017-03-14 11:47:06 +01:00
Marek Safar 4dc2abca76 Fixes mmp execution during build to use correct Mono.Cecil. For some reason setting MONO_PATH does not work 2017-03-14 11:47:06 +01:00
Marek Safar 01f0e67978 Update after another Cecil breaking change 2017-03-14 11:47:06 +01:00
Marek Safar ddb377b7ff [build] Register linker for submodule checks 2017-03-14 11:47:06 +01:00
Marek Safar 1020340ade Add netstandard to the build 2017-03-14 11:47:06 +01:00
Marek Safar 1d3ad5e8c2 Bump mono and linker submodule 2017-03-14 11:47:06 +01:00
Rolf Bjarne Kvinge ff9bae7bbc [mtouch] Don't put frameworks in WatchKit 1 extensions. Fixes #53232. (#1864)
The frameworks go into the container app's Frameworks directory.

https://bugzilla.xamarin.com/show_bug.cgi?id=53232
2017-03-13 17:34:27 -05:00
Rolf Bjarne Kvinge 1e498bce22 Merge remote-tracking branch 'origin/master' into framework-sdk 2017-03-07 07:38:30 +01:00
Rolf Bjarne Kvinge 5353607f53 [generator] Don't define 'GENERATOR', since IKVM sources use the same name (for something else). (#1811)
Generator diff: https://gist.github.com/rolfbjarne/fa9d91f13a6421135e089bed8e1ccefe
2017-03-02 07:13:10 +01:00
Rolf Bjarne Kvinge d196a78cda [registrar] Fix generic argument check to allow INativeObject. Fixes #52868. (#1788)
https://bugzilla.xamarin.com/show_bug.cgi?id=52868
2017-02-28 20:22:05 +01:00
Rolf Bjarne Kvinge 44cceb67bb [mtouch] Update error list. 2017-02-28 13:46:24 +01:00
Rolf Bjarne Kvinge 83d1111e10 [mtouch] Use fewer error numbers for code sharing failures. 2017-02-28 13:26:42 +01:00
Rolf Bjarne Kvinge 3f2915e595 [mtouch] Rephrase a few logging statements according to review. 2017-02-28 12:57:11 +01:00
Rolf Bjarne Kvinge 4de9a8c0d6 Merge remote-tracking branch 'origin/master' into framework-sdk 2017-02-28 10:16:18 +01:00
Chris Hamons 38058debbe [xm] Update help text for AOT (#1767) 2017-02-27 08:39:12 -06:00
Chris Hamons bf47f0f1e2 Fixes for XM 4.5 and netstandard13 and updated comments (#1758)
- Update comments on XM45.targets file
- Remove unnecessary AssemblySearchPaths hack causing issues using nugets with same name as Facades
- Note: MSBuild with XM 4.5 is still broken for now
2017-02-24 17:45:38 -06:00
Rolf Bjarne Kvinge ee5cc41c54 [mtouch] Disable fastdev for projects with more than one binding library. Works around bug #52727. (#1765)
https://bugzilla.xamarin.com/show_bug.cgi?id=52727
2017-02-24 13:34:47 -05:00
Sebastien Pouliot ba623e8efa [apidiff] Update XML references to C9 (#1738) 2017-02-21 18:42:29 -05:00
Rolf Bjarne Kvinge d212b97b1a Merge remote-tracking branch 'origin/master' into framework-sdk 2017-02-21 18:14:29 +01:00
Rolf Bjarne Kvinge 6f3fcd795a [mtouch] Correct (and simplify) AssemblyCollection.AddRange. 2017-02-20 17:14:14 +01:00
Rolf Bjarne Kvinge ca6b073fc1 [tools] Detect ARMv7k. (#1716) 2017-02-20 16:03:41 +01:00
Rolf Bjarne Kvinge 88e0eb5fc8 [generator] Use target framework to determine the platform. (#1690)
This cuts down another group of conditional compilation sections, paving the
way for an IKVM-based generator.

This makes it required to pass --target-framework for to generator executables
(previously only required for Xamarin.Mac/Unified to distinguish between the
different Xamarin.Mac/Unified variants), but it should be invisible to users
since we'll automatically pass the correct --target-framework argument from
the corresponding scripts (btouch/btv/bwatch/bmac) and the MSBuild targets.
This will only break somebody who is executing the managed executables
directly, but nobody should do that in the first place (it's not a supported
scenario).

Generated diff: https://gist.github.com/rolfbjarne/1674be6625632446dba774a305951981
2017-02-17 14:53:58 -05:00
Rolf Bjarne Kvinge cf14456cd5 [mtouch] Add docs and improve MT4146 to be an error if we can detect the generated code won't compile. Fixes #52530. (#1712)
https://bugzilla.xamarin.com/show_bug.cgi?id=52530
2017-02-17 16:00:53 +01:00
Rolf Bjarne Kvinge 6e90f92773 [mtouch] Rename a few variables to make them clearer. 2017-02-17 10:20:30 +01:00
Rolf Bjarne Kvinge 9518477412 [mtouch] Remove duplicated code. 2017-02-17 10:16:59 +01:00
Rolf Bjarne Kvinge 07127a76ca [mtouch] Make code sharing failures real warnings. 2017-02-17 10:16:51 +01:00
Rolf Bjarne Kvinge c1f87393ae Merge remote-tracking branch 'origin/master' into framework-sdk 2017-02-17 10:16:41 +01:00
Rolf Bjarne Kvinge 72ec3ad168 [mtouch/mmp] Add support for --nowarn and --warnaserror. (#1689)
Besides the obvious reasons, this is also useful when testing warnings, since
by making warnings errors, mtouch/mmp will exit a lot faster (and the tests
will finish faster).
2017-02-14 17:46:26 +01:00
Rolf Bjarne Kvinge 916a29accd [mtouch] Copy libprofiler-log.dylib to watch extensions.
Currently we don't put anything in the container watch app, which means we
need to put libprofiler-log.dylib in the watch extension itself.
2017-02-13 17:20:14 +01:00
Rolf Bjarne Kvinge 75c038fcd3 [mtouch] Disallow code sharing if bitcode options are different. 2017-02-13 15:51:10 +01:00
Zoltan Varga 884c86befd [mmp] Apply the changes in dea2dde259 to the mscorlib.xml descriptor in mmp as well. Fixes #52186. (#1685) 2017-02-13 10:16:42 +01:00
Rolf Bjarne Kvinge 816a62a64b [mtouch] A fat container app with a non-fat appex is allowed and not a problem. 2017-02-10 16:39:32 +01:00
Rolf Bjarne Kvinge fd8c09ecb8 [mtouch] Remove the Application.FastDev property, it's never set anymore. 2017-02-10 16:39:32 +01:00
Rolf Bjarne Kvinge 2eb2b7bd42 [mtouch] Remove fixed FIXME. 2017-02-10 16:39:27 +01:00
Rolf Bjarne Kvinge fd1e65d318 [mtouch] Validate a few assumptions about the linker output. 2017-02-10 16:39:27 +01:00
Rolf Bjarne Kvinge 8c4d56e898 [mtouch] Fix loading cached linked assemblies.
The cached linker results can have multiple identical input assemblies (for
assemblies that show up in both the app and any app extensions), so make sure
we don't load those more than once.
2017-02-10 16:39:26 +01:00
Rolf Bjarne Kvinge cd0c9c1163 [mtouch] Only files the linker copies when ensuring the linker output has up-to-date timestamps. 2017-02-10 16:39:26 +01:00
Rolf Bjarne Kvinge 10126f1839 [mtouch] Invalidated cached linked assemblies if a .config file changes.
Config files can modify the AOT-compiled code, so they must be taken into
account when doing cache validation for linked assemblies.
2017-02-10 16:39:26 +01:00
Rolf Bjarne Kvinge 8f91bb163e [mtouch] Re-AOT an assembly if its .mdb or .config files changed. 2017-02-10 16:39:25 +01:00
Rolf Bjarne Kvinge 6f4f54a790 [mtouch] Extensions don't need a NOTICE file, since it's already in the container app. 2017-02-10 16:39:25 +01:00
Rolf Bjarne Kvinge fb0749450c [mtouch] Make sure SDK assemblies in appex'es are included in the container app when code sharing. 2017-02-10 16:39:24 +01:00
Rolf Bjarne Kvinge c814e71fac [mtouch] Required symbols found by the linker must be filtered to the app we're building.
Since the linker can process multiple apps/appex'es at the same time, it also
means it will put together all the required symbols found in _all_ assemblies.

This means that we need to filter out required symbols for other
apps/appex'es.
2017-02-10 16:39:24 +01:00
Rolf Bjarne Kvinge d3e246b193 [mtouch] Don't do code sharing unless the container app's deployment target is at least 8.0.
Frameworks don't work on earlier iOS versions, so we can't (easily) share
native code in this scenario.
2017-02-10 16:39:24 +01:00
Rolf Bjarne Kvinge b1199d2b5a [mtouch] Remove dead code. 2017-02-10 16:39:23 +01:00
Rolf Bjarne Kvinge d0ea10de1a [mtouch] Build SDK assemblies by default to a framework whenever it makes sense.
Change the default to build SDK assemblies to a framework
(Xamarin.Sdk.framework) whenever an app has extensions.
2017-02-10 16:39:23 +01:00
Rolf Bjarne Kvinge 8a264c4602 [mtouch] Improve logging. 2017-02-10 16:39:23 +01:00
Rolf Bjarne Kvinge b547454e98 [mtouch] Fix cache invalidation with app extensions.
Change cache invalidation so that if any app extension's cache is invalid,
then invalidate the cache for the container app and all other app extensions.

This is the safest option when we're sharing code.
2017-02-10 16:39:23 +01:00
Rolf Bjarne Kvinge 95dfdd3a00 [cache] Remove dead code. 2017-02-10 16:39:22 +01:00
Rolf Bjarne Kvinge e7ae947189 [cache] Don't use the global command line arguments to determine input.
Don't use the global command line arguments to determine input, because that's
not the input we use for app extensions anymore.

Instead explicitly pass the input arguments when creating the cache.
2017-02-10 16:39:21 +01:00
Rolf Bjarne Kvinge 02b81e3332 [cache] Fix mmp/mtouch change detection.
Since neither mtouch nor mmmp is mkbundled anymore, the installed binary is in
fact a shell script.

This means that it's quite useless to check if the shell script has been
modified; instead check if the executing assembly has been modified (which
works now that we're not mkbundled anymore).
2017-02-10 16:39:20 +01:00
Rolf Bjarne Kvinge 27289efb1a [mtouch] Fix bundling frameworks from extensions.
We must build each appex bundle before the container bundle, so that we can
compute the frameworks each appex the needs before bundling the container app.

Also there's no need to store the list of frameworks appex's need in a file,
since everything is now done in the same mtouch process.
2017-02-10 16:39:17 +01:00
Rolf Bjarne Kvinge 7e28df59c4 [mtouch] Implement support for sharing code between app extensions and container apps.
Implement support for sharing both code and resources between app extensions
and their container app:

* AOT-compiled code. Each shared assembly is only AOT-compiled once, and if
  the assembly is built to a framework or dynamic library, it will also only
  be included once in the final app (as a framework or dynamic library in the
  container app, referenced directly by the app extension). If the assemblies
  are built to static objects there won't be any size improvements in the app,
  but the build will be much faster, because the assemblies will only be AOT-
  compiled once.
* Any resources related to managed assemblies (debug files, config files,
  satellite assemblies) will be put in the container app only.

Since these improvements are significant, code sharing will be enabled by
default.

Test results
============

For an extreme test project with 7 extensions (embedded-frameworks)[1]:

             with code sharing     cycle 9     difference
build time      1m 47s               3m 33s        -1m 46s = ~50% faster
app size         26 MB               131 MB       -105 MB  = ~80% smaller

For a more normal test project (MyTabbedApplication)[2] - this is a simple application with 1 extension:

             with code sharing     cycle 9     difference
build time      0m 44s               0m 48s        -4s    = ~ 8% faster
app size         23 MB                37 MB        -15 MB = ~40% smaller

Another tvOS app with one extension also show similar gains (MyTVApp)[3]:

             with code sharing     cycle 9     difference
build time      0m 22s               0m 48s        -26s    = ~54% faster
app size         22 MB                62 MB        -40 MB  = ~65% smaller

[1]: https://github.com/rolfbjarne/embedded-frameworks
[2]: https://github.com/xamarin/xamarin-macios/tree/cycle9/msbuild/tests/MyTabbedApplication
[3]: https://github.com/xamarin/xamarin-macios/tree/cycle9/msbuild/tests/MyTVApp
2017-02-10 16:39:15 +01:00
Rolf Bjarne Kvinge 85f28fbd59 [mtouch] Warn if mtouch loads an assembly from a different location than requested.
Warn if mtouch loads an assembly from a different location than requested
(which might be because there are multiple assemblies with the same name).

Also rework the MT0023 check a bit by explicitly loading the root assembly
first, and then detecting if any loaded assemblies matches the root assembly.
This results in code that's a bit more obvious, and it also works correctly
with extensions (previously the entire MT0023 check was skipped for
extensions).
2017-02-10 16:39:15 +01:00
Rolf Bjarne Kvinge a163cb2e14 [mtouch] Make the linker accept multiple root assemblies. 2017-02-10 16:39:14 +01:00
Rolf Bjarne Kvinge e4cf717b1d [mtouch] Simplify linker code slightly by passing fewer arguments around. 2017-02-10 16:39:14 +01:00
Rolf Bjarne Kvinge 8f80ba34af [mtouch] Refactor slightly how the profiler is linked in. 2017-02-10 16:39:14 +01:00
Rolf Bjarne Kvinge ffe3cfd39e [mtouch] Include the product assembly in the '@sdk' group for assembly build targets. 2017-02-10 16:39:13 +01:00
Rolf Bjarne Kvinge 7b5c1be2b7 [mtouch] Allow the assembly build target name for frameworks to end with '.framework'.
Allow the assembly build target name for frameworks to end with '.framework',
so that the following:

    --assembly-build-target=@sdk=framework=Xamarin.Sdk.framework

doesn't end up creating Xamarin.Sdk.framework.framework.
2017-02-10 16:39:13 +01:00
Rolf Bjarne Kvinge 18f220956a [mtouch] Simplify code a little bit. 2017-02-10 14:46:30 +01:00
Rolf Bjarne Kvinge f399d464da [mtouch] Add support for creating a dot file of the build tree. 2017-02-10 14:46:30 +01:00
Rolf Bjarne Kvinge 1be313490d [mtouch] Store each assembly's location in the generated main method.
Store the location of every assembly that can't be deduced at runtime (i.e.
all assemblies that are build to frameworks, since there can be multiple
assemblies in each framework, and the framework name can be customized).
2017-02-10 14:46:30 +01:00
Rolf Bjarne Kvinge 617362b738 [mtouch] Detect when assemblies have native dependencies between them and link properly. Fixes bug #43689.
Detect when assemblies have native dependencies between them (which can happen
when there are multiple binding projects, and the native libraries in those
binding projects have dependencies between them), and add the proper link
arguments (this is only required when building to dynamic libraries or
frameworks, since otherwise everything is linked to one big binary and there
are no dependency problems).

https://bugzilla.xamarin.com/show_bug.cgi?id=43689
2017-02-10 14:46:29 +01:00
Rolf Bjarne Kvinge 96637b5e13 [mtouch] Remove dead code. 2017-02-10 14:46:29 +01:00
Rolf Bjarne Kvinge f9e3cbdf57 [mtouch] Incremental builds (--fastdev) is the same as compiling all assemblies to dynamic libraries. 2017-02-10 14:46:29 +01:00
Rolf Bjarne Kvinge 473c6092b6 [mtouch] Add support for compiling the pinvoke wrappers to a framework. 2017-02-10 14:46:29 +01:00
Rolf Bjarne Kvinge e620caefe2 [mtouch] Implement support for creating frameworks from assemblies.
Implement support for linking the output from AOT compilation to frameworks,
and then bundling those frameworks.
2017-02-10 14:46:28 +01:00
Rolf Bjarne Kvinge 894ebebce0 [mtouch] Treat aot data as a file related to the assembly, and copy it at the same time. 2017-02-10 14:46:28 +01:00
Rolf Bjarne Kvinge 422c389ce1 [mtouch] Remove dead code. 2017-02-10 14:46:28 +01:00
Rolf Bjarne Kvinge d24a4e3b62 [mtouch] Rework how tasks are built.
The previous build system kept a forward-pointing single linked list of tasks
to execute: task X had a list of subsequent tasks to execute. If task X was
up-to-date, it was not created (and the next tasks were directly added to the
list of tasks to execute).

In this world it became complicated to merge output from tasks (for instance
if the output of task X and task Y should be a consumed by a single task
producing a single output, since the corresponding task would end up in both
X's and Y's list of subsequent tasks).

Example: creating a single framework from the aot-compiled output of multiple
assemblies.

So I've reversed the logic: now we keep track of the final output, and then
each task has a list of dependencies that must be built.

This makes it trivial to create merging tasks (for the previous example, there
could for instance be a CreateFrameworkTask, where its dependencies would be
all the corresponding AotTasks).

We also always create every task, and then each task decides when its executed
whether it should do anything or not. This makes it unnecessary to 'forward-
delete' files when creating tasks (say you have three tasks, A, B, C; B
depends on A, and C depends on B; if A's output isn't up-to-date, it has to
delete its own output if it exists, otherwise B would not detect that it would
have to re-execute, because at task *creation* time, B's input hadn't
changed).

Additionally make it based on async/await, since much of the work happens in
externel processes (and we don't need to spin up additional threads just to
run external processes). This makes us have less code run on background
threads, which makes any issues with thread-safety less likely.
2017-02-10 14:46:28 +01:00
Rolf Bjarne Kvinge 0ac6b4fc15 [mtouch] Refactor 'BuildApp' into multiple methods. 2017-02-10 14:46:28 +01:00
Rolf Bjarne Kvinge ee0de7de52 [mtouch] Use BuildTask's logic to check if the task needs to be updated. 2017-02-10 14:46:27 +01:00
Rolf Bjarne Kvinge da0a7ffdd3 [mtouch] Make sure output directory exists. 2017-02-10 14:46:27 +01:00
Rolf Bjarne Kvinge dc70a0e254 [mtouch] Rename parameter to be more descriptive. 2017-02-10 14:46:27 +01:00
Rolf Bjarne Kvinge c2ad1ac499 [mtouch] Don't pass '-read_only_relocs suppress' to the native linker when compiling to asm-only bitcode either.
It fails to link.
2017-02-10 14:46:27 +01:00
Rolf Bjarne Kvinge 6e2648e125 [mtouch] Make sure CompilerFlags always have a Target. 2017-02-10 14:46:27 +01:00
Rolf Bjarne Kvinge 2f380ae509 [mtouch] Remove unused field. 2017-02-10 14:46:26 +01:00
Rolf Bjarne Kvinge 038705eb25 [mtouch] Use BuildTask's logic to check if the task needs to be updated. 2017-02-10 14:46:26 +01:00
Rolf Bjarne Kvinge 04a6f585c5 [mtouch] Make the install_name logic a bit more flexible. 2017-02-10 14:46:26 +01:00
Rolf Bjarne Kvinge a52f18ec3b [mtouch] Give BuildTasks enough information to determine if the task is up-to-date or not. 2017-02-10 14:46:26 +01:00
Rolf Bjarne Kvinge 1f7ce2e445 [mtouch] Fix the error message for 'CompileTask'.
The AOT-compilation occurs in the AOT-task now, and then we compile the result
using CompileTask.

This means that the error message in CompileTask was slightly incorrect, so
rectify it.
2017-02-10 14:46:25 +01:00
Rolf Bjarne Kvinge fea1fc6447 [mtouch] Teach about source files to CompilerFlags. 2017-02-10 14:46:25 +01:00
Rolf Bjarne Kvinge 024d5a92ca [mtouch] Add target-specific error messages.
This removes a little bit of duplicated code, and gives us slightly better error messages.
2017-02-10 14:46:25 +01:00
Rolf Bjarne Kvinge 9e7cec490f [mtouch] Move native linking to a separate task. 2017-02-10 14:42:11 +01:00
Rolf Bjarne Kvinge 3a8d62008d [mtouch] Look for linker input in the linker flags when parsing linker warnings.
Look for libraries passed to the linker in the linker flags, which is the
canonical location for linker input.
2017-02-10 14:42:11 +01:00
Rolf Bjarne Kvinge 69ff0c4486 [mtouch] Move CompileRegistrarTask creation out of the task itself. 2017-02-10 14:42:10 +01:00
Rolf Bjarne Kvinge 3a5c493e85 [mtouch] Remove PInvokesTask creation out of the task itself. 2017-02-10 14:42:10 +01:00
Rolf Bjarne Kvinge ed1a1ae3b8 [mtouch] Rename BuildTask.Build to Run.
Some tasks are technically not 'building', another verb would fit better, so
use the more generic 'Run' instead of 'Build'.
2017-02-10 14:42:10 +01:00
Rolf Bjarne Kvinge 9c6bf21a18 [mtouch] Refactor Generate|CompileMainTasks to only know how to do their task. 2017-02-10 14:42:10 +01:00
Rolf Bjarne Kvinge 0a91d75b2c [mtouch] Create a 'RunRegistrarTask'. 2017-02-10 14:42:09 +01:00
Rolf Bjarne Kvinge e73d71cbe8 [mtouch] Build into arch-specific temporary directories, instead of having arch-specific filenames.
This makes dylibs automatically have the correct dylib id, which means no
fixups are required.

For instance: we'd build libpinvokes.armv7.dylib from libpinvokes.armv7.m,
which by default ends up with a dylib id of "libpinvokes.armv7.dylib". With
this fix no change is required, since we now build armv7/libpinvokes.dylib
from armv7/libpinvokes.m.
2017-02-10 14:42:09 +01:00
Rolf Bjarne Kvinge dcd37c9df2 [mtouch] Compute the dependency map for assemblies earlier and store the results.
Compute the dependency map for assemblies earlier, and store the results.

In a later commit we'll need to know if a dependency map was successfully
computed when determining if a task is up-to-date or not.
2017-02-10 14:42:09 +01:00
Rolf Bjarne Kvinge eaf13f2fcc [mtouch] Link with the correct version of libxamarin/libmono according to other build options. 2017-02-10 14:39:49 +01:00
Rolf Bjarne Kvinge 03614fc775 [mtouch] Strip while copying assemblies.
Rework the code that copies assemblies and their related files to the app
bundle to take into account that we might be building to frameworks now.

Also strip the assemblies when they're copied (if they must be stripped),
which removes the need for custom logic to copy files related to stripped
assemblies.

Additionally change how we handle duplicated assemblies by checking for
duplication before copying them to the app bundle. This allows us to copy
assemblies to the root directory (not the .monotouch-[32|64] subdirectory) if
the 32-bit and 64-bit versions are identical, which also means we won't need
symlinks anymore.
2017-02-10 14:39:48 +01:00
Rolf Bjarne Kvinge d58dcb8141 [mtouch] Remove dead code. 2017-02-10 14:35:20 +01:00
Rolf Bjarne Kvinge f1397b561e [mtouch] No need to pass the input file around if all we want to know is the source code type.
This makes the code a little bit more self-descriptive.
2017-02-10 14:35:20 +01:00
Rolf Bjarne Kvinge 5787bc0ef2 [mtouch] Validate the assembly build targets. 2017-02-10 14:29:11 +01:00
Rolf Bjarne Kvinge a590612751 [mtouch] Add an --assembly-build-target option. 2017-02-10 14:29:11 +01:00
Rolf Bjarne Kvinge ffad69e186 [mtouch] Call linker flags 'linker_flags' and not 'compiler_flags'. 2017-02-10 14:29:11 +01:00
Rolf Bjarne Kvinge e83c2b507f [mtouch] Show output in ProcessTask if the process returns a non-zero exit code. 2017-02-10 14:29:10 +01:00
Rolf Bjarne Kvinge 815fbef3fc [mtouch] Split 'MainTask' into 'GenerateMainTask' and 'CompileMainTask'. 2017-02-10 14:29:10 +01:00
Rolf Bjarne Kvinge 876dc938c8 [mtouch] Rename 'RegistrarTask' to 'CompileRegistrarTask' to be more descriptive. 2017-02-10 14:29:10 +01:00
Rolf Bjarne Kvinge 267c28b552 [mtouch] Remove redundant 'internal' class modifier. 2017-02-10 14:29:10 +01:00
Rolf Bjarne Kvinge 6b9bb63e24 [mtouch] Rename Bitcodeify to BitcodeifyTask to match other similar classes. 2017-02-10 14:29:10 +01:00
Rolf Bjarne Kvinge ee5b915cdc [mtouch] Upgrade mtouch to .NET 4.6. 2017-02-10 14:29:10 +01:00
Rolf Bjarne Kvinge ddedfc2798 [mtouch] Make the architecture a suffix instead of infix for aotdata filenames.
Make the architecture a suffix instead of infix for aotdata filenames so that
it's easier to compute the filename from the assembly name without passing
printf-style format strings around.
2017-02-10 14:29:09 +01:00
Rolf Bjarne Kvinge 5da8fd6ad0 [mtouch] Fix WriteIfDifferent to create target directory if needed. 2017-02-10 14:29:09 +01:00
Rolf Bjarne Kvinge 1385b91202 [mtouch] Simplify the code to update the list of assemblies after linking.
Also move it to a separate method, since we'll be soon needing the logic in
multiple locations.
2017-02-10 14:29:09 +01:00
Rolf Bjarne Kvinge a07085aafa [mtouch] Create a custom AssemblyCollection class.
Create a custom AssemblyCollection class that contains a dictionary with
assembly identity (name) -> Assembly mapping.

This also means that we can detect if we end up loading multiple assemblies
with the same identity, and show an error in that case (even if that case
should never happen since we cache assemblies based on the identity, it's nice
to have code that ensures it).
2017-02-10 14:15:35 +01:00
Rolf Bjarne Kvinge a4dbb289b6 [mtouch] Make the linker output a list of AssemblyDefinition instead of paths.
Have the linker return the paths for AssemblyDefinitions is just redundant if
we immediately use those paths to re-load the AssemblyDefinitions.
2017-02-10 14:12:02 +01:00
Rolf Bjarne Kvinge 5fb09b1b84 [linker] Remove static state, and put the state inside DerivedLinkContext instead. (#1657)
Remove the usage of static variables in the linker so that one day we can run
the linker in parallel over multiple assembly sets.
2017-02-10 07:45:42 +01:00