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

74 Коммитов

Автор SHA1 Сообщение Дата
Vincent Dondain 24cd73a5ca Bump to Xcode 9 (#2176)
- Update Versions-ios and Versions-mac file too.
- Bump maccore and maciostools to the xcode9 branch.
- [builds] Force disable 'futimens' and 'utimensat' so that we build with Xcode 9.
- [builds] 'system' is not available on iOS (simulator).
- [runtime] Fix: cannot initialize a variable of type 'char *' with an rvalue of type 'const char *'
    - Prevented building xcode9 branch, see: https://jenkins.mono-project.com/job/xamarin-macios-pr-builder/3886/console
  ```
  runtime.m:1122:9: error: cannot initialize a variable of type 'char *' with an rvalue of type 'const char *'
                              char *last_sep = strrchr (info.dli_fname, '/');
  ```

- [registrar] Apple removed a header, so don't include it anymore.
- [mtouch] Don't run the partial static registrar for tvOS.
  The generated output doesn't compile because Apple forgot to ship headers for
the ExternalAccessory framework in their tvOS simulator SDK.
2017-06-06 16:21:26 -04: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 05895c41f5 [registrar] Add support for specifying that a protocol changed informal status in a certain SDK. Fixes #43780 and #48311. (#2130)
* [registrar] Add support for specifying that a protocol changed informal status in a certain SDK. Fixes #43780

Add support for specifying that an informal protocol became a formal protocol
(or the reverse) in a certain SDK version, so that the static registrar can
generate the correct code based on the SDK being built with.

This also fixes a series of compiler warnings when using the static registrar:

    In file included from Xamarin.Mac.registrar.full.i386.m:1:
    ./Xamarin.Mac.registrar.full.i386.h:374:11: warning: duplicate protocol definition of 'CALayerDelegate' is ignored
    @protocol CALayerDelegate
              ^
    /Applications/Xcode83.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CALayer.h:798:11: note: previous definition is here
    @protocol CALayerDelegate <NSObject>
              ^
    In file included from Xamarin.Mac.registrar.full.i386.m:1:
    ./Xamarin.Mac.registrar.full.i386.h:824:11: warning: duplicate protocol definition of 'WebDownloadDelegate' is ignored
    @protocol WebDownloadDelegate
              ^
    /Applications/Xcode83.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/WebKit.framework/Headers/WebDownload.h:60:11: note: previous definition is here
    @protocol WebDownloadDelegate <NSURLDownloadDelegate>
              ^
    In file included from Xamarin.Mac.registrar.full.i386.m:1:
    ./Xamarin.Mac.registrar.full.i386.h:851:11: warning: duplicate protocol definition of 'WebFrameLoadDelegate' is ignored
    @protocol WebFrameLoadDelegate
              ^
    /Applications/Xcode83.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/WebKit.framework/Headers/WebFrameLoadDelegate.h:51:11: note: previous definition is here
    @protocol WebFrameLoadDelegate <NSObject>
              ^
    In file included from Xamarin.Mac.registrar.full.i386.m:1:
    ./Xamarin.Mac.registrar.full.i386.h:866:11: warning: duplicate protocol definition of 'WebPolicyDelegate' is ignored
    @protocol WebPolicyDelegate
              ^
    /Applications/Xcode83.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/WebKit.framework/Headers/WebPolicyDelegate.h:138:11: note: previous definition is here
    @protocol WebPolicyDelegate <NSObject>
              ^
    In file included from Xamarin.Mac.registrar.full.i386.m:1:
    ./Xamarin.Mac.registrar.full.i386.h:869:11: warning: duplicate protocol definition of 'WebResourceLoadDelegate' is ignored
    @protocol WebResourceLoadDelegate
              ^
    /Applications/Xcode83.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/WebKit.framework/Headers/WebResourceLoadDelegate.h:46:11: note: previous definition is here
    @protocol WebResourceLoadDelegate <NSObject>
              ^
    In file included from Xamarin.Mac.registrar.full.i386.m:1:
    ./Xamarin.Mac.registrar.full.i386.h:872:11: warning: duplicate protocol definition of 'WebUIDelegate' is ignored
    @protocol WebUIDelegate
              ^
    /Applications/Xcode83.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/WebKit.framework/Headers/WebUIDelegate.h:153:11: note: previous definition is here
    @protocol WebUIDelegate <NSObject>
              ^

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

* [registrar] Use a string to specify when a protocol went from informal to formal.

Use a string to specify when a protocol went from informal to formal, and
don't support the reverse condition (going from formal to informal), since
it's currently not needed and makes the code more complicated and harder to
understand.

Also add an mtouch test, and update an existing mmp test to be more restrictive.

* [registrar] Rename from 'InformalUntil' to 'FormalSince'.

It just sounds better.
2017-05-29 16:15:54 +02:00
Rolf Bjarne Kvinge 63cc4fe142 [registrar] Define a magic symbol to avoid a compiler warning. (#2128)
This avoids the following compiler warning:

    /Applications/Xcode83.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:5:2: warning: gl.h and gl3.h are both included. Compiler will not invoke errors if using removed OpenGL functionality. [-W#warnings]

I found the magic symbol by looking at the headers.
2017-05-25 07:11:19 +02:00
Rolf Bjarne Kvinge 9466ae5080 [registrar] Support 'out' parameters from NULL pointers. Fixes #54919. (#2106)
[registrar] Support 'out' parameters from NULL pointers. Fixes #54919.

Native code doesn't have the 'out' and 'ref' distinction C# has, and passes
NULL around left and right.

So make sure the generated code from the static registrar doesn't write to such NULLs.

https://bugzilla.xamarin.com/show_bug.cgi?id=54919
2017-05-19 12:07:12 +02:00
Rolf Bjarne Kvinge d2574bfc01 [static registrar] Define DEBUG in both header and source.
This way we don't have to make sure to include generated header before any
other header that requires DEBUG to be set (like xamarin.h).
2017-04-26 16:48:09 +02:00
Rolf Bjarne Kvinge 34edff8bef [static registrar] Initialize the embeddinator in every function entry. 2017-04-25 16:06:41 +02:00
Rolf Bjarne Kvinge ea12420fbd [static registrar] Put the generated @interface declaration for public types in the header. 2017-04-25 16:06:41 +02:00
Rolf Bjarne Kvinge ab4765f89c [static registrar] Add support for putting private properties in the implementation section.
This makes registrar.h compilable as Objective-C (as opposed to
Objective-C++), because the __monoObjectGCHandle field (whose type is an C++
type) isn't there anymore.
2017-04-25 16:06:41 +02:00
Rolf Bjarne Kvinge 413b65a5fa [static registrar] Refactor code a little bit to avoid excessive indentation. 2017-04-25 16:06:41 +02:00
Sebastien Pouliot 0dfcb1f09f Merge branch 'master' into mono-2017-02 2017-03-28 21:31:33 -05:00
Vincent Dondain c0abf32083 Fix more merge issues 2017-03-28 15:10:38 -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
Marek Safar 105ee26509 Merge remote-tracking branch 'origin/master' into mono-2017-02 2017-03-23 23:13:43 +01: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
Marek Safar 01f0e67978 Update after another Cecil breaking change 2017-03-14 11:47:06 +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 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 a42419ab2d [mtouch] Remove dead code. (#1549) 2017-01-24 13:43:01 +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
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
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 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
Chris Hamons 378827c6ee Remove unnecessary allocations of Version in Static Registrar (#1371) 2016-12-16 15:59:12 -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
Chris Hamons c67bd9096c [XM] Add partial static registrar support (#1191) 2016-12-01 10:18:30 -06:00
Chris Hamons cc9a99f996 [XM] 10.12.1 APIs are in Xcode 8.1 not 8.2 2016-11-11 14:02:55 -06:00
Chris Hamons 6422000c27 [XM] Fix static registrar under Xcode 8.2 with another hack (#1164)
- Generalized the hack a bit. If we continue to need them
we can make it more data driven
2016-11-11 13:19:26 -06:00
Rolf Bjarne Kvinge 7728c4cd19 [registrar] Use metadata tokens instead of strings to find types and methods. (#1085)
Use metadata tokens instead of strings to find types and methods.

This makes the code to find methods more compact (a lot less strings in the
executable, and additionally in most cases a compact representation (32-bit
integer) of the corresponding metadata token and additional information can be
used, which results in less executable code (fewer parameters to methods,
etc)), resulting in smaller executables.

Size savings are around 200kb for dont link apps, and 20-60kb for linked apps
(this obviously varies a lot depending on how much has to registered by the
registrar).

|                |    Before     |     After     |       Diff        |
|----------------|--------------:|--------------:|------------------:|
| dontlink/32bit |  102.810.144  |  102.609.456  | -200.688 = -0,20% |
| dontlink/64bit |  107.420.576  |  107.221.792  | -198.784 = -0,19% |
| linksdk/32bit  |   40.957.296  |   40.936.864  |  -20.432 = -0,05% |
| linksdk/64bit  |   43.113.136  |   43.093.936  |  -19.200 = -0,04% |
| linkall/32bit  |   38.410.032  |   38.348.288  |  -61.744 = -0,16% |
| linkall/64bit  |   40.315.200  |   40.267.344  |  -47.856 = -0,12% |

Additionally I've removed the `lazy_map` dictionary, which we populated at
startup and was used to map between Class instances and the corresponding
managed type's FullName, and instead iterate over a native array of Class ->
metadata token mappings whenever we need to look up the managed type for a
certain Class instance.

This is slightly slower for each type we need to look up (for a non-linked app
there might be a 2000-3000 entries in the native array, which would be
iterated instead of using a hashtable lookup), but it's only done once per
type and there's a significant startup memory improvement.

For a non-linked test app I get the following using the Xamarin profiler:

|                   |  Before |  After  |       Diff      |
|-------------------|--------:|--------:|----------------:|
| Memory allocated  |  2,8 MB |  2,4 MB | -0,4 MB = -14 % |
| Objects allocated |   43678 |   38463 |   -5215 = -12 % |
| Private bytes     | 26,6 MB | 24,4 MB | -2,2 MB = -8,3% |
| Working set       | 26,6 MB | 24,4 MB | -2,2 MB = -8,3% |
2016-11-01 14:34:56 -04:00
Sebastien Pouliot f015a954ec [mtouch] Add missing HasParameters check inside linker and static registrar (#1010)
* [mtouch] Add missing HasParameters check inside linker and static registrar

Without the checks new, empty collections can be allocated and their
whole and only purpose will be to iterate up to 0 (nop).

The checks saves a small amount of memory (collections) and time.

* [registrar] Fix method comparison when they have no parameters
2016-10-31 22:31:07 -04:00
Rolf Bjarne Kvinge 0c43ddc615 Disable managed exception marshaling when the debugger is attached. Fixes #45116. (#1055)
Managed exception marshaling interferes with the debugger, because it adds
exception handlers to executing code, which makes the Mono runtime think an
exception is handled when logically it's not (although technically it is).

The consequence is that the IDEs will only be notified when we re-throw the
exception after catching it, making it impossible for the IDEs to stop when
the exception is thrown (they will instead stop when we re-throw the
exception).

So disable managed exception marshaling (unless the user changed the default
behavior) when a debugger is attached.

This is the same behavior as Xamarin.Android.

https://bugzilla.xamarin.com/show_bug.cgi?id=45116
2016-10-28 19:07:01 +02:00
Rolf Bjarne Kvinge 4371ea4540 [static registrar] Fix registration of generic types. Fixes #44926. (#1063)
https://bugzilla.xamarin.com/show_bug.cgi?id=44926
2016-10-28 18:42:45 +02:00
Rolf Bjarne Kvinge 6104a514fc [registrar] Cache the System.Void type. (#1024)
Duration before: 1,60s
Duration after:  1,54s
Difference:     -0,06s = -3,8%

Memory usage hardly changed (-21 kb of 540 MB), but the number of method calls
shrunk significantly.

Method calls before: 86.720.379
Method calls after:  74.390.061
Difference:         -12.330.318 = -14,2%

The call to `GetSystemVoidType` was #2 on the list of method calls (whens
sorted by 'self'), called 1072 times taking 1429 ms each time. After this
change it's only called once (and obviously pushed way down the list).
2016-10-28 09:52:58 -04:00
Rolf Bjarne Kvinge a1644f6e13 [registrar] Improve an error message. (#1047) 2016-10-28 08:38:38 -04:00
Rolf Bjarne Kvinge 23a0186a99 [registrar] Fix compiler warning. (#1054) 2016-10-28 08:33:18 -04:00
Rolf Bjarne Kvinge 89eb5dd430 [registrar] Mark our generated code as 'extern C'. (#1049)
This makes the function names smaller, saving a tiny bit of space (about 700
bytes for the dont link test app).

It also looks nicer in crash reports.
2016-10-27 16:12:16 -04:00
Rolf Bjarne Kvinge c533db66bf [mtouch] Always use ordinal string comparisons. (#995) 2016-10-14 12:34:35 +02:00
Rolf Bjarne Kvinge 0863e412b4 Remove XI/Classic support (#926)
* [tests] Remove Classic SDK tests.

* Remove XI/Classic support.

This also means we can remove support for the legacy registrars.

* [monotouch-test] Remove legacy registrar tests.

* [tests/mtouch] Remove Classic tests (and legacy registrar logic).

* [tests/scripted] Fix tests to reference Xamarin.iOS.dll.
2016-09-30 15:02:17 -04:00
Sebastien Pouliot 38148c718a Merge branch 'xcode8' 2016-09-09 15:29:37 -04:00
Rolf Bjarne Kvinge 2eb6ba12c7 [mtouch/mmp] Fix build after breaking cecil update in mono.
Also use mono's cecil instead of our own cecil submodule for mtouch.
2016-09-01 18:28:35 +02:00
Rolf Bjarne Kvinge e291f1717d Revert "Bump [watch-]mono to master to get fix for #43658." (#665) 2016-08-25 14:44:53 +02:00
Rolf Bjarne Kvinge f6b1ccd748 Bump [watch-]mono to master to get fix for #43658. (#653)
* Bump [watch-]mono to master to get fix for #43658.

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

* [mtouch/mmp] Fix build after breaking cecil update in mono.

Also use mono's cecil instead of our own cecil submodule for mtouch.

* Bump [watch-]mono to get compilation fixes after cecil bump in mono.

* Remove cecil submodule, we only use the one in mono now.
2016-08-25 13:10:14 +02:00
Sebastien Pouliot 7619702459 [registrar] Remove tvOS/simulator hack for ExternalAccessory (#619)
Apple now ships the required ExternalAccessory header files

references:
* commit 1190aac04c
  Author: Sebastien Pouliot <sebastien.pouliot@gmail.com>
  Date:   Sun Jul 24 10:44:19 2016 -0400
* rdar#27476259 https://trello.com/c/Okdw58IO
2016-08-16 20:49:22 -04:00
Sebastien Pouliot ff77f85a4c Merge branch 'cycle8' into xcode8 2016-08-08 15:29:36 -04:00
Rolf Bjarne Kvinge 44b30892e9 [registrar] Skip any assemblies with the DelayedRegistrationAttribute in the static registrar. (#557) 2016-08-05 18:43:22 +02:00
Chris Hamons 6f4be16d3a [XM] Fix static registrar.
Rip out all 64-bit registration in 32-bit XM.
2016-08-04 11:54:59 +02:00
Chris Hamons a3b31d154b [XM] Fix static registrar on 10.12 by teaching it that QTKit is dead (#472) 2016-08-04 11:54:59 +02:00
Rolf Bjarne Kvinge c66a44bc12 Teach the static registrar about the lack of ExternalAccessory headers in the tvOS simulator.
This is only applicable to tvOS 10 (i.e. the xcode8 branch),
but applying the patch already helps avoiding merge failures
for other fixes in the same area.
2016-08-04 11:54:58 +02:00
Chris Hamons 798aca0767 [XM] Fix static registrar.
Rip out all 64-bit registration in 32-bit XM.
2016-08-02 17:44:10 +02:00