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

710 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 144ff1a6ba [mtouch] A few adjustments after allowing multiple root assemblies.
* Remove the MT0008 test, since the error will never be shown again.
* Check non-existent root assemblies and report MT0018 instead of MT0007 if
  they look like command-line arguments.
* Collect all MT0018/MT0007 errors before reporting any of them.
2017-04-19 19:08:59 +02:00
Rolf Bjarne Kvinge c6ec561c37 [linker] Don't mark public types from product assemblies when in embeddinator mode.
We automatically add the product assembly as a root assembly when in
embeddinator mode (because other root assemblies may not reference it), but we
don't want to mark all public types from product assemblies.
2017-04-19 11:39:06 +02:00
Rolf Bjarne Kvinge d83067c2a3 [mtouch] Fix whitespace issue. 2017-04-18 17:28:25 +02:00
Rolf Bjarne Kvinge 1acf7358da [mmp] Build and install pdb files. Fixes #53927. (#2016)
https://bugzilla.xamarin.com/show_bug.cgi?id=53927
2017-04-18 15:50:34 +02:00
Rolf Bjarne Kvinge 6568ec70ed [mtouch] Install pdb files, not mdb files (which we're not creating anymore) (#2017) 2017-04-18 09:45:05 -04:00
Rolf Bjarne Kvinge 488cccb8d4 [mtouch] Put simulator assemblies into MonoBundle/simulator for frameworks.
Put simulator assemblies in MonoBundle/simulator for frameworks, so that we
can have a single framework that contains both device and simulator
assemblies without assemblies conflicting between device and simulator.

The device assemblies continue in the same place, in the MonoBundle directory,
so no additional checks are needed on device.
2017-04-18 15:18:46 +02:00
Rolf Bjarne Kvinge ba072d3168 [mtouch] Mark all public types in the root assemblies when in embeddinator mode.
Otherwise the linker might remove root assemblies, if they're libraries and
nothing at all is marked in them.
2017-04-18 11:36:30 +02:00
Rolf Bjarne Kvinge 7134c46652 [mtouch] The main executable is a shared library when building for simulator in embeddinator mode. 2017-04-18 11:36:30 +02:00
Rolf Bjarne Kvinge ef31d1fcd3 [mtouch] Generate assembly to framework mapping for the simulator when in embeddinator mode. 2017-04-18 11:36:30 +02:00
Rolf Bjarne Kvinge fceb49c4cd [mtouch] We need to create a fat simulator framework in embeddinator mode. 2017-04-18 11:36:29 +02:00
Rolf Bjarne Kvinge 5f1778298d [mtouch] Refactor lipo logic to a separate method. 2017-04-18 11:36:29 +02:00
Rolf Bjarne Kvinge 2b1e7af83d [mtouch] When in embeddinator mode, we still need to build the main executable for the simulator. 2017-04-18 11:36:29 +02:00
Rolf Bjarne Kvinge 80536f9bd7 [mtouch] Simlauncher won't work for the embeddinator. 2017-04-18 11:36:29 +02:00
Rolf Bjarne Kvinge c43eedf781 [mtouch] Make sure the platform assembly is always included in the app when in embeddinator mode. 2017-04-18 11:36:28 +02:00
Rolf Bjarne Kvinge e44c1241ac [mtouch] When in embeddinator mode, we must link the generated registrar and pinvoke code into the framework we create.
When in embeddinator mode, we must link the generated registrar and pinvoke
code into the framework we create.

This also requires creating the corresponding aot/link tasks after creating
the registrar/pinvoke tasks.
2017-04-18 11:36:28 +02:00
Rolf Bjarne Kvinge 548ff02ed5 [mtouch] When in embeddinator mode the global gcc flags apply to the framework we create. 2017-04-18 11:36:28 +02:00
Rolf Bjarne Kvinge 08ba65ce67 [mtouch] Don't try to lipo the main executable in embeddinator mode.
Don't try to lipo the main executable in embeddinator mode, because there
isn't a main executable.
2017-04-18 11:36:28 +02:00
Rolf Bjarne Kvinge ca3fc72d38 [mtouch] When in embeddinator mode, create the NOTICE in the framework instead of the app. 2017-04-18 11:36:27 +02:00
Rolf Bjarne Kvinge 4c2419f993 [mtouch] When in embeddinator mode, libxamarin and libmono are linked statically into the target framework. 2017-04-18 11:36:27 +02:00
Rolf Bjarne Kvinge d1ebaa94db [mtouch] Add an embeddinator mode. 2017-04-18 11:36:27 +02:00
Rolf Bjarne Kvinge 392deaca30 [mtouch] Refactor NOTICE writing a little bit to make it possible to write NOTICE to any directory. 2017-04-18 11:36:27 +02:00
Rolf Bjarne Kvinge 098b24d99e [mtouch] Set linker flags required by libxamarin when linking with libxamarin. 2017-04-18 11:36:26 +02:00
Rolf Bjarne Kvinge a3e066738c [mtouch] Set linker flags required by libmono when linking with libmono. 2017-04-18 11:36:26 +02:00
Rolf Bjarne Kvinge 1afae37c7f [runtime] Add support for initializing in an embedder mode. 2017-04-18 11:13:42 +02:00
Rolf Bjarne Kvinge 38960a5b9a [mtouch] Add support for multiple root assemblies from the command line. 2017-04-18 11:13:41 +02:00
Rolf Bjarne Kvinge 2eb1ce4616 [mtouch/mmp] When gathering frameworks, gather into the product assembly's frameworks.
When gathering frameworks, gather into the product assembly's frameworks, not
the global frameworks.

This is necessary when building a non-linked dylib/framework in embeddor mode,
because we link the registrar code into the framework, and that code will
require linking with all the frameworks all the assemblies require.
2017-04-18 11:13:21 +02:00
Sebastien Pouliot d9fc5cf837 [mtouch] Update code that only considered .mdb (not .pdb) (#2003)
Also stop using `mdb` as the name for debug symbols and remove

> static MdbReader mdb_reader;

since we're not mkbundl'ing mtouch anymore.

Related to https://github.com/xamarin/xamarin-macios/pull/2002 for mmp
2017-04-17 12:48:35 +02:00
Chris Hamons 521bdf3691 Fix bird typo in mmp args (#2006) 2017-04-14 10:53:27 -05:00
Chris Hamons 7d252a5353 [macos] Refactor framework skipping logic in mmp (#2005)
- Fixup comment in https://github.com/xamarin/xamarin-macios/pull/1968 that was missed
2017-04-14 10:45:14 -05:00
Marek Safar 594a375c02 Update tools to use csc 2017-04-14 09:11:01 +02:00
Marek Safar ae5e483764 [linker] Update linker to recognize debug async notification methods. Fixes #55037 (#2004) 2017-04-13 11:54:47 -04:00
Sebastien Pouliot d3d7e6752a [mmp] Update code that only considered .mdb (not .pdb) (#2002) 2017-04-12 17:38:54 -04:00
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
Sebastien Pouliot eed503e422 [mtouch] Reload symbols before saving an assembly again (when needed). Fixes #51667 (#1651) (#1653)
Cecil cannot save an assembly more than once without reloading its
debugging symbols. There was code for this, in the special case where
an assembly could be saved more than once. However the order of the
operations changed and the code to reload symbols was now located too
late.

https://bugzilla.xamarin.com/show_bug.cgi?id=51667
2017-02-08 20:50:29 -05:00
Chris Hamons 2c835c5294 [XM] Add hybrid/standard AOT option and improve AOT code (#1650)
* [XM] Seperate parsing from compilation in AOT code

- Parsing command line options was too entangled with actually compiling
- Refactor test code to centralize Compile, reducing some complexity of tests
- Groundwork for hybrid vs non-hybrid AOT work

* Add hybrid/standard AOT support

* Add xammac_tests to makefile/jenkins

* Add flag to force AOT

* Disable MonoTouchFixtures.Contacts.ContactStoreTest.GetUnifiedContacts on XM due to prompts on Jenkins
2017-02-08 13:40:48 -06:00
Rolf Bjarne Kvinge 84953af5de [mtouch/mmp] Fix cecil dependencies. (#1656)
Make sure mtouch/mmp rebuild cecil when anything changes in cecil.
2017-02-08 14:57:37 +01:00
Rolf Bjarne Kvinge be12544444 [mtouch] Remove unused file from the build. (#1655) 2017-02-08 13:45:57 +01:00
Chris Hamons f6918bdc43 Update xm apidiff to cycle8 (#1624) 2017-02-06 08:40:43 -06:00
Sebastien Pouliot a94e4dc423 Revert c633bd378f and fix #51805 with a new Cecil API (#1640)
* Revert "[mtouch][linker] Remove type forwarders. Fixes #51805 (#1589) (#1600)"

This reverts commit c633bd378f.

* [mono] Bump mono to get latest cecil (cycle9) and fix linker's ExternalType.Scope. Fixes #52187 and #51805

Original fix for bug #51805 was reverted since it caused a regression [2]
when type forwarders are used thru reflection, which happens when
serializing some types.

[1] https://bugzilla.xamarin.com/show_bug.cgi?id=51805
[2] https://bugzilla.xamarin.com/show_bug.cgi?id=52187
2017-02-03 16:12:28 -05:00
Alex Soto 3b0f1baf69 [mmp/btouch] Better error when bad xml linker input is given to mmp/mtouch (#1614)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=52238

If you give mtouch/mmp a linker xml file with bad input for
example a Xamarin.iOS app and the linker.xml has a reference
to Xamarin.Mac instead of X.I.dll i.e.

<?xml version="1.0" encoding="UTF-8" ?>
<linker>
	<assembly fullname="Xamarin.Mac">
    	<type fullname="ObjCRuntime.Constants"/>
	</assembly>
</linker>

You will get a not so helpful generic error

MT2001 Could not link assemblies. Reason: Failed to process XML description: <unspecified>

It seems that when you use a xml file for linker you get a
`XmlResolutionException` from cecil when it fails to resolve
and the better error comes from the inner exception so we use
that instead.

New error output for XmlResolutionException:

MT2017: Could not process XML description: Failed to resolve assembly: 'Xamarin.Mac, Culture=neutral, PublicKeyToken=null'
2017-02-03 14:04:06 -06:00
Rolf Bjarne Kvinge d9c23c2ba8 [mtouch] Automatically enable bitcode if LLVM is enabled. Fixes #52241. (#1620)
Currently we can't build watchOS projects if LLVM is enabled, but bitcode is
not (see bug #51634).

Additionally the IDEs do not have UI to select if bitcode is enabled or not,
so automatically enable it if LLVM is enabled (since most likely people will
be building for the App Store if LLVM is enabled).

https://bugzilla.xamarin.com/show_bug.cgi?id=51634
https://bugzilla.xamarin.com/show_bug.cgi?id=52241
2017-02-03 07:16:17 +01:00
Rolf Bjarne Kvinge 68415e88c5 [mtouch] Fix build error with fastdev & libpinvokes & paths with spaces. (#1618) 2017-02-02 18:09:42 +01:00
Timothy Risi 48682b27aa Resource files for mac should be copied to the app bundle (#1500)
Resource files for mac should be copied to the app bundle
* Move the Satellite code used by mac to tools/common/Assembly.cs
* Add EmbeddedResources test to xammac_tests
2017-01-31 15:59:08 -09:00
Sebastien Pouliot c633bd378f [mtouch][linker] Remove type forwarders. Fixes #51805 (#1589) (#1600)
a. System.Net.Http.Primitives.dll is user code *and* contains type
forwarders (it's like a facade) to another facade assembly,
System.Net.Primitives.dll, that ships with the SDK;

b. The former, System.Net.Http.Primitives.dll, is not processed by
the linker, e.g. no code is removed and the assembly cannot be deleted.
However we save back (as much as we can [1]) the result of any type
being resolved;

c. It also means the later, System.Net.Primitives.dll, is fully linked
and (in many cases) can be removed from the final application (as it's
mostly forwarders).

d. This means the final, re-saved, System.Net.Http.Primitives.dll binary
could point to non-existing metadata, i.e. the removed
System.Net.Primitives.dll, because of [1].

Because we resolve (and save) the forwarders *and* because we do not
allow code downloads or generation (Apple restriction) it is possible to
remove the forwarders, which will fix the issue for XI.

[1] The scope of exported types cannot be updated
abb4e902da/Mono.Cecil/ExportedType.cs (L41)

There is also a enhancement bug, #11165, about this but it predated our
PCL support and the resolve-n-save that we now do for forwarders. This
is now _fully_ fixed.

References:
* https://bugzilla.xamarin.com/show_bug.cgi?id=11165 (enhancement)
* https://bugzilla.xamarin.com/show_bug.cgi?id=51805
2017-01-31 16:22:34 -05:00
Rolf Bjarne Kvinge bac0253848 [mtouch] Automatically disable incremental builds if building to bitcode and any third-party bindings were found. Works around bug #51710. (#1592)
Most projects building to bitcode (any kind of bitcode, this includes the
marker-only version as well), will fail to link when linking with third-party
libraries and incremental builds are enabled.

So automatically disable incremental builds when we detect this scenario.

This is only a workaround until we can make this scenario build correctly.

https://bugzilla.xamarin.com/show_bug.cgi?id=51710
2017-01-31 14:55:54 +01:00
Rolf Bjarne Kvinge f24c8f7331 [docs] Update text about MT4134 to not mention the legacy registrar anymore. (#1558)
Since the legacy registrar is not available anymore.
2017-01-26 15:31:26 +01:00
Rolf Bjarne Kvinge 3dac0bae81 Use @rpath instead of @executable_path in dylibs. (#1552)
Use @rpath instead of @executable_path in dylibs, since it allows us to be
more flexible when placing dylibs in the app.

In particular with this change it's trivial to put libmonosgen-2.0.dylib in
the container app, and reference it from extensions.
2017-01-24 20:24:32 +01:00
Rolf Bjarne Kvinge 30082029cb [mtouch] Fix compiler warning in generated main code. (#1550) 2017-01-24 13:43:38 +01:00
Rolf Bjarne Kvinge a42419ab2d [mtouch] Remove dead code. (#1549) 2017-01-24 13:43:01 +01:00
Rolf Bjarne Kvinge 62faa06f4b [mtouch] Don't parse appex executables for architecture(s). (#1551)
Don't parse appex executables for the architecture(s) when we have the exact
same information already in the process.
2017-01-24 13:42:49 +01:00
Rolf Bjarne Kvinge 29dbb38ad4 [mtouch] It's no longer necessary to set MONO_GC_PARAMS during AOT-compilation. (#1548)
According to Vlad it's not necessary to set MONO_GC_PARAMS during AOT-
compilation, since all MONO_GC_PARAMS options can be changed at runtime:

Rolf Kvinge [16:35] @vlad.brezae is this true for all the different options MONO_GC_PARAMS take: https://github.com/xamarin/xamarin-macios/pull/1546#discussion_r97318092?
Rolf Kvinge [16:36] I remember this: https://bugzilla.xamarin.com/show_bug.cgi?id=35414#c14
Rofl Kvinge [16:36] which apparently you changed here, so that it can be changed at runtime: https://bugzilla.xamarin.com/show_bug.cgi?id=35414#c27
Rolf Kvinge [16:36] but I don't know if this is true for all the options you can pass using MONO_GC_PARAMS
Vlad Brezae [16:41] yes, it should be true for all of them, that was a bug
Rolf Kvinge [16:41] ok, that's great news 😄
2017-01-24 10:07:42 +01:00
Vlad Brezae cd9292ffdd Enable selecting the sgen major mode (#1546)
* [mmp/mtouch] Add option for concurrent sgen

* [msbuild] Add support for concurrent sgen properties

* [mmp] Test for concurrent sgen option
2017-01-24 07:28:15 +01:00
Rolf Bjarne Kvinge 1a7a4ab463 [mtouch] Add support for specifying how to optimize LLVM output. (#1532)
Performance tests
-----------------

This is for a new watchOS extension project, built for release.

* The default (currently -O2) optimizations:      41s (  baseline )  30.027.060 bytes (     baseline    )
* All optimizations disabled (`--llvm-opt=all=`): 17s (-24s = -59%)  32.978.312 bytes (+2.951.252 = +10%)
* Optimized for size (`--llvm-opt=all=-Os`):      36s ( -5s = -12%)  28.617.408 bytes (-1.409.652 =  -5%)
* Optimized for more size (`--llvm-opt=all=-Oz`): 35s ( -6s = -15%)  28.601.016 bytes (-1.426.044 =  -5%)
* Optimized slightly (`--llvm-opt=all=-O1`):      35s ( -6s = -15%)  28.666.556 bytes (-1.360.504 =  -5%)
* Optimized a lot (`--llvm-opt=all=-O3`):         41s (  0s =   0%)  30.403.996 bytes (+  376.936 =  +1%)

Conclusions
-----------

* The fastest build by far (less than twice as fast) is if optimizations are
  disabled, but this adds a 10% size penalty (~3 MB in this test case),
  compared to the baseline, and 15% size penalty (4.3 MB) compared to -Oz.
* -Oz seems to have the best overall results: at least as fast as any other
  optimized build, and the smallest app as well.

Caveats
-------

Some optimizations might not work the AOT compiled code. The resulting
binaries have not been tested.
2017-01-20 16:11:48 +01:00
Rolf Bjarne Kvinge 786ae13f80 [mtouch] Fix an unnecessary re-link when the linker copies assemblies without processing them. (#1534)
Event sequence:

* mtouch is executed with the linker disabled.
* The linker pipeline copies all input assemblies (since the linker is
  disabled the assemblies don't change) into the PreBuild directory. This will
  keep the original timestamps of the input assemblies.
* mtouch is executed again, when none of the input assemblies changed.
* The linker pipeline will re-execute, because it will see that at least one
  of the input assemblies (at least the .exe) is newer than at least one of
  the assemblies in the PreBuild directory (usually a framework assembly,
  because those have the original timestamp from their install location).

Fix:

Touch all the assemblies in the PreBuild directory after the linker pipeline
executes the first time. This way the second time mtouch is executed, it will
find that all assemblies in the PreBuild directory have timestamps later than
all the input assemblies, so it will load the cached linked assemblies,
instead of re-executing the linker pipeline.
2017-01-20 10:45:08 +01:00
Sebastien Pouliot e72b654890 [linker] Inline BinaryCompatibility.TargetsAtLeast_Desktop_V4_5[_1] (#1518)
This is a more interesting case since the inlining of 2 property getters
has a deeper impact and removes other types/methods from the final app.

Here we don't care what's inside the code we replace - only that it
always return a constant boolean after evaluation. That _constant_ is
something we can add tests to ensure we continue to behave identically.

```
--- before	2017-01-16 14:58:12.000000000 -0500
+++ after	2017-01-16 14:58:09.000000000 -0500
@@ -1580,7 +1580,6 @@
 System.String System.AppDomain::get_BaseDirectory()
 System.String System.AppDomain::get_FriendlyName()
 System.String System.AppDomain::getFriendlyName()
-System.String System.AppDomain::GetTargetFrameworkName()
 System.String System.AppDomain::ToString()
 System.UnhandledExceptionEventHandler System.AppDomain::UnhandledException
 System.UnhandledExceptionEventHandler System.AppDomain::UnhandledException
@@ -11949,54 +11948,12 @@
 System.Reflection.FieldInfo System.Runtime.Serialization.ValueTypeFixupInfo::ParentField()
 System.Runtime.Serialization.ValueTypeFixupInfo
 System.Void System.Runtime.Serialization.ValueTypeFixupInfo::.ctor(System.Int64,System.Reflection.FieldInfo,System.Int32[])
-System.Runtime.Versioning.BinaryCompatibility
-System.Boolean System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap::TargetsAtLeast_Desktop_V4_5
-System.Boolean System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap::TargetsAtLeast_Desktop_V4_5_1
-System.Boolean System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap::TargetsAtLeast_Desktop_V4_5_2
-System.Boolean System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap::TargetsAtLeast_Desktop_V4_5_3
-System.Boolean System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap::TargetsAtLeast_Desktop_V4_5_4
-System.Boolean System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap::TargetsAtLeast_Desktop_V5_0
-System.Boolean System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap::TargetsAtLeast_Phone_V7_1
-System.Boolean System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap::TargetsAtLeast_Phone_V8_0
-System.Boolean System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap::TargetsAtLeast_Silverlight_V4
-System.Boolean System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap::TargetsAtLeast_Silverlight_V5
-System.Boolean System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap::TargetsAtLeast_Silverlight_V6
-System.Boolean System.Runtime.Versioning.BinaryCompatibility::get_TargetsAtLeast_Desktop_V4_5()
-System.Boolean System.Runtime.Versioning.BinaryCompatibility::get_TargetsAtLeast_Desktop_V4_5_1()
-System.Boolean System.Runtime.Versioning.BinaryCompatibility::ParseTargetFrameworkMonikerIntoEnum(System.String,System.Runtime.Versioning.TargetFrameworkId&,System.Int32&)
-System.Boolean System.Runtime.Versioning.BinaryCompatibility::TargetsAtLeast_Desktop_V4_5()
-System.Boolean System.Runtime.Versioning.BinaryCompatibility::TargetsAtLeast_Desktop_V4_5_1()
-System.Int32 System.Runtime.Versioning.BinaryCompatibility::AppWasBuiltForVersion()
-System.Int32 System.Runtime.Versioning.BinaryCompatibility::get_AppWasBuiltForVersion()
-System.Int32 System.Runtime.Versioning.BinaryCompatibility::s_AppWasBuiltForVersion
-System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap
-System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap System.Runtime.Versioning.BinaryCompatibility::s_map
-System.Runtime.Versioning.TargetFrameworkId System.Runtime.Versioning.BinaryCompatibility::AppWasBuiltForFramework()
-System.Runtime.Versioning.TargetFrameworkId System.Runtime.Versioning.BinaryCompatibility::get_AppWasBuiltForFramework()
-System.Runtime.Versioning.TargetFrameworkId System.Runtime.Versioning.BinaryCompatibility::s_AppWasBuiltForFramework
-System.Void System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap::.ctor()
-System.Void System.Runtime.Versioning.BinaryCompatibility/BinaryCompatibilityMap::AddQuirksForFramework(System.Runtime.Versioning.TargetFrameworkId,System.Int32)
-System.Void System.Runtime.Versioning.BinaryCompatibility::.cctor()
-System.Void System.Runtime.Versioning.BinaryCompatibility::ParseFrameworkName(System.String,System.String&,System.Int32&,System.String&)
-System.Void System.Runtime.Versioning.BinaryCompatibility::ReadTargetFrameworkId()
-System.Runtime.Versioning.CompatibilitySwitch
-System.String System.Runtime.Versioning.CompatibilitySwitch::GetValueInternal(System.String)
 System.Runtime.Versioning.TargetFrameworkAttribute
 System.String System.Runtime.Versioning.TargetFrameworkAttribute::_frameworkDisplayName
 System.String System.Runtime.Versioning.TargetFrameworkAttribute::_frameworkName
 System.String System.Runtime.Versioning.TargetFrameworkAttribute::FrameworkDisplayName()
 System.Void System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(System.String)
 System.Void System.Runtime.Versioning.TargetFrameworkAttribute::set_FrameworkDisplayName(System.String)
-System.Int32 System.Runtime.Versioning.TargetFrameworkId::value__
-System.Runtime.Versioning.TargetFrameworkId
-System.Runtime.Versioning.TargetFrameworkId System.Runtime.Versioning.TargetFrameworkId::NetCore
-System.Runtime.Versioning.TargetFrameworkId System.Runtime.Versioning.TargetFrameworkId::NetFramework
-System.Runtime.Versioning.TargetFrameworkId System.Runtime.Versioning.TargetFrameworkId::NotYetChecked
-System.Runtime.Versioning.TargetFrameworkId System.Runtime.Versioning.TargetFrameworkId::Phone
-System.Runtime.Versioning.TargetFrameworkId System.Runtime.Versioning.TargetFrameworkId::Portable
-System.Runtime.Versioning.TargetFrameworkId System.Runtime.Versioning.TargetFrameworkId::Silverlight
-System.Runtime.Versioning.TargetFrameworkId System.Runtime.Versioning.TargetFrameworkId::Unrecognized
-System.Runtime.Versioning.TargetFrameworkId System.Runtime.Versioning.TargetFrameworkId::Unspecified
 System.IntPtr System.RuntimeArgumentHandle::args
 System.RuntimeArgumentHandle
 System.Boolean System.RuntimeFieldHandle::Equals(System.Object)
```

```
Statistics

Native subtotal           35,729,800   35,728,760       -1,040       0.00 %
    Executable            29,270,272   29,270,240          -32       0.00 %
    AOT data *.aotdata     6,459,528    6,458,520       -1,008      -0.02 %

Managed *.dll/exe          4,537,344    4,532,736       -4,608      -0.10 %

TOTAL                     40,581,685   40,576,037       -5,648      -0.01 %
```
2017-01-19 08:45:19 -05:00
Rolf Bjarne Kvinge d3d542aba6 [mtouch] Move the BuildTask classes into their own files. (#1521)
This is just a pure code move, no functional code changes.
2017-01-19 12:42:27 +01:00
Rolf Bjarne Kvinge 3b310b71eb [mtouch] Speed up marking types referenced in attributes. Fixes #49087. (#1531)
Switch to a new API introduced in Cecil added new API to get all the
attributes in an assembly, without having to traverse (and load) every type
and member.

This makes mtouch significantly faster when computing the list of referenced
assemblies, which is noticable when mtouch later determines nothing else needs
to be done (because nothing changed).

A few tests show that mtouch is now approximately twice as fast:

* A customer test project goes from 2s to 1s.
* A simple test app goes from 1.3s to 0.6.

https://bugzilla.xamarin.com/show_bug.cgi?id=49087
2017-01-19 10:24:00 +01:00
Rolf Bjarne Kvinge 2d104f32d9 [mtouch] Make sure native symbols from third-party libraries are preserved in dylibs. Fixes #51548.
The native linker treats object files (.o) and static libraries (.a files,
which are archives of .o files) differently.

The native linker will always include object files into the executable:

	$ echo "void xxx () {}" > foo.m
	$ clang -c foo.m -o foo.o -arch x86_64
	$ ld foo.o -dylib -o foo.dylib -macosx_version_min 10.12 -arch x86_64
	$ nm foo.dylib
	0000000000000fe0 T _xxx

However, if the object file is inside a static library:

	$ echo "void xxx () {}" > foo.m
	$ clang -c foo.m -o foo.o -arch x86_64
	$ ar cru foo.a foo.o
	$ ld foo.a -dylib -o foo.dylib -macosx_version_min 10.12 -arch x86_64
	$ nm foo.dylib
	<no output>

This means that our testing library (libtest.a) which is a fat library of
_object files_, do not show the problems reported in bug #51548.

So:

a) I've fixed the creation of libtest.a to be a fat library of _static
   libraries_. This causes the `FastDev_LinkWithTest` test to fail exactly
   like in bug #51548.

b) I've made mtouch pass `-u <native symbol>` to the native linker, for every
   native symbol referenced in a managed assembly, when creating a dylib.
   Amazingly this seems to work fine even with symbols to Objective-C classes
   (`_OBJC_CLASS_$_<class name>`).

c) This also required adding support for collecting the Objective-C names of
   all managed types registered with Objective-C to the linker. The
   information is already available in the static registrar, but that would
   require us to make sure the static registrar is executed before compiling
   dylibs, which means those two tasks won't be able to run in parallel (also
   there's no guarantee we'll even run the static registrar).

https://bugzilla.xamarin.com/show_bug.cgi?id=51548
2017-01-18 12:33:06 +01:00
Rolf Bjarne Kvinge dae1d79aed [mtouch] Quote symbols passed to the native linker.
Also quote any arguments with a '$' character.
2017-01-18 10:48:11 +01:00
Rolf Bjarne Kvinge a09c1e8cc5 [mtouch] Store a list of members for each native symbol.
There might be more than one member for each P/Invoke symbol, so make sure to
keep track of every one of them.
2017-01-18 10:48:11 +01:00
Rolf Bjarne Kvinge b4cc60572b [mtouch/mmp] Share code between link contexts. 2017-01-18 10:48:11 +01:00
Sebastien Pouliot 00b1c09acb [linker] Add an well known candidate inliner substep along with tests (#1513)
TL&DR: This is *how* it should be done and tested, it's not complete
(single, simple case) nor the most interesting case ;-)

The trick is to make sure each case is covered by tests so a mono
_bump_ won't give us a BCL that does not conform to what the linker
expect.

What's the impact ?

1. There is the expected reduction of metadata in mscorlib. Since both
   methods don't call other API there's no indirect effect (removal).

--- before	2017-01-15 11:12:44.000000000 -0500
+++ after	2017-01-15 11:12:56.000000000 -0500
@@ -13166,9 +13166,6 @@
 System.Void System.Security.SecurityException::.ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)
 System.Void System.Security.SecurityException::.ctor(System.String)
 System.Void System.Security.SecurityException::GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)
-System.Boolean System.Security.SecurityManager::CheckElevatedPermissions()
-System.Security.SecurityManager
-System.Void System.Security.SecurityManager::EnsureElevatedPermissions()
 System.Security.SecurityRulesAttribute
 System.Security.SecurityRuleSet System.Security.SecurityRulesAttribute::m_ruleSet
 System.Void System.Security.SecurityRulesAttribute::.ctor(System.Security.SecurityRuleSet)

2. There is no visible size change (even with #1) in mscorlib.dll due to
   padding (compiler /filealign)

   mscorlib.dll                793,600      793,600            0       0.00 %

3. there's a *very* small reduction of mscorlib.*.aotdata size

   mscorlib.armv7.aotdata      717,264      717,216          -48      -0.01 %
   mscorlib.arm64.aotdata      712,840      712,704         -136      -0.02 %

   AOT data *.aotdata        6,460,064    6,459,880         -184       0.00 %

4. there's no change in executable size - normal as the AOT compiler has
   _likely_ already doing the same optimization (before this commit)

   Executable               29,270,272   29,270,272            0       0.00 %

Full comparison: https://gist.github.com/spouliot/0464c8fa3a92b6486dfd90595d9eb718
2017-01-17 21:49:44 -05:00
Sebastien Pouliot 0a25188751 [mtouch] Remove RemoveSelector step for XI (#1512)
We're not storing selectors in fields anymore so this step does nothing
expect iterating over the code.

The step is still needed for `mmp` (for Xamarin.Mac.dll)
2017-01-16 14:00:55 -05:00
Rolf Bjarne Kvinge 4cbfc537f7 [mtouch] Add the mtouch test project to the Xamarin.iOS solution. (#1510)
Add the mtouch test project to the Xamarin.iOS solution, and also create a new
mtouch solution that only contains projects directly related to mtouch.
2017-01-16 18:46:15 +01:00
Rolf Bjarne Kvinge d6c2422fcf [mtouch] Simplify code a bit. (#1508)
Simplify code a bit to avoid constant null checking and also take advantage of
the fact that HashSet.Add returns if the value was added or not (to avoid a
Contains check).
2017-01-16 18:35:28 +01:00
Rolf Bjarne Kvinge 3a480b53bf Merge pull request #1506 from rolfbjarne/mtouch-single-invocation
[mtouch] Build extensions and the container app in the same mtouch process.
2017-01-16 18:33:42 +01:00
Sebastien Pouliot a563a66c34 [linker] Update BaseSubStep subclasses to use ExceptionalSubStep (#1507)
This allows mtouch to give better error message when something unexpected
occurs in the linker pipeline (at least for the sub-steps).

Practically it means fewer, contextless MT2001 errors. The replacements
error code are more precise, e.g.
* what was being done;
* what was being processed

and helps both diagnosing and, possibly, gives clues for workarounds
2017-01-16 11:42:41 -05:00
Rolf Bjarne Kvinge f19d2707e3 [mtouch] MT0066 is an error. (#1505) 2017-01-16 16:22:08 +01:00
Rolf Bjarne Kvinge 5aaea3ee49 [mtouch] Build extensions and the container app in the same mtouch process.
Build extensions and the container app in the same mtouch process, by storing
all the mtouch arguments when called to build extensions in a text file, and
then reloading those arguments when called to build the main app.

This is required if we want to share code between extensions and the
container.
2017-01-16 13:52:37 +01:00
Rolf Bjarne Kvinge 53fc697aad [mtouch] Refactor command-line parsing to be reusable.
Also add a few tests to verify how we treat the root assembly (or lack
thereof).
2017-01-16 13:52:37 +01:00
Rolf Bjarne Kvinge d2498370d9 [mtouch] Make the 'action' a local variable instead of a global one.
Make the 'action' a local variable instead of a global one so that argument
parsing can be done multiple times.
2017-01-16 12:45:03 +01:00
Rolf Bjarne Kvinge 052c2e9753 [mtouch] Refactor input validation a bit.
Move some input validation from the Main method to the App instance,
since it depends on the App instance.
2017-01-16 12:42:46 +01:00
Rolf Bjarne Kvinge 0a07b6ba8e Remove unnecessary bitcode from dylibs. Fixes #51352 (#1469)
This is a series of fixes to the dynamic libraries we build / create to remove
any unnecessary bloat (unused architectures, bitcode).

A brand new watchOS app with no changes goes from 35MB to 11MB with these
fixes (with incremental builds disabled, the app size is 10MB).

--------------------------------------------------------------------------------

* [runtime] Split list of architectures into simulator and device-specific lists.

* [runtime] Build separate dylibs for device and simulator.

Build separate dylibs for device and simulator, since we already install these
into different locations.

This makes both the simulator and device builds slightly faster (since the
respective dylibs are smaller, and less data to copy around).

For watchOS apps, this saves ~430kb.

* [runtime] Strip bitcode from dylibs. Fixes #51352.

We know that dylibs will never be shipped to the App Store, so we'll never
need them to have bitcode.

So just strip the bitcode from all our dylibs, since this makes apps with
fastdev significantly smaller (and thus much faster to upload to watch
devices).

For watchOS apps this is a very significant improvement: a branch new watchOS
app without any changes goes from 35MB to 17MB.

https://bugzilla.xamarin.com/show_bug.cgi?id=51352

* [mtouch] Fix dylib compilation to not embed full bitcode.

Facts
=====

a. The output from the AOT compiler is an assembly (.s) file.
b. Clang's assembler does not support -fembed-bitcode-marker (only -fembed-
   bitcode), so when we ask clang to -fembed-bitcode-marker, the assembler
   receives a -fembed-bitcode argument.
c. This means that the assembled object file does not contain the
   __LLVM/__bitcode and __LLVM/__cmdline sections (it does however contain an
   __LLVM/__asm section).
d. The native linker will create a bitcode assembly section if none of the
   object files passed to the linker contain a __LLVM/__bitcode section and
   there's an __LLVM/__asm section present.
e. The end result is that when we build to a dylib, we end up (unexpectedly,
   because we ask Clang to -fembed-bitcode-marker) including both armv7k and
   bitcode in the dylib, thus bloating the dylib size significantly.

Solution
========

We manually add the __LLVM/__bitcode and __LLVM/__cmdline sections to the .s
file Mono's AOT compiler generated. This way the .o file will have the magic
sections, and the linker will not include bitcode (only the bitcode marker) in
the final library.

An empty watchOS extension with incremental builds is now 6MB smaller (down
to 11MB from 17MB).
2017-01-16 12:32:06 +01:00
Rolf Bjarne Kvinge 6f84d37d56 [mmp] Make sure Cecil is next to mmp.exe, so we doesn't load the system one. 2017-01-12 17:38:10 +01:00
Marek Safar c210332a93 Cecil breaking change update 2017-01-12 10:26:24 -05:00
Sebastien Pouliot b1281b259f [cecil] Bump mono to get the latest Cecil's revision. Fixes #51336 (#1478)
This includes [1] which fix the parsing of broken .mdb as seen in [2]

Also fix mtouch's resolver and the static registrar to match some Cecil
API changes.

references:
[1] 045b0f9729
[2] https://bugzilla.xamarin.com/show_bug.cgi?id=51336
2017-01-12 08:47:06 -05:00
Chris Hamons ffe142d0b5 [XM] AOT support in Xamarin.Mac (#1340) 2017-01-11 14:10:39 -06:00
Rolf Bjarne Kvinge c2e2e3d824 [mtouch] Include extracted frameworks from binding assemblies when listing the frameworks an extension needs. Fixes #45800. (#1461)
Include extracted frameworks from binding assemblies when listing the
frameworks an extension needs.

Fixes #45800 - comments 8-13.

https://bugzilla.xamarin.com/show_bug.cgi?id=45800
2017-01-11 16:50:07 +01:00
Vincent Dondain ded6d2f129 [mtouch] Update MT0091 message (#1453)
Fixes bug #40835: Improve enable managed linker error message
(https://bugzilla.xamarin.com/show_bug.cgi?id=40835)
2017-01-09 16:34:58 +01:00
Rolf Bjarne Kvinge b3d2b50dca [mtouch] Auto-install locally after building in the IDE. (#1432)
Auto-install locally after building in the IDE, so that running mtouch tests
after running the mtouch project doesn't require switching to the command
line.
2017-01-03 16:34:33 -05:00
Sebastien Pouliot dea2dde259 [linker] Update mscorlib.xml to preserve generic collection interfaces. Fixes #50290 (#1384) (#1427)
The `generic_icollection_class` condition (in class.c) does not match the mscorlib.xml descriptor file.

+ IEnumerator`1
+ IReadOnlyList`1
+ IReadOnlyCollection`1

reference:
https://bugzilla.xamarin.com/show_bug.cgi?id=50290
2017-01-03 13:03:29 -05:00
Rolf Bjarne Kvinge d7ecfc3a14 [mtouch/mmp] Make Cache a non-static class. (#1425)
So that there can be multiple caches in the same process (which we'll have
once mtouch can compile extensions and the container app in the same process).
2017-01-03 15:14:47 +01:00
Rolf Bjarne Kvinge 3d4ad53253 [mtouch] Fix infinite recursion after d1102c80. (#1420)
Fixes this test failure:

    Xamarin.Registrar.MT4161 : Unexpected error/warning with --registrar:static:
	    error MT0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com
2017-01-02 11:05:01 +01:00
Rolf Bjarne Kvinge ab21da1b85 [xharness] Add support for uninstalling apps from device. (#1413)
The new error message / number is used in mlaunch.
2017-01-02 08:58:46 +01:00
Chris Hamons cdf3915704 Fix EveryFrameworkSmokeTests test with MediaPlayerLibrary (#1418) 2016-12-28 08:46:46 -06:00
Rolf Bjarne Kvinge ab2548a115 [mtouch] Automatically create the output directory if it doesn't exist. (#1414) 2016-12-24 10:57:08 -05:00
Sebastien Pouliot a562ac513a [apidiff] Update XML references to match C8SR2 (10.3.1) (#1411) 2016-12-23 13:13:24 -05:00
Rolf Bjarne Kvinge d1102c800e [mtouch] Remove most static state and put it on an instance. (#1398)
* [mtouch] Remove most static state and put it on an instance.

Remove most static state, and put it on an instance (of Application) instead.

Soon we'll build multiple apps (app extensions) in the same process, and we
need to make sure we're not inadvertedly (and incorrectly) sharing state
between apps, so remove as much static state as possible to avoid any
problems.

* [mtouch] Rename GetIsUsingClang -> IsUsingClang.
2016-12-23 18:50:35 +01:00
Rolf Bjarne Kvinge 3ec3f39089 [mtouch] Always require a SDK version when building. (#1407)
* [mtouch] Always require a SDK version when building.

Technically it was required before too, but the error messages were non-optimal:
it could for instance complain that the user is using an iOS framework that
was introduced in iOS 2.0.

* [mtouch tests] Rewrite MT0060 and MT0061 tests to use MTouchTool.

This makes sure we pass --sdk to mtouch (which MTouchTool does by default), so
that we don't run into MT0025 before the errors we're testing for.
2016-12-23 17:09:39 +01:00
Rolf Bjarne Kvinge ee5b450174 [mtouch] Remove deprecated comment. (#1402) 2016-12-23 07:35:36 +01:00
Rolf Bjarne Kvinge 3f9599d3f4 [mtouch/mmp] Add better help for the --marshal-[managed|objectivec]-exceptions arguments. (#1403) 2016-12-22 20:11:50 +01:00
Rolf Bjarne Kvinge db4c28df61 [mtouch] Remove Classic-only file. (#1400) 2016-12-22 18:53:22 +01:00
Rolf Bjarne Kvinge 7dad48a59c [mtouch] Remove dead code. (#1397)
The (ugly) manual exit logic was only needed when interacting with the
simulator, which mtouch doesn't do anymore.
2016-12-22 17:39:10 +01:00
Rolf Bjarne Kvinge ffe3184345 [generator] Use --target-framework to specify which XM profile to target. (#1339) 2016-12-20 11:33:56 +01:00
Chris Hamons 378827c6ee Remove unnecessary allocations of Version in Static Registrar (#1371) 2016-12-16 15:59:12 -06:00
Chris Hamons 10bb6b1f1b [XM] Fix isysroot with new fixed SDKVersion 2016-12-13 15:12:50 -06:00
Chris Hamons 5a6c205739 Fix d02c112176 to work when no sdk passed in 2016-12-13 13:47:24 -06:00
Chris Hamons d02c112176 [XM] Fix static registrar to handle frameworks added in point releases
- Move hack from StaticRegistrar to mmp driver so we set SDKVersion correctly for point releases
- Clean up a bit of duplicate while we are there
2016-12-13 12:20:47 -06:00
Chris Hamons 5cb1b1eee8 [XM] Fix static registrar with Xcode 8.2
- Another brick in the wall of GetSDKVersion hacks
2016-12-13 08:44:54 -06:00
Sebastien Pouliot b5632f9c2f merge xcode8.2 into master 2016-12-12 21:26:23 -05:00
Rolf Bjarne Kvinge 318a7dfbe1 TargetFramework: add support for profile. (#1337)
Add support for specifying the profile with the target framework,
and support using "Version=" before the version:

    Xamarin.Mac,Version=v2.0,Profile=Mobile.
2016-12-12 17:01:10 +01:00