xamarin-macios/tests/test-libraries
Rolf Bjarne Kvinge 2d104f32d9 [mtouch] Make sure native symbols from third-party libraries are preserved in dylibs. Fixes #51548.
The native linker treats object files (.o) and static libraries (.a files,
which are archives of .o files) differently.

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

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

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

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

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

So:

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

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

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

https://bugzilla.xamarin.com/show_bug.cgi?id=51548
2017-01-18 12:33:06 +01:00
..
.gitignore [tests] Generate some trampoline and registrar tests. 2016-10-13 15:10:43 +02:00
Makefile [mtouch] Make sure native symbols from third-party libraries are preserved in dylibs. Fixes #51548. 2017-01-18 12:33:06 +01:00
XTest-Info.plist [tests] Add test-libraries. 2016-04-26 08:00:35 -04:00
libframework.h [tests] Add test-libraries. 2016-04-26 08:00:35 -04:00
libframework.m [tests] Add test-libraries. 2016-04-26 08:00:35 -04:00
libtest.cs [tests] Generate some trampoline and registrar tests. 2016-10-13 15:10:43 +02:00
libtest.h [tests] Generate some trampoline and registrar tests. 2016-10-13 15:10:43 +02:00
libtest.m [tests] Generate some trampoline and registrar tests. 2016-10-13 15:10:43 +02:00
rename.h [tests] Fix framework-test to actually work. (#1297) 2016-12-05 18:35:53 +01:00
testgenerator.cs [tests] Generate some trampoline and registrar tests. 2016-10-13 15:10:43 +02:00
testgenerator.csproj [tests] Generate some trampoline and registrar tests. 2016-10-13 15:10:43 +02:00