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

301 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 5fc4fc66af
[registrar] Don't throw NRE when finding methods that almost implement optional protocol members. (#3658)
If a class implements a protocol with optional members, and that class also exports methods whose selectors match an optional member, but the signature doesn't match, we must show a useful warning instead of erroring out due to a NullReferenceException.

Fixes this:

    System.NullReferenceException: Object reference not set to an instance of an object
      at Registrar.StaticRegistrar.GetBlockProxyAttributeMethod (Mono.Cecil.MethodDefinition method, System.Int32 parameter) [0x00001] in /Users/builder/data/lanes/1381/9de35b83/source/xamarin-macios/tools/common/StaticRegistrar.cs:4113
      at Registrar.StaticRegistrar.GetBlockWrapperCreator (Registrar.Registrar+ObjCMethod obj_method, System.Int32 parameter) [0x001e1] in /Users/builder/data/lanes/1381/9de35b83/source/xamarin-macios/tools/common/StaticRegistrar.cs:4101
      at Registrar.StaticRegistrar.Specialize (Registrar.AutoIndentStringBuilder sb, Registrar.Registrar+ObjCMethod method, System.Collections.Generic.List`1[T] exceptions) [0x0216b] in /Users/builder/data/lanes/1381/9de35b83/source/xamarin-macios/tools/common/StaticRegistrar.cs:3683

when building the msbuild/tests/MyWatchKit2IntentsExtension project.
2018-03-05 15:26:16 +01:00
Rolf Bjarne Kvinge 664c790b8c
[mtouch] Propagate the computed value for removal of the dynamic registrar to code shared app extensions. (#3622) (#3630)
This fixes a startup crash in code shared app extensions due to having the
wrong value set in the runtime (the dynamic registrar was removed, but the
executable didn't know it).
2018-03-05 07:41:56 +01:00
Rolf Bjarne Kvinge 835f65897f
[static registrar] Optimize creation of delegates for blocks. (#3623) (#3644)
* [static registrar] Optimize creation of delegates for blocks.

Optimize creation of delegates for blocks so that it doesn't require the
dynamic registrar.

This is done by getting the metadata token for the Create method that creates
the delegate, and embed that metadata token in the generated code from the
static registrar.

Also add tests, since this scenario was not covered by tests already.

* [mmptest] Fix test after recent changes.

* [test-libraries] Avoid duplicate symbols.

* [tests] Update according to changes.
2018-03-05 07:41:28 +01:00
Chris Hamons cabc4fbe2c [mmp] Add stripping of 32-bit dylibs to work with new App Store restrictions (#3387) (#3633)
- https://github.com/xamarin/xamarin-macios/issues/3367
- App Store will now fail builds if you add in a 32-bit dylib
- If you are a 32-bit app you don't need the 64-bit part of your fat
dylib anyway
- Add --optimize=-trim-architectures to allow customization of behavior, as not everyone
uses app store

In addition, while writing tests for this is was noticed that mmp tests did not "really" run Release configuration correctly in most cases. Fixing this turned out to be a bit of a pain, but necessary to correctly test this (and other things).

- Turns out that /p:configuration:debug is not sufficient to tell mmp to
do the right thing
- That, in most projects, sets the DebugSymbols property, which really
is what is checked.
- However, two of our projects did not have that, so we always did
release mmp work.
- Removed configuration property for tests and added real "Release"
configuration option
2018-03-02 14:33:27 +01:00
Rolf Bjarne Kvinge b131a54be5
[static registrar] Optimize creation of delegates for blocks. (#3623)
* [static registrar] Optimize creation of delegates for blocks.

Optimize creation of delegates for blocks so that it doesn't require the
dynamic registrar.

This is done by getting the metadata token for the Create method that creates
the delegate, and embed that metadata token in the generated code from the
static registrar.

Also add tests, since this scenario was not covered by tests already.

* [mmptest] Fix test after recent changes.

* [test-libraries] Avoid duplicate symbols.

* [tests] Update according to changes.
2018-03-02 14:30:18 +01:00
Rolf Bjarne Kvinge a106cd7520
[mtouch] Bundle duplicated assemblies in the container app. Fixes #58873. (#3626)
Assemblies that satisfy all of these conditions:

* Are not in the container project.
* Are in multiple app extensions.

can (and should) be bundled in the container app.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=58873
2018-03-02 09:39:42 +01:00
Chris Hamons ca4360116c
[mmp] Add stripping of 32-bit dylibs to work with new App Store restrictions (#3387)
- https://github.com/xamarin/xamarin-macios/issues/3367
- App Store will now fail builds if you add in a 32-bit dylib
- If you are a 32-bit app you don't need the 64-bit part of your fat
dylib anyway
- Add --optimize=-trim-architectures to allow customization of behavior, as not everyone
uses app store

In addition, while writing tests for this is was noticed that mmp tests did not "really" run Release configuration correctly in most cases. Fixing this turned out to be a bit of a pain, but necessary to correctly test this (and other things).

- Turns out that /p:configuration:debug is not sufficient to tell mmp to
do the right thing
- That, in most projects, sets the DebugSymbols property, which really
is what is checked.
- However, two of our projects did not have that, so we always did
release mmp work.
- Removed configuration property for tests and added real "Release"
configuration option
2018-03-01 09:36:06 -06:00
Rolf Bjarne Kvinge de15337f61
[mtouch] Propagate the computed value for removal of the dynamic registrar to code shared app extensions. (#3622)
This fixes a startup crash in code shared app extensions due to having the
wrong value set in the runtime (the dynamic registrar was removed, but the
executable didn't know it).
2018-03-01 14:59:54 +01:00
Rolf Bjarne Kvinge 72bc672d6b
[mtouch] Find the link context for code shared app extensions in the static registrar. Fixes #3514. (#3545) (#3557)
When code sharing is enabled, only the container app/target will have a
LinkContext.

So make sure the static registrar finds that link context when it needs
information from the linker.

https://github.com/xamarin/xamarin-macios/issues/3514
2018-02-21 15:10:20 +01:00
Rolf Bjarne Kvinge c0c0e63a3b
[mtouch] Find the link context for code shared app extensions in the static registrar. Fixes #3514. (#3545)
When code sharing is enabled, only the container app/target will have a
LinkContext.

So make sure the static registrar finds that link context when it needs
information from the linker.

https://github.com/xamarin/xamarin-macios/issues/3514
2018-02-21 09:27:26 +01:00
Rolf Bjarne Kvinge 83509221e1
[tests] Update tests according to temporary directory name change. (#3548) 2018-02-20 17:59:14 +01:00
Rolf Bjarne Kvinge 2a29d0e0aa
[mtouch/mmp] Fix tracking of whether the static registrar should run again or not. Fixes #641. (#3534) (#3536)
* [tests] Improve debug spew for the RebuildTest_WithExtensions test.

* [mtouch/mmp] Store/load if the dynamic registrar is removed or not into the cached link results.

Store/load if the dynamic registrar is removed or not into the cached link
results, so that we generate the correct main.m even if cached linker results
are used.

* [mtouch/mmp] The static registrar must not execute if we're loading cached results from the linker.

The static registrar must not execute if we're loading cached results from the
linker, because the static registrar needs information from the linker that's
not restored from the cache.

* [mtouch/mmp] Share Touch code.

* [mtouch/mmp] Make it possible to touch inexistent files (to create them).

* [mtouch/mmp] Fix tracking of whether the static registrar should run again or not.

The recent changes to support optimizing away the dynamic registrar caused the
Xamarin.MTouch.RebuildTest_WithExtensions test to regress.

The problem
-----------

* The linker now collects and stores information the static registrar needs.
* This information is not restored from disk when the linker realizes that it
  can reload previously linked assemblies instead of executing again.
* The static registrar runs again (for another reason).
* The information the static registrar needs isn't available, and incorrect
  output follows.

So fix 1: show an error if the static registrar runs when the linker loaded
cached results.

The exact scenario the test ran into is this:

* 1st build: everything is new and everything is built.
* 2nd build: contents of .exe changes, the linker runs again, the static
  registrar runs again, but sees that the generated output didn't change, so
  it doesn't write the new content to disk (this is an optimization to avoid
  compiling the registrar.m file again unless needed).
* 3rd build: only the .exe timestamp changes, the linker sees nothing changes
  in the contents of the .exe and loads the previously linked assemblies from
  disk, the static registrar sees that the .exe's timestamp is newer than
  registrar.m's timestamp and run again, but doesn't produce the right result
  because it doesn't have the information it needs.

Considered solutions
--------------------

1. Only track timestamps, not file contents. This is not ideal, since it will
   result in more work done: in particular for the case above, it would add a
   registrar.m compilation in build #2, and linker rerun + static registrar
   rerun + registrar.m compilation + final native link in build #3.
2. Always write the output of the static registrar, even if it hasn't changed.
   This is not ideal either, since it will also result in more work done: for
   the case above, it would add a registrar.m compilation + final native link
   in build #3.
3. Always write the output of the static registrar, but track if it changed or
   not, and if it didn't, just touch registrar.o instead of recompiling it.
   This only means the final native link in build #3 is added (see #5 for why
   this is worse than it sounds).
4. Always write the output of the static registrar, but track it it changed or
   not, and if it didn't, just touch registrar.o instead of recompiling it,
   and track that too, so that the final native link in build #3 isn't needed
   anymore. Unfortunately this may result in incorrect behavior, because now
   the msbuild tasks will detect that the executable has changed, and may run
   dsymutil + strip again. The executable didn't actually change, which means
   it would be the previously stripped executable, and thus we'd end up with
   an empty .dSYM because we ran dsymtil on an already stripped executable.
5. Idea #4, but write the output of the final link into a temporary directory
   instead of the .app, so that we could track whether we should update the
   executable in the .app or not. This is not optimal either, because
   executables can be *big* (I've seen multi-GB tvOS bitcode executables), and
   extra copies of such files should not be taken lightly.
6. Idea #4, but tell the MSBuild tasks that dsymutil/strip doesn't need to be
   rerun even if the timestamp of the executable changed. This might actually
   work, but now the solution's become quite complex.

Implemented solution
--------------------

Use stamp files to detect whether a file is up-to-date or not.

In particular:

* When we don't write to a file because the new contents are identical to the
  old contents, we now touch a .stamp file. This stamp file means "the
  accompanying file was determined to be up-to-date when the stamp was
  touched."
* When checking whether a file is up-to-date, also check for the presence of a
  .stamp file, and if it exists, use the highest timestamp between the stamp
  file and the actual file.

Now the test scenario becomes:

* 1st build: everything is new and everything is built.
* 2nd build: contents of .exe changes, the linker runs again, the static
  registrar runs again, but sees that the generated output didn't change, so
  it doesn't write the new content to disk, but it creates a registrar.m.stamp
  file to indicate the point in time when registrar.m was considered up-to-
  date.
* 3rd build: only the .exe timestamp changes, the linker sees nothing changes
  in the contents of the .exe and loads the previously linked assemblies from
  disk, the static registrar sees that the .exe's timestamp is *older* than
  registrar.m.stamp's timestamp and doesn't run again.

We only use the stamp file for source code (registrar.[m|h], main.[m|h],
pinvokes.[m|h]), since using it every time has too much potential for running
into other problems (for instance we should never create .stamp files inside
the .app).

Fixes these test failures:

    1) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("single","",False,System.String[])
      single
      Expected: <empty>
      But was:  < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory371/testApp.app/testApp is modified, timestamp: 2/15/2018 3:04:11 PM > 2/15/2018 3:04:09 PM" >

    2) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("dual","armv7,arm64",False,System.String[])
      dual
      Expected: <empty>
      But was:  < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory375/testApp.app/testApp is modified, timestamp: 2/15/2018 3:06:03 PM > 2/15/2018 3:06:00 PM" >

    3) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("llvm","armv7+llvm",False,System.String[])
      llvm
      Expected: <empty>
      But was:  < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory379/testApp.app/testApp is modified, timestamp: 2/15/2018 3:07:14 PM > 2/15/2018 3:07:12 PM" >

    4) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("debug","",True,System.String[])
      debug
      Expected: <empty>
      But was:  < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory383/testApp.app/testApp is modified, timestamp: 2/15/2018 3:08:16 PM > 2/15/2018 3:08:13 PM" >

    5) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("single-framework","",False,System.String[])
      single-framework
      Expected: <empty>
      But was:  < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory387/testApp.app/testApp is modified, timestamp: 2/15/2018 3:09:18 PM > 2/15/2018 3:09:16 PM" >

Fixes https://github.com/xamarin/maccore/issues/641
2018-02-20 11:43:23 +01:00
Rolf Bjarne Kvinge 5788a9fa9b
[mtouch] Rename temporary directories so the order assemblies move is clearer. (#3531)
* [mtouch] Rename temporary directories so the order assemblies move is clearer.

I implemented this myself, but I can never remember in which order assemblies
go from one directory to another during the build.

So number these temporary directories, so that even the most forgetful minds
can understand without having to remember anything.

* [tests] Update test according to temporary directory name change.
2018-02-19 21:50:20 +01:00
Rolf Bjarne Kvinge 3113c5d2b5
[mtouch/mmp] Fix tracking of whether the static registrar should run again or not. Fixes #641. (#3534)
* [tests] Improve debug spew for the RebuildTest_WithExtensions test.

* [mtouch/mmp] Store/load if the dynamic registrar is removed or not into the cached link results.

Store/load if the dynamic registrar is removed or not into the cached link
results, so that we generate the correct main.m even if cached linker results
are used.

* [mtouch/mmp] The static registrar must not execute if we're loading cached results from the linker.

The static registrar must not execute if we're loading cached results from the
linker, because the static registrar needs information from the linker that's
not restored from the cache.

* [mtouch/mmp] Share Touch code.

* [mtouch/mmp] Make it possible to touch inexistent files (to create them).

* [mtouch/mmp] Fix tracking of whether the static registrar should run again or not.

The recent changes to support optimizing away the dynamic registrar caused the
Xamarin.MTouch.RebuildTest_WithExtensions test to regress.

The problem
-----------

* The linker now collects and stores information the static registrar needs.
* This information is not restored from disk when the linker realizes that it
  can reload previously linked assemblies instead of executing again.
* The static registrar runs again (for another reason).
* The information the static registrar needs isn't available, and incorrect
  output follows.

So fix 1: show an error if the static registrar runs when the linker loaded
cached results.

The exact scenario the test ran into is this:

* 1st build: everything is new and everything is built.
* 2nd build: contents of .exe changes, the linker runs again, the static
  registrar runs again, but sees that the generated output didn't change, so
  it doesn't write the new content to disk (this is an optimization to avoid
  compiling the registrar.m file again unless needed).
* 3rd build: only the .exe timestamp changes, the linker sees nothing changes
  in the contents of the .exe and loads the previously linked assemblies from
  disk, the static registrar sees that the .exe's timestamp is newer than
  registrar.m's timestamp and run again, but doesn't produce the right result
  because it doesn't have the information it needs.

Considered solutions
--------------------

1. Only track timestamps, not file contents. This is not ideal, since it will
   result in more work done: in particular for the case above, it would add a
   registrar.m compilation in build #2, and linker rerun + static registrar
   rerun + registrar.m compilation + final native link in build #3.
2. Always write the output of the static registrar, even if it hasn't changed.
   This is not ideal either, since it will also result in more work done: for
   the case above, it would add a registrar.m compilation + final native link
   in build #3.
3. Always write the output of the static registrar, but track if it changed or
   not, and if it didn't, just touch registrar.o instead of recompiling it.
   This only means the final native link in build #3 is added (see #5 for why
   this is worse than it sounds).
4. Always write the output of the static registrar, but track it it changed or
   not, and if it didn't, just touch registrar.o instead of recompiling it,
   and track that too, so that the final native link in build #3 isn't needed
   anymore. Unfortunately this may result in incorrect behavior, because now
   the msbuild tasks will detect that the executable has changed, and may run
   dsymutil + strip again. The executable didn't actually change, which means
   it would be the previously stripped executable, and thus we'd end up with
   an empty .dSYM because we ran dsymtil on an already stripped executable.
5. Idea #4, but write the output of the final link into a temporary directory
   instead of the .app, so that we could track whether we should update the
   executable in the .app or not. This is not optimal either, because
   executables can be *big* (I've seen multi-GB tvOS bitcode executables), and
   extra copies of such files should not be taken lightly.
6. Idea #4, but tell the MSBuild tasks that dsymutil/strip doesn't need to be
   rerun even if the timestamp of the executable changed. This might actually
   work, but now the solution's become quite complex.

Implemented solution
--------------------

Use stamp files to detect whether a file is up-to-date or not.

In particular:

* When we don't write to a file because the new contents are identical to the
  old contents, we now touch a .stamp file. This stamp file means "the
  accompanying file was determined to be up-to-date when the stamp was
  touched."
* When checking whether a file is up-to-date, also check for the presence of a
  .stamp file, and if it exists, use the highest timestamp between the stamp
  file and the actual file.

Now the test scenario becomes:

* 1st build: everything is new and everything is built.
* 2nd build: contents of .exe changes, the linker runs again, the static
  registrar runs again, but sees that the generated output didn't change, so
  it doesn't write the new content to disk, but it creates a registrar.m.stamp
  file to indicate the point in time when registrar.m was considered up-to-
  date.
* 3rd build: only the .exe timestamp changes, the linker sees nothing changes
  in the contents of the .exe and loads the previously linked assemblies from
  disk, the static registrar sees that the .exe's timestamp is *older* than
  registrar.m.stamp's timestamp and doesn't run again.

We only use the stamp file for source code (registrar.[m|h], main.[m|h],
pinvokes.[m|h]), since using it every time has too much potential for running
into other problems (for instance we should never create .stamp files inside
the .app).

Fixes these test failures:

    1) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("single","",False,System.String[])
      single
      Expected: <empty>
      But was:  < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory371/testApp.app/testApp is modified, timestamp: 2/15/2018 3:04:11 PM > 2/15/2018 3:04:09 PM" >

    2) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("dual","armv7,arm64",False,System.String[])
      dual
      Expected: <empty>
      But was:  < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory375/testApp.app/testApp is modified, timestamp: 2/15/2018 3:06:03 PM > 2/15/2018 3:06:00 PM" >

    3) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("llvm","armv7+llvm",False,System.String[])
      llvm
      Expected: <empty>
      But was:  < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory379/testApp.app/testApp is modified, timestamp: 2/15/2018 3:07:14 PM > 2/15/2018 3:07:12 PM" >

    4) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("debug","",True,System.String[])
      debug
      Expected: <empty>
      But was:  < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory383/testApp.app/testApp is modified, timestamp: 2/15/2018 3:08:16 PM > 2/15/2018 3:08:13 PM" >

    5) Failed : Xamarin.MTouch.RebuildTest_WithExtensions("single-framework","",False,System.String[])
      single-framework
      Expected: <empty>
      But was:  < "/Users/builder/data/lanes/5746/4123bf7e/source/xamarin-macios/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.Tests.BundlerTool.CreateTemporaryDirectory387/testApp.app/testApp is modified, timestamp: 2/15/2018 3:09:18 PM > 2/15/2018 3:09:16 PM" >

Fixes https://github.com/xamarin/maccore/issues/641
2018-02-19 20:28:04 +01:00
Rolf Bjarne Kvinge a2b49f4bb5 [tests] Fix expected warning message for optimize warning test. 2018-02-15 17:45:02 +01:00
Rolf Bjarne Kvinge ed886f6181 [tests] Refactor several tests to use new-style syntax.
Failure are reported much better, and the testing is more accurate and extensive.
2018-02-14 01:13:17 +01:00
Rolf Bjarne Kvinge 564e433bbd [tests] Adjust tests after new optimization was implemented. 2018-02-14 01:12:26 +01:00
Rolf Bjarne Kvinge ea3316465b [tests] Add a test to make sure the protocol attributes are properly removed. 2018-02-13 19:38:34 +01:00
Rolf Bjarne Kvinge 1c77da63cf [tests][mtouch] Update a few tests according to recent changes. 2018-02-13 19:38:34 +01:00
Rolf Bjarne Kvinge 97230c28e1
Optimize calls to BlockLiteral.SetupBlock to inject the block signature. (#3391)
* [linker] Optimize calls to BlockLiteral.SetupBlock to inject the block signature.

Optimize calls to BlockLiteral.SetupBlock[Unsafe] to calculate the block
signature at build time, and inject it into the call site.

This makes block invocations 10-15x faster (I've added tests that asserts at
least an 8x increase).

It's also required in order to be able to remove the dynamic registrar code in
the future (since calculating the block signature at runtime requires the
dynamic registrar).

* [mtouch/mmp] Add support for reporting errors/warnings that point to the code line causing the error/warning.

Add support for reporting errors/warnings that point to the code line causing
the error/warning by adding ErrorHelper overloads that take the exact
instruction to report (previously we defaulted to the first line/instruction
in a method).

* [tests] Add support for asserting filename/linenumber in warning messages.

* Make all methods that manually create BlockLiterals optimizable.

* [tests] Create a BaseOptimizeGeneratedCodeTest test that's included in both XI's and XM's link all test.

* [tests] Add link all test (for both XI and XM) to test the BlockLiteral.SetupBlock optimization.

* [tests] Add mtouch/mmp tests for the BlockLiteral.SetupBlock optimization.

* [tests][linker] Make the base test class abstract, so tests in the base class aren't executed twice.

* [tests][linker] Don't execute linkall-only tests in linksdk.

The optimization tests only apply when the test assembly is linked, and that
only happens in linkall, so exclude those tests in linksdk.

* [tests][mmptest] Update test according to mmp changes.

Fixes these test failures:

    1) Failed : Xamarin.MMP.Tests.MMPTests.MM0132("inline-runtime-arch")
    The warning 'MM0132: Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' was not found in the output:
    	Message #1 did not match:
    		actual:   'Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock.'
    		expected: 'Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.'
    	Message #2 did not match:
    		actual:   'Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock.'
    		expected: 'Unknown optimization: 'inline-runtime-arch'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.'

    2) Failed : Xamarin.MMP.Tests.MMPTests.MM0132("foo")
    The warning 'MM0132: Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.' was not found in the output:
    	Message #1 did not match:
    		actual:   'Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock.'
    		expected: 'Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.'
    	Message #2 did not match:
    		actual:   'Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size, blockliteral-setupblock.'
    		expected: 'Unknown optimization: 'foo'. Valid optimizations are: remove-uithread-checks, dead-code-elimination, inline-isdirectbinding, inline-intptr-size.'

* [tests][linker] Fix typo.

Fixes this test failure:

    1) SetupBlock_CustomDelegate (Linker.Shared.BaseOptimizeGeneratedCodeTest.SetupBlock_CustomDelegate)
         Counter
      Expected: 1
      But was:  2

* [registrar] Minor adjustment to error message to match previous (and better) behavior.

Fixes this test failure:

    1) Failed : Xamarin.Registrar.GenericType_WithInvalidParameterTypes
    The error 'MT4136: The registrar cannot marshal the parameter type 'System.Collections.Generic.List`1<U>' of the parameter 'arg' in the method 'Open`1.Bar(System.Collections.Generic.List`1<U>)'' was not found in the output:
    	Message #1 did not match:
    		actual:   'The registrar cannot marshal the parameter type 'System.Collections.Generic.List`1<Foundation.NSObject>' of the parameter 'arg' in the method 'Open`1.Bar(System.Collections.Generic.List`1<U>)''
    		expected: 'The registrar cannot marshal the parameter type 'System.Collections.Generic.List`1<U>' of the parameter 'arg' in the method 'Open`1.Bar(System.Collections.Generic.List`1<U>)''

* [docs] mmp shows MM errors/warnings.

* [docs] Improve according to reviews.

* [tests] Fix merge failure causing test duplication.
2018-02-06 07:08:15 +01:00
Rolf Bjarne Kvinge 6b5870d668
[tests] Move linker tests to match introspection directory layout. (#3365)
* [tests] Move linker tests to match introspection directory layout.

Move linker tests to match introspectio directory layout: tests/linker/ios and
tests/linker/mac instead of tests/linker-ios and tests/linker-mac.

This creates a logical place for shared linker files (tests/linker).

* [tests] Fix path to GuiUnit_NET_4_5.csproj in sln as well.

This is the path used to find referenced projects when building Classic.

Fixes this build problem:

    warning: Referenced project 'GuiUnit_NET_4_5' not found in the solution.
    /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/common/mac/MacTestMain.cs(11,7) : error CS0246: The type or namespace name `GuiUnit' could not be found. Are you missing an assembly reference?
    /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/common/mac/MacTestMain.cs(64,42) : error CS0246: The type or namespace name `IMainLoopIntegration' could not be found. Are you missing an assembly reference?
    /Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/common/mac/MacTestMain.cs(75,34) : error CS0246: The type or namespace name `InvokerHelper' could not be found. Are you missing an assembly reference?
2018-02-05 15:09:04 +01:00
Rolf Bjarne Kvinge f905427739
[tests] Share supporting code between the mtouch and mmp tests. (#3374)
* [tests] Share supporting code between the mtouch and mmp tests.

Create a new class 'BundlerTool', which now contains most of the code in
MTouchTool that's also applicable to mmp (and the new MmpTool class).

This will make it easier to share tests between the mtouch and mmp tests.

Some tweaks are still probably required, but this should get us most of the
way.

* [tests] Fix generator tests after changes in shared test code.

* [tests] Add new file to the MSBuild/XM tests.
2018-02-02 07:09:04 +01:00
Rolf Bjarne Kvinge 03d78d13f3
[tests][mtouch] Simplify code to fetch symbols from a binary (nm). (#3286)
Simplify/refactor code to fetch symbols from a binary to reuse an existing
function instead of manually calling `nm` every time.
2018-01-24 00:31:32 +01:00
Rolf Bjarne Kvinge af03020eef
[mtouch/mmp] Give users more control over optimizations, and share more code between mtouch and mmp. (#3242)
* [mtouch/mmp] Give users more control over optimizations, and share more code between mtouch and mmp.

1. Add an --optimize flag to mtouch/mmp that allows users to select which
   optimizations to apply (or not). This makes it easier to add future
   optimizations, and allow users to disable any optimization that causes
   problems without having to disable many other features.

2. Share as much optimization code as possible between mtouch and mmp. This
   immediately gives a benefit to mmp, which has three new optimizations only
   mtouch had: NSObject.IsDirectBinding inlining, IntPtr.Size inlining and
   dead code elimination.

   This results in ~6kb of disk space saved for a linked Xamarin.Mac app:

   * link sdk: [Debug][1], [Release][2]
   * link all: [Debug][3], [Release][4]

Testing also verifies that monotouchtest ([Debug][5], [Release][6]) has not
changed size at all, which means that no default optimizations have changed
inadvertedly.

[1]: https://gist.github.com/rolfbjarne/6b731e3b5ca6170355662e6505c3d492#link-sdk-mac--debug
[2]: https://gist.github.com/rolfbjarne/6b731e3b5ca6170355662e6505c3d492#link-sdk-mac--release
[3]: https://gist.github.com/rolfbjarne/6b731e3b5ca6170355662e6505c3d492#link-all-mac--debug
[4]: https://gist.github.com/rolfbjarne/6b731e3b5ca6170355662e6505c3d492#link-all-mac--release
[5]: https://gist.github.com/rolfbjarne/6b731e3b5ca6170355662e6505c3d492#monotouchtest-iphonedebug64
[6]: https://gist.github.com/rolfbjarne/6b731e3b5ca6170355662e6505c3d492#monotouchtest-iphonerelease64

* [tools] Don't enable the IsDirectBinding optimization by default for Xamarin.Mac apps, it's not safe.

* Fix whitespace issues.

* [doc] Document optimizations.

* Officially support optimizations by adding them to the Versions.plist.

* [linker] Improve IntPtr.Size inliner + dead code eliminatior and add tests.

* Properly handle operands for the ldc_i4_s instruction (they're sbyte).
* Fix less-than condition to actually do a less-than comparison.
* Make sure to look up the bitness in the Target, not the Application, since
  the Application's value will be incorrect when building fat apps (both
  Is32Build and Is64Build will be true).
* Remove unnecessary checks for the IntPtr.Size inliner: this optimization
  does not depend on other instructions than the IntPtr.get_Size call, so
  remove the checks that verify surrounding instructions. This makes the
  IntPtr.Size inliner kick in in more scenarios (such as the new tests).
* Add tests.

* [tests] Add mmp tests for optimizations.

* [tests] Fix XM optimization tests.

* [tests] Fix test build error.
2018-01-23 11:33:48 +01:00
Rolf Bjarne Kvinge dadf5ca6e6
[mtouch] Make sure the xamarin_localized_string_format* functions are available in simlauncher. Fixes #3265. (#3269)
* [mtouch] Make sure the xamarin_localized_string_format* functions are available in simlauncher. Fixes #3265.

Fixes https://github.com/xamarin/xamarin-macios/issues/3265.

* [mtouch] Add test for simlauncher symbols, add add more missing symbols.
2018-01-22 14:21:24 +01:00
Sebastien Pouliot 3a851e2a63
[mtouch][mmp] Report invalid debug symbols files. Fixes #3200 (#3203)
* [mtouch][mmp] Report invalid debug symbols files. Fixes #3200

Try to read the assembly with symbols and, if that fails, warn and
fallback to loading them without symbols.

This fixes cases were it's not easy to update or delete (e.g. nuget)
bad symbols files - so this cannot be an error without causing a lot
of pain.

However it needs to be reported, otherwise it wont be fixed (by the
publisher) and it can limit the debugability of the application and
the usefulness of the stacktraces.

Finally merge most of the resolver's code between mtouch and mmp so
we don't have to fix such issue twice anymore.

note: this needs to be slightly updated once we get a version of cecil
that can give us a more precise error message.

Also bring Rolf's tests from
https://github.com/xamarin/xamarin-macios/pull/3079

reference:
https://github.com/xamarin/xamarin-macios/issues/3200
2018-01-12 17:39:38 -05:00
Sebastien Pouliot 4509e66168
[mtouch] Fix Xamarin.Sdk not to link with private frameworks. Fixes #61039 (#3118)
We can't trust Apple's native linker to pick the right (non private)
framework when an older TargetVersion is used. It just prefer what's
available - even if specified with a WeakFramework :(

That was already dealt with for applications. However the native linking
of the Xamarin.Sdk.framework (code sharing with extensions) is done with
the `LinkTask` instead of the `NativeLinkTask` so it did not have the
"auto correct" code.

Unit test added.

reference:
https://bugzilla.xamarin.com/show_bug.cgi?id=61039
2017-12-22 10:28:29 -05:00
Sebastien Pouliot 03f9c4b9ca
[mtouch][mmp] Allow the use of major-only version numbers in arguments. Fixes #60280 (#3029)
The parsing done by `System.Version` does not accept a major-only string,
e.g. providing "11" would throw an exception.

Since people generally refer version as iOS 11 (and not iOS 11.0) this
is, at best, a nuisance. Xcode toolchain accept "11" as a valid string.

The first part of message was updated to show both the option name and
the (user provided) value.

The 2nd part remain the text of the .net exception message, i.e. what
`Version.Parse` tells you when it validates the string. Seeing the input
value should make it more obvious for other, incorrect version strings.

reference:
https://bugzilla.xamarin.com/show_bug.cgi?id=60280
2017-11-23 11:16:30 -05:00
Manuel de la Pena 1a7712f595
[MTouch] If we are building a shared code extension, do not build the msym dir. #60415 (#3016)
* [MTouch] If we are building a shared code extension, do not build the msym dir.
2017-11-17 18:24:09 +01:00
Chris Hamons d2d2fcb352
[macos] Error when linking mix-mode assemblies (#2911)
- https://bugzilla.xamarin.com/show_bug.cgi?id=58583
2017-11-16 09:18:18 -06:00
Rolf Bjarne Kvinge e8d16c925b
[mtouch/mmp/bgen] Add support for response files. (#2808)
* [mtouch/mmp/bgen] Add support for response files.

This is the first part of the fix for #56501.

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

* [tests] Make sure no single argument starting with a '@' is passed to mtouch unless it's a response file.

--assembly-build-target takes arguments starting with '@', for instance:

    --assembly-build-target @all=framework

which does not work anymore, because that's interpreted as a response file
(mtouch tries to read the file '@all=framework', which obviously doesn't
exist).

The fix is simple, don't put a space between the two arguments:

    --assembly-build-target=@all=framework

* Add --root-assembly to mtouch/mmp and make the MSBuild tasks use this new option.

This makes it possible to pass root assemblies starting with `@` to mtouch/mmp
without getting mistaken for response files.

* [msbuild] Always use the command-line option that takes an equals or colon.

Always use the command-line option that takes an equals or colon instead of a
space.

Do either of these:

    --foo=something
    --foo:something

instead of this:

    --foo something

so that `something` can start with an at (`@`) sign without being mistaken for
a response file.

* [msbuild] Fix tests according to recent task changes.
2017-11-16 16:02:34 +01:00
Bernhard Urban 20182800a1
[runtime] integrate mono 2017-10 (#2905)
* Update the function name used to initialize libmono-profiler-log, its called mono_profiler_init_log () now.

* [builds] Pass --with-cross-offsets= to crosstv's configure.

* Bump mono to 2017-08.

* Bump mono to 2017-08.

* Force disable 'futimens' and 'utimensat' so that we build with Xcode 9.

This is also needed to build with Xcode 8.3 on High Sierra.

* Remove old AppleTls implementation.

* Bump mono.

* Bump mono to 2017-08.

* Bump mono to 2017-08

* Reenable link-keep-resources-2 test

- This reverts commit 76b759ef22.
- 2017-08 has linker fix

* Bump mono to 2017-10

* Revert "Bump mono to 2017-10"

This reverts commit bb7832724e.

* Bump system mono to 2017-10

* Bump embedded mono to 2017-10

* [runtime] reflect eglib move

9be68f8952

* bump mono

* [btouch] remove Security.Tls usage from test

* [mtouch tests] update the function name used to initialize libmono-profiler-log, its called mono_profiler_init_log () now.

see
ea4e4a9ef6

fixes:

```
1) Failed : Xamarin.MTouch.Profiling(tvOS)
  _mono_profiler_startup_log
  Expected: collection containing "_mono_profiler_startup_log"
  But was:  < "_mono_profiler_init_log" >
at Xamarin.MTouch.Profiling (Xamarin.Profile profile) [0x00106] in <511889694a624cc9a50e0e9b259b05c5>:0

2) Failed : Xamarin.MTouch.Profiling(watchOS)
  _mono_profiler_startup_log
  Expected: collection containing "_mono_profiler_startup_log"
  But was:  < "_xamarin_get_block_descriptor", "_mono_profiler_init_log" >
at Xamarin.MTouch.Profiling (Xamarin.Profile profile) [0x00106] in <511889694a624cc9a50e0e9b259b05c5>:0
```

* [mmptest] update log profiler options.

826558a4af
deprecated the dash prefix for the mlpd path.

`noallocs` or `nocalls` are not needed, neither of them are default anymore.

* [mmptest] fix link-keep-resources-2 test to cope with more corlib resources.

another corlib resource (mscorlib.xml) was added:

https://github.com/mono/mono/commit/11e95169e787#diff-2d1c64decd91d9a6e8842ab0f0e9438d

* Revert "[mmptest] fix link-keep-resources-2 test to cope with more corlib resources."

This reverts commit 350eb3c174.

* [XHarness] Add the Mono.Data.Tds tests.

* Address comments from rolf in the review.

* [mmp regresssion tests] bump mono linker, so mscorlib.xml gets stripped

the test was failing in that way:

> Executing link-keep-resources-2...
> [FAIL]	i18n 4/2 data files present: charinfo.nlp, collation.core.bin, collation.tailoring.bin, mscorlib.xml

also update the output, because it's actually expected at least three
elements.

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

* bump mono

fixes crash in tvOS: https://github.com/mono/mono/pull/5812

* bump mono for updated BCL tests

see https://github.com/mono/mono/pull/5820

* [mono] set 2017-10 branch in .gitmodules

* [macos] Fix guiunit error on clean builds by depending on correct copy (#2912)

* [macos] Fix guiunit error on clean builds by depending on correct copy

- From a clean build making a BCL test would error due to the non-mobile guiunit not being built
- This was because the Makefile-mac.inc target was incorrect
- This was because xharness assumed that non variation based targets were always Modern
- However, BCL tests are Full, not Modern

* Code review change

* Swap to var to reduce diff

* Revert changes in the paths for GuiUnit.

* [XHarness] Add the System.IO.Compression bcl tests. (#2918)

* [XHarness] Add the System.IO.Compression bcl tests.

*  [XHarness] Add bcl tests for System.IO.Compression.FileSystem. (#2924)

* [XHarness] Add the System.IO.Compression bcl tests.

* Ensure that resources are correctly copied in the bundles.

* [XHarness] Add bcl tests for System.IO.Compression.FileSystem.

* As per review, make the Mac test app name match the tests that are ran.

* [XHarness] Add Mono.CSharp tests on ios. (#2927)

* [XHarness] Add Mono.CSharp tests on ios.

* Bump mono to bring changes in the mono.csharp tests.

* [xtro-sharpie] fix TypeDefinition access due to Cecil change

* Bump mono

* bump mono

fixes
- https://bugzilla.xamarin.com/show_bug.cgi?id=60480
- https://bugzilla.xamarin.com/show_bug.cgi?id=60482

* bump mono

more fixes around conflicting paths when tests are run in parallel.

* Bump for mono/mono@2017-10
2017-11-14 21:30:08 +01:00
Rolf Bjarne Kvinge 6dc755c342
Include the mono version in Versions.plist. (#3003) 2017-11-14 19:40:11 +01:00
Rolf Bjarne Kvinge 407a19b59b
[tests][mtouch] Add test case for bug #59617. (#2926)
* [tests][mtouch] Convert MT4162 to new syntax.

This also means adding support for custom usings in test code, and adding
support for asserting filename/linenumber with error patterns, and custom
pattern syntax.

* [tests][mtouch] Add test case for bug #59617.

This amounts to running the MT4162 test with the linker enabled.

https://bugzilla.xamarin.com/show_bug.cgi?id=59617
2017-10-27 19:14:58 +02:00
Rolf Bjarne Kvinge 996d90614b [linker] Handle ParameterInfos preserved from XML definitions. Fixes #60176. (#2915)
Don't assume that a marked method has a caller, since a method can be marked
from XML as well.

This fixes a NullReferenceException:

> error : Could not link assemblies.
>  	Type: `System.Reflection.RuntimeParameterInfo`
>  	Assembly: `mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e`
>  Reason: Object reference not set to an instance of an object
>  --- inner exception
>  System.NullReferenceException: Object reference not set to an instance of an object (Aufgaben-ID: 165)
>    at MonoTouch.Tuner.MonoTouchMarkStep.MarkMethod (Mono.Cecil.MethodReference reference) [0x0004f] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs:105
>    at Mono.Linker.Steps.MarkStep.MarkMethodCollection (System.Collections.IEnumerable methods) [0x00017] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:1163
>    at Mono.Linker.Steps.MarkStep.MarkMethods (Mono.Cecil.TypeDefinition type) [0x0000b] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:1157
>    at Xamarin.Linker.Steps.MobileMarkStep.MarkMethods (Mono.Cecil.TypeDefinition type) [0x0000b] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MobileMarkStep.cs:123
>    at Mono.Linker.Steps.MarkStep.ApplyPreserveInfo (Mono.Cecil.TypeDefinition type) [0x0004a] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:1102
>    at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x001ee] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:607
>    at Xamarin.Linker.Steps.MobileMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00001] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MobileMarkStep.cs:71
>    at Xamarin.Linker.Steps.CoreMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00046] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/CoreMarkStep.cs:156
>    at MonoTouch.Tuner.MonoTouchMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00001] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs:84
>    at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x0007d] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:566
>    at Xamarin.Linker.Steps.MobileMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00001] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MobileMarkStep.cs:71
>    at Xamarin.Linker.Steps.CoreMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00046] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/CoreMarkStep.cs:156
>    at MonoTouch.Tuner.MonoTouchMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00001] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs:84
>    at Mono.Linker.Steps.MarkStep.InitializeType (Mono.Cecil.TypeDefinition type) [0x0005b] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:94
>    at Mono.Linker.Steps.MarkStep.InitializeAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x00025] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:81
>    at Mono.Linker.Steps.MarkStep.Initialize () [0x00016] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:73
>    at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x00008] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:66
>    at Xamarin.Linker.Steps.MobileMarkStep.Process (Mono.Linker.LinkContext context) [0x00001] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MobileMarkStep.cs:33
>    at Xamarin.Linker.Steps.CoreMarkStep.Process (Mono.Linker.LinkContext context) [0x00017] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/CoreMarkStep.cs:26
>    at MonoTouch.Tuner.MonoTouchMarkStep.Process (Mono.Linker.LinkContext context) [0x0001d] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs:36
>    at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00023] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker/Pipeline.cs:128
>    at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[Mono.Cecil.AssemblyDefinition]& assemblies) [0x000e0] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/mtouch/Tuning.cs:82

https://bugzilla.xamarin.com/show_bug.cgi?id=60176
2017-10-24 10:57:17 +02:00
Rolf Bjarne Kvinge 05484c915f [registrar] Don't verify the SDK for protocol members, and fix the SDK check for other cases. Fixes #59617. (#2790)
* [registrar] Remove useless interface.

* [registrar] Don't store LinkContext in the static registrar when in can be fetched from the Target. Partially fixes #59617.

This avoids a problem where our code would store null because LinkContext
wasn't created yet when the static registrar instance was created.

This fixes the missing error from bug #59617.

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

* [registrar] Don't verify the SDK for protocol members. Partially fixes #59617.

It's not needed, because protocol members don't end up in the registrar output
anyway (and would thus not prevent the registrar code from compiling).

Classes that implement any protocol members would still run into the SDK
check, so this should not prevent real problematic code from being reported
either.

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

* [tests][mtouch] Fix tests after registrar changes.
2017-09-28 17:35:21 +02:00
Rolf Bjarne Kvinge eeb6256834 [mtouch] Show MT0123 if the executable assembly does not reference the product assembly. Fixes #59798. (#2801)
It does not make sense to create Xamarin.iOS projects that don't reference
Xamarin.iOS.dll, so make this an explicit error.

This fixes a NullReferenceException which could (when building for device, or
when not using simlauncher) occur, and instead shows the MT0123 error.

> MTOUCH : error MT0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com
> System.NullReferenceException: Object reference not set to an instance of an object
>   at Xamarin.Bundler.Target.GatherFrameworks () [0x00065] in /Users/builder/data/lanes/5024/152b654a/source/xamarin-macios/tools/common/Target.cs:122
>   at Xamarin.Bundler.Target.ProcessAssemblies () [0x000c2] in /Users/builder/data/lanes/5024/152b654a/source/xamarin-macios/tools/mtouch/Target.cs:802
>   at Xamarin.Bundler.Application.ProcessAssemblies () [0x0002f] in /Users/builder/data/lanes/5024/152b654a/source/xamarin-macios/tools/mtouch/Application.cs:1407
>   at Xamarin.Bundler.Application.BuildManaged () [0x00001] in /Users/builder/data/lanes/5024/152b654a/source/xamarin-macios/tools/mtouch/Application.cs:831
>   at Xamarin.Bundler.Application+<>c.<BuildAll>b__134_1 (Xamarin.Bundler.Application v) [0x00000] in /Users/builder/data/lanes/5024/152b654a/source/xamarin-macios/tools/mtouch/Application.cs:779
>   at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00024] in <48b95f3df5804531818f80e28ec60191>:0
>   at Xamarin.Bundler.Application.BuildAll () [0x00050] in /Users/builder/data/lanes/5024/152b654a/source/xamarin-macios/tools/mtouch/Application.cs:779
>   at Xamarin.Bundler.Driver.Main2 (System.String[] args) [0x00481] in /Users/builder/data/lanes/5024/152b654a/source/xamarin-macios/tools/mtouch/mtouch.cs:1420
>   at Xamarin.Bundler.Driver.Main (System.String[] args) [0x0000f] in /Users/builder/data/lanes/5024/152b654a/source/xamarin-macios/tools/mtouch/mtouch.cs:945

https://bugzilla.xamarin.com/show_bug.cgi?id=59798
2017-09-28 17:31:55 +02:00
Rolf Bjarne Kvinge d0bb1c5d0c [tests] Recover BindAs test that got lost in merges. (#2786) 2017-09-27 14:05:54 +02:00
Rolf Bjarne Kvinge a979a10412 Merge remote-tracking branch 'origin/master' into bindas-registrar-support 2017-09-22 10:50:07 +02:00
Rolf Bjarne Kvinge 3aabef12dd [mtouch/mmp] Downgrade MT0123 to a verbose log statement instead. (#2701)
* [mtouch/mmp] Downgrade MT0123 to a verbose log statement instead.

It's unlikely to be useful for normal people who've just set LANG for whatever
unrelated reason.

If it's needed to diagnose failures, it'll still show up in verbose logs.

* [docs] Remove MT0123, it's no longer being used, and we never released a version that used it either.

* [tests][mtouch] Update tests according to code changes (MT0123 removal).
2017-09-18 17:14:17 +02:00
Sebastien Pouliot 05eb96d0a7 Merge branch 'xcode9' into xcode9-master-merge 2017-09-15 11:05:30 -04:00
Sebastien Pouliot 6e918098da Merge latest d15-3 fixes into xcode9 (#2660)
* [msbuild] Re-added wildcard (*) expandsion for application-identifier in Entitlements.plist (#2186)

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

* Bump mono (#2213)

* Framework tests were still binding non-linked Simple class which errors now (#2216) (#2218)

- Improve Makefile to rebuild when projects build with errors

* Bump mono to get cecil fix for bug #56808. (#2222)

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

* [msbuild] Use @(ReferencePath) instead of @(ResolvedFiles) (#2188) (#2214)

This allows things to work on both xbuild and msbuild.

In xbuild, both lists are exactly the same and on msbuild,
only @(ReferencePath) exists.

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

* NSActivityOptions.IdleDisplaySleepDisabled had wrong value (#2232) (#2239)

This was due to an integer overflow.  The original value was based on Int32
1 << 40 == 256

The correct value should be based on a UInt64.
1UL << 40 == 1099511627776

* [tests] Fix bug 57699 - [iOS]InternalsTest failure (Linkall) tests on device (#2243)

Strip native debugging symbols should not be checked for debug builds

* Bump mono to get fix for bug #57780.

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

* Update .gitmodules

Change branch to d15-3 branch of mono

* Bump maccore to get fix for bug #55064.

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

* [mono] Bump mono to get the head of cecil/mono-2017-04 and fix IsComObject #57919

Also fix #58789 [1], the typo in tools/mtouch/Tuning.cs showing in MT0000 errors
instead MT2102. That's already in master and d15-4

mono bump includes:

[2] commit 2a6502cee0df9de5198eafe7c8b5f6ac25106f34 (HEAD -> d15-3, origin/d15-3)
Merge: 02457c20fcf 5e05cafc6f1
Author: Luis Aguilera <luis.aguilera@xamarin.com>
Date:   Fri Aug 18 10:04:06 2017 -0400

    Merge pull request #5401 from marek-safar/com

    [Marshal.IsComObject] Make this predicate return false instead of thr…

[3] commit 02457c20fcf57c0610e844d638eb1da82b5d1eb0
Merge: da80840ea55 73fd9a1b82e
Author: Luis Aguilera <luis.aguilera@xamarin.com>
Date:   Fri Aug 18 09:59:06 2017 -0400

    Merge pull request #5400 from spouliot/bump-cecil-58834-d15-3

    [cecil] Bump to the head of the mono-2017-04 branch and pick the fix for bug #58834

References
[1] https://bugzilla.xamarin.com/show_bug.cgi?id=58789
[2] https://bugzilla.xamarin.com/show_bug.cgi?id=57919
[3] https://bugzilla.xamarin.com/show_bug.cgi?id=58834

* [mtouch] Put 'mono_profiler_startup_log' in the symbol list. Fixes #58778. (#2501)

We need the 'mono_profiler_startup_log' symbol when profiling is enabled, so
make sure to add the symbol to the correct list of symbols we need.

Previously we were passing `-u _mono_profiler_startup_log` to clang directly,
which is fine, but not complete, since it does not write the symbol to the
symbollist file (--symbollist=file), which means it wouldn't be preserved when
the MSBuild tasks strip the executable.

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

* Bump versions for SR3

https://trello.com/c/EVze08ei

* Bump mono to include HttpClientHandler fix #44027

https://trello.com/c/jYFXadH8/8-systemnethttp-close-request-stream-when-httpclienthandler
https://bugzilla.xamarin.com/show_bug.cgi?id=44027
2017-09-12 13:08:55 -04:00
Rolf Bjarne Kvinge af44978cce [mtouch] Print verbosity using an invariant culture. Fixes #58849. (#2507)
* [mtouch/mmp] Set CultureInfo.CurrentCulture according to LANG.

This makes it easier to run mtouch/mmp under different locales when testing.

Unfortunately mono checks the system locale before checking LANG, which means
that there's no built-in way in macOS/mono to specify the current locale
without changing the system locale.

* [mtouch] Print verbosity using an invariant culture. Fixes #58849.

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

* [mtouch/mmp] Fix error code.

* [mtouch/mmp] Log/warn when we set the current language.
2017-08-22 09:40:26 +02:00
Rolf Bjarne Kvinge f60801bf6b [mtouch] Put 'mono_profiler_startup_log' in the symbol list. Fixes #58778. (#2501)
We need the 'mono_profiler_startup_log' symbol when profiling is enabled, so
make sure to add the symbol to the correct list of symbols we need.

Previously we were passing `-u _mono_profiler_startup_log` to clang directly,
which is fine, but not complete, since it does not write the symbol to the
symbollist file (--symbollist=file), which means it wouldn't be preserved when
the MSBuild tasks strip the executable.

https://bugzilla.xamarin.com/show_bug.cgi?id=58778
2017-08-18 11:20:43 +02:00
Rolf Bjarne Kvinge 81a1d81d38 [tests] Add the HFS+ equivalent of a memory barrier. Fixes #57831. (#2352)
https://bugzilla.xamarin.com/show_bug.cgi?id=57831
2017-07-31 17:13:08 +02:00
Rolf Bjarne Kvinge d34918dda2 [mtouch] Report better error (MT4169) when we can't generate a P/Invoke wrapper for a P/Invoke. (#2349) 2017-07-20 15:34:42 +02:00
Rolf Bjarne Kvinge 772f6d5b43 [mtouch] Fix collecting required internal symbols which aren't in the objc_msgSend family. (#2330)
Fix collecting required internal symbols which aren't in the objc_msgSend
family by not bailing out early for a function which isn't in the objc_msgSend
family.

Also add a test.
2017-07-18 14:26:45 +02:00
Rolf Bjarne Kvinge 981af59058 [mtouch] Don't allow building for 32-bit when deployment target is >= 11. Fixes #57966. (#2303)
* [mtouch] Don't allow building for 32-bit when deployment target is >= 11. Fixes #57966.

Also bump maccore to get an mlaunch error for launching a 32-bit app in a 64-bit-only simulator.

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

* [tests][msbuild] Make sure all Info.plists have deployment targets.

Otherwise we get different behavior (32-bit allowed or not) depending on which
Xcode is used to build.

* [mtouch] Default to 64-bit arch if not specified and targeting iOS 11+.

* [tests] Tweak tests to either specify a deployment target < 11 or not build a 32-bit arch.
2017-07-11 08:54:50 +02:00
Rolf Bjarne Kvinge 871c055308 [generator] Add unit test project, and port a few tests over from the makefile tests. (#2299) (#2304) 2017-07-11 08:52:24 +02:00
Rolf Bjarne Kvinge 3d429a106b [generator] Add unit test project, and port a few tests over from the makefile tests. (#2299) 2017-07-10 12:46:31 +02:00
Rolf Bjarne Kvinge 88a377e5f3 [tests] Update tests since BindAs supports conversions between enums and NSNumber. 2017-07-07 12:28:53 +02:00
Rolf Bjarne Kvinge a41c6ebc3f [registrar] Verify if the BindAs type matches the type in the method signature. 2017-07-07 12:28:10 +02:00
Rolf Bjarne Kvinge 098c6876fa [mtouch] Minor adjustments to get error messages right. 2017-07-05 08:54:42 +02:00
Rolf Bjarne Kvinge f53e9da0d7 [mtouch] Minor adjustments to get error messages right. 2017-07-04 20:07:20 +02:00
Rolf Bjarne Kvinge d3a505fa24 [tests] Add mtouch tests for the BindAs attribute. 2017-07-04 07:35:29 +02:00
Rolf Bjarne Kvinge 22a01fd6f8 [mtouch] Check for __Internal P/Invokes after processing P/Invokes for exception marshaling. Fixes #57833. (#2261)
When we process P/Invokes to add support for exception marshaling, we may
change P/Invokes to be __Internal. This means that we need to move the check
for __Internal P/Invokes to after processing P/Invokes for exception
marshaling.

https://bugzilla.xamarin.com/show_bug.cgi?id=57833
2017-06-28 17:09:15 +02:00
Rolf Bjarne Kvinge 2fa55d410d [mtouch] If a P/Invoke is used by any assembly that looks up the native symbol using dlsym, it's a required symbol. Fixes #57826. (#2260)
Previously the assumption was that if an assembly not using dlsym references a
native symbol, it's not a required symbol. This is true as far as the native
linker goes: the native linker will see that the native symbol is referenced
by the AOT-compiled code, and it won't be removed.

However, we use also this exact logic to create the list of functions we ask
the native strip command to preserve, and in this case we need to include all
symbols needed in all assemblies that looks up native functions using dlsym.

https://bugzilla.xamarin.com/show_bug.cgi?id=57826
2017-06-28 16:26:26 +02:00
Rolf Bjarne Kvinge c1348da5f6 [tests][mtouch] Adjust tests to cope with Xcode 9. Fixes #57601. (#2231)
Fixes:

1. Failed : Xamarin.MTouch.MT0091(tvOS,"tvOS")
    The error 'MT0091: This version of Xamarin.iOS requires the tvOS 11.0 SDK (shipped with Xcode 9.0). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only (to try to avoid the new APIs).' was not found in the output:
    Message #1 did not match:
        actual:   'This version of Xamarin.iOS requires the tvOS 11.0 SDK (shipped with Xcode 9). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only (to try to avoid the new APIs).'
        expected: 'This version of Xamarin.iOS requires the tvOS 11.0 SDK (shipped with Xcode 9.0). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only (to try to avoid the new APIs).'

2. Failed : Xamarin.MTouch.MT0091(iOS,"iOS")
    The error 'MT0091: This version of Xamarin.iOS requires the iOS 11.0 SDK (shipped with Xcode 9.0). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only (to try to avoid the new APIs).' was not found in the output:
    Message #1 did not match:
        actual:   'This version of Xamarin.iOS requires the iOS 11.0 SDK (shipped with Xcode 9). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only (to try to avoid the new APIs).'
        expected: 'This version of Xamarin.iOS requires the iOS 11.0 SDK (shipped with Xcode 9.0). Either upgrade Xcode to get the required header files or set the managed linker behaviour to Link Framework SDKs Only (to try to avoid the new APIs).'

3. Failed : Xamarin.Registrar.NoWarnings
    no warnings
    Expected: not String matching "warning:"
    But was:  "/Users/builder/jenkins/workspace/xamarin-macios-pr-builder/tests/mtouch/bin/Debug/tmp-test-dir/Xamarin.MTouchTool.CreateTemporaryDirectory298/mtouch-test-cache/registrar.m:32468:17: warning: method 'paymentAuthorizationViewController:didAuthorizePayment:handler:' in protocol 'PKPaymentAuthorizationViewControllerDelegate' not implemented [-Wprotocol]"

https://bugzilla.xamarin.com/show_bug.cgi?id=57601
2017-06-21 12:07:13 +02:00
Rolf Bjarne Kvinge 257de9c2c0 [mtouch] Normalize strings that refer to assemblies and their paths before comparing them. Fixes #57266. (#2217)
HFS normalizes filenames to Form D when files are stored. This means that an
assembly whose assembly name is stored in Form C might be stored in a file
whose filename is Form D (which you'll get if you use the Form C filename).

However, this is a problem when we've already loaded an assembly and if we
doesn't take normalization into account: we check the cache based on the
filename, but store in the cache based on the assembly name. If those two uses
different normalization schemes, bad things (bug #57266) happen.

So in these scenarios normalize strings before comparing them.

https://bugzilla.xamarin.com/show_bug.cgi?id=57266
2017-06-15 11:24:31 +02:00
Timothy Risi 25468bf617 Merge Quote methods into a single class instead of multiple versions (#2153) 2017-06-06 12:32:25 -08:00
Rolf Bjarne Kvinge d17cb6556a [mtouch] Improve how we make sure native symbols aren't stripped away. Fixes #51710 and #54417. (#2162)
* [mtouch] Improve how we make sure native symbols aren't stripped away. Fixes #51710 and #54417.

* Refactor required symbol collection to store more information about each
  symbol (field, function, Objective-C class), and in general make the code
  more straight forward.
* Implement support for generating source code that references these symbols,
  and do this whenever we can't ask the native linker to keep these symbols
  (when using bitcode). Additionally make it possible to do this manually, so
  that the source code can be generated for non-bitcode platforms too (which
  is useful if the number of symbols is enormous, in which case we might
  surpass the maximum command-line length).
* Also make it possible to completely ignore native symbols, or ignore them on
  a per-symbol basis. This provides a fallback for users if we get something
  right and we try to preserve something that shouldn't be preserved (for
  instance if it doesn't exist), and the user ends up with unfixable linker
  errors.
* Don't collect Objective-C classes unless they're in an assembly with
  LinkWith attributes. We don't need to preserve Objective-C classes in any
  other circumstances.
* Implement everything for both Xamarin.iOS and Xamarin.Mac, and share the
  code between them.
* Remove previous workaround for bug #51710, since it's no longer needed.
* Add tests.

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

* [mtouch] Make sure to only keep symbols from the current app when code sharing.

This fixes a build problem with the interdependent-binding-projects test when
testing in Today Extension mode.
2017-06-02 18:29:19 +02:00
Rolf Bjarne Kvinge 1fb67779f8 [registrar] Detect more invalid characters in selectors so that we can report better errors. Fixes #55568. (#2154)
* [registrar] Detect more invalid characters in selectors so that we can report better errors. Fixes #55568.

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

* [mtouch] Add a few comments about duplicated data between mtouch and tests.
2017-06-02 16:37:26 +02:00
Rolf Bjarne Kvinge 1189a5b94c [mtouch] Set the force flag again when the cache is invalid. Fixes #54973. (#2163)
In 11390f119c we stopped setting the force flag
when the cache was invalid, because we'd delete the cache anyway, and it was
determined that deleting the cache was enough.

Unfortunately it's not, because some output is not in the cache, and might not
get correctly updated.

Scenario:

* User builds app.
* User changes some build option (for instance switching off incremental
  builds).
* User does an insignificant change in a source file for the executable
  process.
* User builds app again (without cleaning). This will rebuild the exe, but
  since the change was insignificant, all the IL, except the MVID, would
  remain identical.
* mtouch would see that the command-line options changed, and invalidate the
  cache. This would delete the cache, and everything would be rebuilt,
  including AOT-compiling the assemblies again.
* When the time came for mtouch to copy assemblies to the app directory,
  mtouch would realize that the existing .exe in the app (which was not
  deleted because it's not in the cache, but the actual output directory) was
  only insignificantly different (only the MVID was different, which our cache
  logic knows to ignore when comparing assemblies), so it wouldn't copy the
  .exe to the .app.
* At runtime we'd assert, because the MVID in the aot-compiled code was
  different from the MVID in the assembly:

      error: Failed to load AOT module '(null)' while running in aot-only mode: doesn't match assembly.

* The exact assert varies depending on which build option changed. Other
  variations:

      Failed to load AOT module '(null)' while running in aot-only mode: compiled against GC (4, while the current runtime uses GC sgen)

      * Assertion at /Users/builder/data/lanes/4691/0719ced1/source/xamarin-macios/external/mono/mono/metadata/metadata.c:1118, condition `idx < t->rows' not met

Because of this I'm reverting 11390f119c, and
once again setting the force flag when the cache is invalid. It might be
overkill, but it's the safest option (cache invalidation is after all the only
hard problem in computer science), and bugs are very annoying and
timeconsuming to track down.

https://bugzilla.xamarin.com/show_bug.cgi?id=54973
2017-06-02 15:23:30 +02:00
Rolf Bjarne Kvinge f6599c4437 [tests] Reuse some code between mtouch rebuild tests and improve the output. (#2157)
* [tests] Print mtouch output if verbose output was requested, even if mtouch succeeded.

* [tests] Reuse some code between mtouch rebuild tests.
2017-06-01 17:28:56 +02:00
Rolf Bjarne Kvinge 25e6a93976 [tests] Simplify the MT4164 test a bit. (#2151)
* [tests] Add support to mtouch tests for comparing file name & line number of error/warning messages.

* [tests] Simplify the MT4164 test a bit.
2017-06-01 01:10:36 +02:00
Rolf Bjarne Kvinge c199c9f2c2 [mtouch] Show a nice error (MT4168) if the user registers a managed class with an Objective-C keyword. Fixes #51776. (#2150)
Previously:

    obj/iPhone/Ad-Hoc/mtouch-cache/64/registrar.m:4402:12: error: expected identifier
    @interface register : UITableViewController {
    ^
    obj/iPhone/Ad-Hoc/mtouch-cache/64/registrar.m:4402:21: error: expected unqualified-id
    @interface register : UITableViewController {

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

Now:

    error MT4168: Cannot register the type 'register' because its Objective-C name 'register' is an Objective-C keyword. Please use a different name.

https://bugzilla.xamarin.com/show_bug.cgi?id=51776
2017-05-31 19:07:02 +02:00
Andi McClure a6cf8c5edc [Do not merge yet] Update to mono 2017-04 branch (#1960)
* Update to mono 2017-04 branch

* Patch from Zoltan to fix build error with CppSharp.CppParser.dll

* Include new linker files in Makefile, based on mareks commit

* [msbuild] Fix running bgen for Xamarin.Mac.

bgen must be executed with the system mono, not bmac-mobile-mono, and without
the MONO_PATH variable set.

* System.Data tests should act as if they are running on mobile profile

* Add --runtime=mobile to mono flags in Modern

* Move runtime launcher options up

* System.Data tests should use Mobile profile (mac fix)

* Bump 2017-04 to pick up AOT and assembly resolution fixes

* Build fixes for netstandard.dll and System.Drawing.Primitives.dll

The new handling went in with https://github.com/mono/mono/pull/4501.

I also noticed that WatchOS was missing a target for System.Drawing.Primitives.dll, so I added that.

* Add netstandard.dll to 2.1/Facades and System.Drawing.Primitives.dll to WatchOS

* Fix 2.1/Facades/netstandard.dll build

* Fix the netstandard targets

* Bump mono to latest 2017-04 commit

* [xharness] Fix adding defines to csproj by correctly detecting existing defines.

* Bump mono to latest 2017-04 commit

* [mtouch] Update csproj with new files.

* [mtouch] Improve reporting for MarkExceptions from the linker.

* Bump mono to latest 2017-04 commit

* Bump mono to pick up latest 2017-04 branch commit (Fixes #55436)

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

* Add a missing Makefile dependency

* Chris Hamons patch to apply --runtime=mobile as necessary at AOT time

(It is currently being applied for some configurations at runtime only)

* Bump system mono

* Bump mono for assembly loader changes

* Bump system mono

* Update assemblies list as some where moved to facades

6ca5ec442b
c38e4d9220

* Bump mono to latest 2017-04 commit

* Add another new facade

* Bump mono to tip of 2017-04.

* Bump mono to tip of 2017-04.

* [tests][mtouch] Adjust tests to cope with fewer assemblies being included in linked apps. Fixes #56307 and #56308.

System.dll is now completely linked away unless the app actually uses any
System.dll API.

This is the change that caused this to change: 4960d5d2a2

Previously the following types would always be kept by the linker:

```
$ monodis --typedef System.dll
Typedef Table
1: (null) (flist=1, mlist=1, flags=0x0, extends=0x0)
2: ObjCRuntime.INativeObject (flist=1, mlist=1, flags=0xa0, extends=0x0)
3: Mono.Net.CFObject (flist=1, mlist=2, flags=0x100000, extends=0x5)
4: Mono.Net.CFArray (flist=4, mlist=19, flags=0x100, extends=0xc)
5: Mono.Net.CFNumber (flist=5, mlist=32, flags=0x100100, extends=0xc)
6: Mono.Net.CFRange (flist=5, mlist=41, flags=0x100108, extends=0x25)
7: Mono.Net.CFString (flist=7, mlist=42, flags=0x100100, extends=0xc)
8: Mono.Net.CFData (flist=8, mlist=53, flags=0x100100, extends=0xc)
9: Mono.Net.CFDictionary (flist=8, mlist=63, flags=0x0, extends=0xc)
10: Mono.Net.CFMutableDictionary (flist=10, mlist=75, flags=0x100100, extends=0x24)
11: Mono.Net.CFUrl (flist=10, mlist=80, flags=0x100100, extends=0xc)
12: Mono.Net.CFRunLoop (flist=10, mlist=83, flags=0x100100, extends=0xc)
13: Mono.Net.CFBoolean (flist=10, mlist=94, flags=0x100, extends=0x5)
14: Mono.AppleTls.SecCertificate (flist=13, mlist=106, flags=0x100100, extends=0x5)
15: Mono.AppleTls.SecIdentity (flist=14, mlist=122, flags=0x100, extends=0x5)
16: Mono.AppleTls.SecIdentity/ImportOptions (flist=19, mlist=134, flags=0x100105, extends=0x5)
17: Mono.AppleTls.SecKey (flist=19, mlist=134, flags=0x100100, extends=0x5)
18: Mono.AppleTls.SecStatusCode (flist=21, mlist=141, flags=0x100, extends=0x69)
19: Mono.AppleTls.SecTrustResult (flist=395, mlist=141, flags=0x100, extends=0x69)
20: Mono.AppleTls.SecImportExport (flist=404, mlist=141, flags=0x100100, extends=0x5)
21: Mono.AppleTls.SecImportExport/<>c (flist=404, mlist=144, flags=0x102103, extends=0x5)
22: Mono.AppleTls.SecPolicy (flist=406, mlist=147, flags=0x100100, extends=0x5)
23: Mono.AppleTls.SecTrust (flist=407, mlist=154, flags=0x100100, extends=0x5)
24: System.Security.Cryptography.OidGroup (flist=408, mlist=174, flags=0x101, extends=0x69)
25: System.Security.Cryptography.Oid (flist=420, mlist=174, flags=0x100101, extends=0x5)
26: System.Security.Cryptography.CAPI (flist=423, mlist=176, flags=0x100180, extends=0x5)
27: System.Security.Cryptography.AsnEncodedData (flist=423, mlist=178, flags=0x100101, extends=0x5)
28: System.Security.Cryptography.X509Certificates.X509Utils (flist=424, mlist=179, flags=0x100100, extends=0x5)
29: System.Security.Cryptography.X509Certificates.PublicKey (flist=424, mlist=181, flags=0x100101, extends=0x5)
30: System.Security.Cryptography.X509Certificates.X509Certificate2 (flist=429, mlist=188, flags=0x102101, extends=0x51)
31: System.Security.Cryptography.X509Certificates.X509Certificate2Impl (flist=431, mlist=204, flags=0x100080, extends=0x55)
32: System.Security.Cryptography.X509Certificates.X509CertificateCollection (flist=431, mlist=209, flags=0x102101, extends=0x6d)
33: System.Security.Cryptography.X509Certificates.X509CertificateCollection/X509CertificateEnumerator (flist=431, mlist=212, flags=0x100102, extends=0x5)
34: System.Security.Cryptography.X509Certificates.X509Helper2 (flist=432, mlist=217, flags=0x100180, extends=0x5)
35: <PrivateImplementationDetails> (flist=432, mlist=218, flags=0x100, extends=0x5)
36: <PrivateImplementationDetails>/__StaticArrayInitTypeSize=9 (flist=433, mlist=219, flags=0x113, extends=0x25)
```

Some of the above types from System.dll implemented ObjCRuntime.INativeObject
(from System.dll), which our linker detected as implementing
ObjCRuntime.INativeObject (from Xamarin.iOS.dll), so these types were treated
as custom NSObject subclasses, and the MarkNSObjects linker step would mark
them (which would in turn cause all the other types in the list to be marked).

With that change, these types now implement ObjCRuntimeInternal.INativeObject,
and the linker does not treat them as custom NSObject subclasses anymore.

I think the new behavior is correct: these types do not actually inherit from
the real NSObject/INativeObject, so the linker should not treat them as such.

This may run into different bugs because the linker might now remove more
stuff than before, but that would be a different issue.

This means that the fix is to modify these tests accordingly.

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

* Bump mono to latest.

* Fix merge conflict that was missed

* [mtouch] Renumber new error which clashes with an existing error number in master.
2017-05-29 18:39:29 +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 1548594e7b [mtouch] Allow code sharing assemblies from multiple locations if they're identical. Fixes #56513. (#2119)
* [mtouch] Allow code sharing assemblies from multiple locations if they're identical. Fixes #56498.

We disallow code sharing when the same assembly (based on name) is referenced
from multiple paths, but poke a hole in this logic by allowing the same
assembly from multiple paths when those assemblies are 100% identical, since
that should be 100% safe.

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

* [tests] Comment out assert that asserts due to another bug.
2017-05-25 07:10:56 +02:00
Rolf Bjarne Kvinge ea15ebd859 [mtouch] Don't look for assembly references in attributes in assemblies we ship. Partially fixes #49087. (#2121)
* [mtouch] Don't look for assembly references in attributes in assemblies we ship. Partially fixes #49087.

Don't look for assembly references in attributes in assemblies we ship,
because it takes a significant amount of time to do this, and we can
precompute the fact that there aren't any such assembly references.

Additionally add a test to ensure we catch any changes to this assumption.

For a simple test app this makes rebuilding (without any changes) go from
~1.1s to ~0.4s.

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

* [tests] Simplify tests to not use [TestCaseSource].

Using [TestCaseSource] is nice when running from the IDE, since it shows all
test cases in the test tree.

Unfortunately it causes the console runner to freak out [1], because the method
that lists all the test cases calls Configuration's cctor, which calls
TestContext.CurrentContext.TestDirectory, which is apparently not safe this
early in the test run.

[1] I think 'freak out' is the appropriate term for this behavior, which has
absolutely no direct nor obvious connection to the cause of the problem:

System.Runtime.Remoting.RemotingException: Cannot create channel sink to connect to URL 93a78115_c0da_4b6a_9661_9f9b9d9fb935/6669afd6_4.rem. An appropriate channel has probably not been registered.

Server stack trace:
  at System.Runtime.Remoting.RemotingServices.GetClientChannelSinkChain (System.String url, System.Object channelData, System.String& objectUri) [0x00019] in <04300341516a482b9708b764d58af7ca>:0
  at System.Runtime.Remoting.RemotingServices.GetOrCreateClientIdentity (System.Runtime.Remoting.ObjRef objRef, System.Type proxyType, System.Object& clientProxy) [0x0001d] in <04300341516a482b9708b764d58af7ca>:0
  at System.Runtime.Remoting.RemotingServices.GetRemoteObject (System.Runtime.Remoting.ObjRef objRef, System.Type proxyType) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
  at System.Runtime.Remoting.RemotingServices.GetProxyForRemoteObject (System.Runtime.Remoting.ObjRef objref, System.Type classToProxy) [0x0001b] in <04300341516a482b9708b764d58af7ca>:0
  at System.Runtime.Remoting.RemotingServices.Unmarshal (System.Runtime.Remoting.ObjRef objectRef, System.Boolean fRefine) [0x0007a] in <04300341516a482b9708b764d58af7ca>:0
  at System.Runtime.Remoting.RemotingServices.Unmarshal (System.Runtime.Remoting.ObjRef objectRef) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
  at System.Runtime.Remoting.ObjRef.GetRealObject (System.Runtime.Serialization.StreamingContext context) [0x0000f] in <04300341516a482b9708b764d58af7ca>:0
  at System.Runtime.Serialization.ObjectManager.ResolveObjectReference (System.Runtime.Serialization.ObjectHolder holder) [0x00010] in <04300341516a482b9708b764d58af7ca>:0
  at System.Runtime.Serialization.ObjectManager.DoFixups () [0x0007f] in <04300341516a482b9708b764d58af7ca>:0
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize (System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser serParser, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00077] in <04300341516a482b9708b764d58af7ca>:0
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x000a2] in <04300341516a482b9708b764d58af7ca>:0
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.DeserializeMethodResponse (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) [0x00000] in <04300341516a482b9708b764d58af7ca>:0
  at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage (System.Runtime.Remoting.Messaging.IMessage msg) [0x00083] in <270c90abbc234cde9d33eb198a97cf71>:0
2017-05-24 21:05:21 +02:00
Rolf Bjarne Kvinge 0c87730ff1 [mtouch] Fix linking with the same third-party framework from both extension and container app. Fixes #56635. (#2112)
If both an extension and the container app (or multiple extensions) reference
the same binding assembly for a framework, then we'd error out with an
internal error when trying to copy the framework from both locations to the
container app.

So instead detect when we're trying to copy multiple identical (by comparing
the on-disk contents) frameworks, and only copy one of them.

We'll still show an error if the frameworks are different, but now a nice
MT1035 error with a proper error description instead of an internal error.

https://bugzilla.xamarin.com/show_bug.cgi?id=56635
2017-05-19 17:05:38 +02:00
Rolf Bjarne Kvinge 03589db5ba [mmp/mtouch/ObjCRuntime] Calculate the path to the runtime-options.plist using NSBundle's ResourcePath. (#2072)
* [mmp/mtouch/ObjCRuntime] Calculate the path to the runtime-options.plist using NSBundle's ResourcePath.

The anatomy of apps and frameworks differ between iOS and macOS:

* iOS: we put runtime-options.plist in the root directory of the app.
* macOS:
  * for apps we put runtime-options in foo.app/Contents/Resources
  * for frameworks we put runtime-options in foo.framework/Versions/Current/A/Resources

Luckily NSBundle's ResourcePath property returns exactly this path, so change
our logic to use this property.

Also calculate the NSBundle using an exported type we know we have (using the
main bundle won't work when we're a framework).

* [tests] Add mmp/mtouch tests to verify the default HttpClientHandler according to build arguments.

* [ObjCRuntime] Use a custom class for finding the bundle.

Use a self-defined custom class to find the bundle where our resources are.
Using the internal NSObject.NSObject_Disposer class doesn't work when this
file (RuntimeOptions.cs) is compiled into System.Net.Http.dll.
2017-05-08 17:58:21 +02:00
Rolf Bjarne Kvinge 1eb6c335a6 [mtouch] Disable incremental builds for the simulator. Fixes #55712. (#2054)
It does not make sense to support incremental builds for the simulator (since
no AOT compilation is done), it just makes the test matrix more complicated.

So simplify things by removing support for incremental builds.

We also ignore any (other) --assembly-build-target arguments, because building
to frameworks doesn't make sense either in the simulator.

https://bugzilla.xamarin.com/show_bug.cgi?id=55712
2017-04-28 13:34:37 -04:00
Sebastien Pouliot 63a67b5287 Merge pull request #2040 from rolfbjarne/bug55555
[mtouch] Don't remove information when collecting all architectures. Fixes #55555.
2017-04-25 21:29:53 -04:00
Rolf Bjarne Kvinge d8d9a96254 [mtouch] Add support for stripping bitcode from frameworks when not needed. Fixes #55256. (#2037)
This dramatically decreases the size of watchOS apps built for debug when
using frameworks, because it ends up removing all the bitcode from
Mono.framework.

https://bugzilla.xamarin.com/show_bug.cgi?id=55256
2017-04-25 17:46:41 +02:00
Rolf Bjarne Kvinge f6cbea8545 [mtouch] Don't remove information when collecting all architectures. Fixes #55555.
Of particular importance is if we're building for LLVM or not: this fixes a
bug where we wouldn't pass --llvm to the AOT compiler when compiling
assemblies to frameworks (which we do when sharing code).

https://bugzilla.xamarin.com/show_bug.cgi?id=55555
2017-04-25 14:32:08 +02:00
Rolf Bjarne Kvinge 6b89100044 Merge pull request #2019 from rolfbjarne/embeddinator-4000
Add embeddinator support.
2017-04-20 10:09:02 +02:00
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 bb288e8c60 [tests] Bump mono to get fix for bug #54578 and add test case. (#2026)
https://bugzilla.xamarin.com/show_bug.cgi?id=54578
2017-04-19 09:54:47 -04: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
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
Rolf Bjarne Kvinge 1105ee6136 [tests][mtouch] Fix MT0091 test after error text change. (#1956)
Also fix the test to not depend on having a specific version of an older Xcode
installed, but instead use any old Xcode.
2017-04-03 16:10:42 +02:00
Marek Safar 95b8f2559f Remove Mono.Dynamic.Interpreter from mtouch tests 2017-03-29 16:23:28 +02: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
Marek Safar 16ba9f1452 [build] Update debug symbols to pdb 2017-03-14 11:47:06 +01: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 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 59bd32d9ca [tests] Add test for MT0127. (#1781) 2017-02-28 16:08:58 +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 4de9a8c0d6 Merge remote-tracking branch 'origin/master' into framework-sdk 2017-02-28 10:16:18 +01:00
Rolf Bjarne Kvinge 1821ff86f3 [tests][mtouch] Simplify code a bit. (#1763) 2017-02-24 14:59:46 +01: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 e8fbb7f0a6 [tests][mtouch] There's no need to delete a temporary directory we create ourselves. (#1711)
Deleting the directory when the test completes just makes it harder to copy-
paste the failing command.

Any directories created by Cache.CreateTemporaryDirectory will automatically
be deleted at the next test run, so this won't use up disk space.
2017-02-17 16:01:05 +01: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 07127a76ca [mtouch] Make code sharing failures real warnings. 2017-02-17 10:16:51 +01:00
Rolf Bjarne Kvinge 4a0ffa3110 [mtouch tests] Refactor registrar tests a little bit to not cause trouble in Xamarin Studio. (#1679)
Change how the registrar calls mtouch a bit, so that we don't use API that
throws an exception with the entire output in the exception message.

The problem is that if the process has a lot of output, XS slows down to a
crawl when showing the exception message in the test result pad.

Instead print the output to the terminal.
2017-02-10 18:24:37 +01:00
Rolf Bjarne Kvinge 4917950327 [mtouch tests] Refactor registrar tests a little bit to not cause trouble in Xamarin Studio.
Change how the registrar calls mtouch a bit, so that we don't use API that
throws an exception with the entire output in the exception message.

The problem is that if the process has a lot of output, XS slows down to a
crawl when showing the exception message in the test result pad.

Instead print the output to the terminal.
2017-02-10 16:39:39 +01:00
Rolf Bjarne Kvinge 769e11fb58 [mtouch tests] Add new test for architectures in frameworks. 2017-02-10 16:39:30 +01:00
Rolf Bjarne Kvinge 5bea8577a4 [mtouch tests] Automatically pass --extension to mtouch if we create a temporary extension. 2017-02-10 16:39:29 +01:00
Rolf Bjarne Kvinge ccd1c2ce4d [mtouch tests] Remove debug spew. 2017-02-10 16:39:29 +01:00
Rolf Bjarne Kvinge b78d6fa429 [mtouch tests] Fix typo. 2017-02-10 16:39:29 +01:00
Rolf Bjarne Kvinge 6d744417dd [mtouch tests] Improve rebuild test. 2017-02-10 16:39:26 +01:00
Rolf Bjarne Kvinge d38656b912 [mtouch tests] Bump the timeout for a few tests from 1 to 5 minutes. 2017-02-10 16:39:25 +01:00
Rolf Bjarne Kvinge 2973b99f51 [mtouch tests] Add support for passing --nostrip to mtouch.
And use it to make tests run faster when we don't need to strip code.
2017-02-10 16:39:20 +01:00
Rolf Bjarne Kvinge 2a21419197 [mtouch tests] Add code sharing test. 2017-02-10 16:39:19 +01:00
Rolf Bjarne Kvinge 62c08fd233 [mtouch tests] Allow creating temporary apps/extensions multiple times without re-creating temporary directories.
Allow creating temporary apps/extensions multiple times without re-creating temporary directories.

This makes it possible for tests to call CreateTemporaryApp|Extension multiple
times with different code, and have only the actual managed assembly change
between each time (which is useful for tests that verifies that cached builds
are used properly).
2017-02-10 16:39:19 +01:00
Rolf Bjarne Kvinge 2f8064a6e4 [mtouch tests] Check if plist has changed before writing it.
This is important for rebuild tests checking filestamps.
2017-02-10 16:39:19 +01:00
Rolf Bjarne Kvinge a1a141b4ca [mtouch tests] Use a different default app name for service extensions.
Otherwise it might end up clashing with the main app's name, preventing code sharing.
2017-02-10 16:39:18 +01:00
Rolf Bjarne Kvinge 18a6bf4690 [mtouch tests] Store app extensions as MTouchTool instances. 2017-02-10 16:39:18 +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 15438d3a79 [mtouch tests] We don't create symlinks for assemblies anymore, so update tests accordingly. 2017-02-10 14:46:30 +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 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 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 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 6545897ccf [tests] Add test for MT0003. 2017-02-10 14:03:25 +01:00
Rolf Bjarne Kvinge 209ac7e58e [tests] Some simulator builds can disable the linker to build slightly faster. 2017-02-10 14:03:25 +01:00
Rolf Bjarne Kvinge 0e27b4a812 [mtouch tests] Add sleep to fix #47696. (#1662)
Sometimes, when the stars align, fastsim can build an app in less than a
second.

Coupled with the fact that HFS+'s filestamp resolution is 1 second, we can't
assert that filestamps change without making sure enough time passes by.

So sleep for a second.

https://bugzilla.xamarin.com/show_bug.cgi?id=47696
2017-02-09 11:53:18 +01:00
Rolf Bjarne Kvinge a22cda6eb3 [mtouch tests] Adjust FastDev_LinkWithTest after fe17d5db9f. (#1633)
We disabled fastdev for tvOS/watchOS projects with binding projects in
bac02538, and that broke the FastDev_LinkWithTest:

    Errors and Failures:
    1) Test Failure : Xamarin.MTouch.FastDev_LinkWithTest(TVOS)
         Binding symbol not in executable
      Expected: no item String ending with " T _theUltimateAnswer"
      But was:  < ... >

So adjust the test to match the new behavior.
2017-02-03 11:02:07 +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
Rolf Bjarne Kvinge 47a7568f9b [tests] Refactor many of the mtouch tests to use new testing infrastructure. (#1569)
This makes a couple of future optimizations easier:

* Cache the compilation of test assemblies.
* Load mtouch.exe directly in the test process.
2017-01-27 07:35:32 +01:00
Rolf Bjarne Kvinge 98feef8dff [tests] The mtouch tests now require Cecil, so add the expected project reference to the solution. (#1568) 2017-01-27 07:32:44 +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 025226999a [tests] Sleep a bit to work around HFS' lack of sub-second timestamp values. (#1541)
HFS timestamp resolution is 1 second, which means that we can't distinguish
files modified again within 1 second. This means that this test will fail more
often the faster we make mtouch, so add a forced sleep to make sure we don't
do things faster than the file system can keep track of.
2017-01-20 16:55:08 +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 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
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 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
Rolf Bjarne Kvinge f771761b32 Merge pull request #1444 from rolfbjarne/xharness-add-device-support
[xharness] Major rewrite (add server mode, add device support, add today extension support).
2017-01-10 17:29:37 +01:00
Rolf Bjarne Kvinge 6141528f52 [mtouch tests] Add missing file to csproj. 2017-01-09 17:03:05 +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 39cb42961d [mtouch tests] Add Cache. 2017-01-05 10:43:55 +01:00
Rolf Bjarne Kvinge 2d3a990acf [mtouch tests] Minor refactoring to make a few nested classes non-nested. (#1433) 2017-01-04 19:33:57 +01:00
Rolf Bjarne Kvinge d3e974e2bc [mtouch tests] Build the registrar tests for the simulator. (#1431)
It's *much* faster.
2017-01-03 19:40:33 +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 c5cc47f545 [tests] Specify ordinal string comparison for a few string operations. (#1406) 2016-12-23 17:07:18 +01:00
Rolf Bjarne Kvinge 7842a0b506 [mtouch] Remove deprecated Classic commmand-line arguments. (#1319)
* [mtouch] Remove deprecated Classic commmand-line arguments.

* [mtouch docs] Document MT0022's death.
2016-12-08 18:59:04 +01:00
Rolf Bjarne Kvinge 30bac18e10 [mtouch] Fix BundleId. (#1315)
The BundleId property is used by the code that generates the mSYM directory,
but its value was always the default value 'com.yourcompany.sample' instead of
looked up in the app's Info.plist.

So fix the BundleId property to do the expected.

Also fix the mSYM test (SymbolicationData) to actually test mSYM stuff (it was
partially disabled when we disabled automatic mSYM generation for C8, and
never re-enabled), and port it to the new and better test syntax, and add a
few more asserts to check the manifest.xml generation.
2016-12-08 16:05:47 +01:00
Rolf Bjarne Kvinge 8de0d43799 [mtouch] -lsqlite3 is a linker flag, not a file to be linked with, so treat it accordingly. Fixes #49220. (#1313)
-lsqlite3 is a linker flag, not a file to be linked with, so when
automatically determining that we need to pass -lsqlite3 we need to put it in
the right list of linker information.

Otherwise we may end up passing `-force_load -lsqlite3` to the linker (if the
assembly's ForceLoad flag is set), which won't compile.

https://bugzilla.xamarin.com/show_bug.cgi?id=49220
2016-12-08 15:42:30 +01:00
Rolf Bjarne Kvinge 7dedd1bb4f [tests] Give tests that build for device a bit more time. (#1312)
dontlink/64-bit release times out on our Sierra bots, so try to bump the
timeout to see if this is working on other bots because those other bots are
faster.
2016-12-08 14:11:51 +01:00
Rolf Bjarne Kvinge 2e3185d687 [mtouch tests] Rename Profile.Unified to Profile.iOS. (#1281)
Rename Profile.Unified to Profile.iOS to better match the other values in the enum (tvOS/watchOS).
2016-12-01 12:32:48 +01:00
Rolf Bjarne Kvinge f58ec73658 [tests] Fix a couple of compiler warnings. (#1282)
Fixes:

	TimingTests.cs(17,4): warning CS0618: `NUnit.Framework.TestFixtureSetUpAttribute' is obsolete: `Use OneTimeSetUpAttribute'
	TimingTests.cs(120,4): warning CS0618: `NUnit.Framework.TestFixtureTearDownAttribute' is obsolete: `Use OneTimeTearDownAttribute'
2016-12-01 12:28:42 +01:00
Rolf Bjarne Kvinge 66f82d1f94 [jenkins] Add support for enabling device builds using labels. (#1184)
* [jenkins] Add support for enabling device builds using labels.

* [xharness] Give the iOS MSBuild tests 30 minutes to finish.

* [mtouch tests] Give the BuildTestProject 10 minutes to compile each test case.

Wrench bots build the dontlink test in ~3m40, but that's apparently not enough
for the Jenkins bots (slower bots?), which time out the test after 5 minutes.

So double the timeout to 10 minutes, which will hopefully give the Jenkins
bots enough time to run the test to completion.
2016-11-17 10:22:26 +01:00
Rolf Bjarne Kvinge 37e59b8457 [mtouch tests] Convert MT1016 and MT1017 tests to use new test syntax and link them. (#1173)
Convert MT1016 and MT1017 to newer test syntax, and at the same time change
them to not disable the managed linker.

For these tests it doesn't matter if they're linked or not, but linking is
much faster (20s vs 82s for both tests).
2016-11-11 19:01:24 +01:00
Rolf Bjarne Kvinge 878f2c527a [tests] Update MT1017 test after 7c6d04f1. (#1170)
In 7c6d04f1 the code to create the NOTICE file was simplified, and the new
implementation is writing to a temporary file and then replacing the existing
file.

This makes the scenario that MT1017 was testing (failure if a readonly NOTICE
file already exists) go away, since we don't write to the existing file
anymore (so the build succeeds).
2016-11-11 17:49:41 +01:00
Rolf Bjarne Kvinge 37a0b72a4e [mtouch tests] Update Makefile to NUnit3 syntax for helper text/targets. (#1171) 2016-11-11 17:47:54 +01:00