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

157 Коммитов

Автор SHA1 Сообщение Дата
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 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
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 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
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
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 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 fd8c09ecb8 [mtouch] Remove the Application.FastDev property, it's never set anymore. 2017-02-10 16:39:32 +01:00
Rolf Bjarne Kvinge b1199d2b5a [mtouch] Remove dead code. 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 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 f399d464da [mtouch] Add support for creating a dot file of the build tree. 2017-02-10 14:46:30 +01:00
Rolf Bjarne Kvinge 96637b5e13 [mtouch] Remove dead code. 2017-02-10 14:46:29 +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 6e2648e125 [mtouch] Make sure CompilerFlags always have a Target. 2017-02-10 14:46:27 +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 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 fea1fc6447 [mtouch] Teach about source files to CompilerFlags. 2017-02-10 14:46:25 +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 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 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 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 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 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
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
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 a42419ab2d [mtouch] Remove dead code. (#1549) 2017-01-24 13:43:01 +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 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
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 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