Skip to content

Conversation

@EgorBo
Copy link
Member

@EgorBo EgorBo commented Mar 16, 2020

I'd like to add a minimal Full AOT sample for iOS (to our mono/netcore/sample directory).
I decided to add it as an xcode project to be able to easily open & debug/deploy on a device.
Such samples are useful for experiments and debug purposes (I use it in order to debug issues in corefx tests).

Steps to run the sample:

./build.sh -os iOS -arch arm64
cd src/mono/netcore/sample/iOS
make xcode
# now you can open the xcode project and deploy/debug the sample

Безымянный проект

However, xcode files are quite verbose so probably makes sense to generate the project via cmake.
What do you think @akoeplinger @steveisok @marek-safar do we need the sample in the repo?
UPD replaced with CMake.

// a kind of an animation
ios_set_text (msg.Substring (0, i + 1));
await Task.Delay (100);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how text is animated (see gif)

@EgorBo EgorBo added os-ios Apple iOS and removed os-ios Apple iOS labels Mar 16, 2020
static os_log_t stdout_log;

/* These are not in public headers */
typedef unsigned char* (*MonoLoadAotDataFunc) (MonoAssembly *assembly, int size, void *user_data, void **out_handle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lambdageek could this be fixed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes let's file an issue about this, we shouldn't need to rely on private functions.

using System.Threading.Tasks;
using System.Runtime.InteropServices;

public class MonoPInvokeCallbackAttribute : Attribute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great to avoid this and use NativeCallableAttribute

@vargaz could you please check where we are with the support of mono/mono#17479

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it basically same thing? but yeah NativeCallableAttribute sounds better.

@stephentoub
Copy link
Member

Neat

Copy link
Member

@akoeplinger akoeplinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good apart from a few nits.

@EgorBo EgorBo merged commit 67d1cb6 into dotnet:master Mar 18, 2020
Comment on lines +15 to +20
/* These are not in public headers */
typedef unsigned char* (*MonoLoadAotDataFunc) (MonoAssembly *assembly, int size, void *user_data, void **out_handle);
typedef void (*MonoFreeAotDataFunc) (MonoAssembly *assembly, int size, void *user_data, void *handle);
void mono_install_load_aot_data_hook (MonoLoadAotDataFunc load_func, MonoFreeAotDataFunc free_func, void *user_data);
void mono_trace_init (void);
void mono_gc_init_finalizer_thread (void);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #33736

@steveisok steveisok mentioned this pull request Mar 21, 2020
4 tasks
monojenkins pushed a commit to monojenkins/mono that referenced this pull request Mar 24, 2020
See dotnet/runtime#33633 and https://github.com/xamarin/xamarin-macios/blob/master/runtime/exports.t4

* `mono_install_load_aot_data_hook` was already a `MONO_API`, but it was not in a public header.
  It is added to `mono/jit/mono-private-unstable.h`
* `mono_gc_init_finalizer_thread` was [used by Xamarin.iOS](https://github.com/xamarin/xamarin-macios/blob/63ab48e679716264b33af00f86c24426da1d9f97/runtime/mono-runtime.h.t4#L278) for a long time without being in any public header.  It's one of the reasons we have to compile Mono for XI with `--disable-visibility-hidden`.  Make the function a proper `MONO_API` unconditionally - but make it do nothing if the runtime is compiled without `--with-lazy-thread-creation` (the default).  It is now a public Mono API function.
* `mono_trace_init` was a `MONO_API` function in a non-public header that was already used by embedders that need to set up logger hooks.  It is now not necessary to call this before calling the logger functions to set up logger hooks such as `mono_trace_set_log_handler`
lambdageek added a commit to mono/mono that referenced this pull request Mar 24, 2020
See dotnet/runtime#33633 and https://github.com/xamarin/xamarin-macios/blob/master/runtime/exports.t4

* `mono_install_load_aot_data_hook` was already a `MONO_API`, but it was not in a public header.
  It is added to `mono/jit/mono-private-unstable.h`
* `mono_gc_init_finalizer_thread` was [used by Xamarin.iOS](https://github.com/xamarin/xamarin-macios/blob/63ab48e679716264b33af00f86c24426da1d9f97/runtime/mono-runtime.h.t4#L278) for a long time without being in any public header.  It's one of the reasons we have to compile Mono for XI with `--disable-visibility-hidden`.  Make the function a proper `MONO_API` unconditionally - but make it do nothing if the runtime is compiled without `--with-lazy-thread-creation` (the default).  It is now a public Mono API function.
* `mono_trace_init` was a `MONO_API` function in a non-public header that was already used by embedders that need to set up logger hooks.  It is now not necessary to call this before calling the logger functions to set up logger hooks such as `mono_trace_set_log_handler`

Co-authored-by: lambdageek <lambdageek@users.noreply.github.com>
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants