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

75 Коммитов

Автор SHA1 Сообщение Дата
Timothy Risi 25468bf617 Merge Quote methods into a single class instead of multiple versions (#2153) 2017-06-06 12:32:25 -08:00
Marius Ungureanu 51cda3b468 [Mac,iOS] Generate create_classes as C methods so they can be used from objc. (#2158)
This change introduces the export of create_classes methods as objc compatible, without enforcing Objective-C++ as the development language for custom registrar embedders by moving the stringbuilder flushing inside the extern "C" block.
Mark the generated linking code as extern "C" too and also change the return type of xamarin_create_classes_Xamarin_Mac to void in mmp generation, as it was mistakenly set to int.
2017-06-02 09:19:04 +02:00
Rolf Bjarne Kvinge 0dd385d81f [mtouch] Link with AVFoundation in watchOS apps when needed. Fixes #56862. (#2143)
The AVFoundation framework's headers used to be broken in the simulator SDK
([1], [2]) until watchOS 3.2 (Xcode 8.3) fixed it. This means it's now safe to
use AVFoundation.

Additionally set the initial SDK version where this framework was introduced
to 3.2 for simulator builds, which means that if customers try to use it (with
an old Xcode), they will get a nice-ish error:

> MTOUCH : error MT4134: Your application is using the 'AVFoundation' framework, which isn't included in the watchOS SDK you're using to build your app (this framework was introduced in watchOS 3.2, while you're building with the watchOS 3.1 SDK.) Please select a newer SDK in your app's watchOS Build options.

instead of an ugly:

> MTOUCH : error MT4109: Failed to compile the generated registrar code. Please file a bug report at http://bugzilla.xamarin.com

the error message is slightly incorrect (the problem is only with the
simulator SDK, not the device SDK), but this should happen very rarely (it
only occurs if all of the following are true: using AVFoundation + in a
simulator build * the static registrar manually selected), so IMHO a more
accurate error description isn't worth it.

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

[1] 7149661251
[2] https://openradar.appspot.com/29131674
2017-05-31 13:10:51 +02:00
Rolf Bjarne Kvinge a32714eb43 [mtouch/mmp] Print assembly references in verbose mode. (#2139)
* [mtouch/mmp] Print assembly references in verbose mode.

Sample output:

    Loaded assembly 'unifiedtestapp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' from /Users/rolf/Projects/TestApp/bin/iPhoneSimulator/Debug/unifiedtestapp.exe
        References: mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
        References: Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
    Loaded assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' from /work/maccore/master/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/lib/mono/Xamarin.iOS/mscorlib.dll
    Loaded assembly 'Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' from /work/maccore/master/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/lib/mono/Xamarin.iOS/../../64bits/Xamarin.iOS.dll
        References: mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
        References: System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
        References: System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
        References: Mono.Security, Version=2.0.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756
        References: System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
    Loaded assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' from /work/maccore/master/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/lib/mono/Xamarin.iOS/System.dll
        References: mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
        References: Mono.Security, Version=2.0.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756
        References: System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
    Loaded assembly 'Mono.Security, Version=2.0.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' from /work/maccore/master/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/lib/mono/Xamarin.iOS/Mono.Security.dll
        References: mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
        References: System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
    Loaded assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' from /work/maccore/master/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/lib/mono/Xamarin.iOS/System.Xml.dll
        References: mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
        References: System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
    Loaded assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' from /work/maccore/master/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/lib/mono/Xamarin.iOS/System.Core.dll
        References: mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
        References: System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e

I believe this will make it easier to diagnose cases where something references a desktop assembly.

* [mtouch/mmp] Share more code between mmp and mtouch.
2017-05-29 16:15:22 +02:00
Rolf Bjarne Kvinge 363eb083ef [docs] Document mmp errors and remove duplicated information about mtouch errors. (#2056) 2017-05-01 14:02:54 -04:00
Rolf Bjarne Kvinge f445856652 Merge pull request #2039 from rolfbjarne/e4k-static-registrar
Add support for the embeddinator in the static registrar.
2017-04-27 06:54:34 +02:00
Rolf Bjarne Kvinge 294668fa54 [mtouch] Fix compiling assemblies to frameworks on watchOS. (#2038)
* [runtime] Fix Xamarin-debug.framework's install name.

This makes building to frameworks work in debug mode.

* [mtouch] Fix check to add frameworks to watchKit extensions.

* [mtouch] Never pass -read_only_relocs to the native linker when bitcode is enabled.

* [mtouch] Bitcode requires linking with c++.

This particular case applies to shared libraries/frameworks (we already link
with c++ when building statically).
2017-04-25 17:39:58 +02:00
Rolf Bjarne Kvinge 9cd3ab1206 [mtouch/mmp] Move --embeddinator to shared code so mmp gets it as well. 2017-04-25 16:06:41 +02:00
Rolf Bjarne Kvinge 532fd7d2ee [mtouch] Fix launch mode. 2017-04-19 19:12:17 +02: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 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 80536f9bd7 [mtouch] Simlauncher won't work for the embeddinator. 2017-04-18 11:36:29 +02:00
Rolf Bjarne Kvinge d1ebaa94db [mtouch] Add an embeddinator mode. 2017-04-18 11:36:27 +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
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
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 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
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
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
Marek Safar 258cbdda4b Adds pdb handling to mtouch 2017-03-14 11:51:08 +01:00
Marek Safar c51ba190f6 [mtouch] Copy pdb debug symbols when available 2017-03-14 11:47:06 +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 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 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 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 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 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 a590612751 [mtouch] Add an --assembly-build-target option. 2017-02-10 14:29:11 +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
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 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
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
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 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
Chris Hamons ffe142d0b5 [XM] AOT support in Xamarin.Mac (#1340) 2017-01-11 14:10:39 -06: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 ab2548a115 [mtouch] Automatically create the output directory if it doesn't exist. (#1414) 2016-12-24 10:57:08 -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