Bug 39452 - mmp does not adjust native framework ID before linking
Summary: mmp does not adjust native framework ID before linking
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: mmp ()
Version: 2.8.0 (C7)
Hardware: PC Mac OS
: High normal
Target Milestone: master
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2016-03-08 16:56 UTC by Aaron Bockover [MSFT]
Modified: 2016-08-18 20:24 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Aaron Bockover [MSFT] 2016-03-08 16:56:04 UTC
The new support for referencing native frameworks is nearly usable!

However, a native framework may have any sort of arbitrary ID. For example, the official ChromiumEmbeddedFramework.framework has an ID of @executable_path/ChromiumEmbeddedFramework.

Assuming that on disk the "source" ChromiumEmbeddedFramework binary is at:

  path/to/ChromiumEmbeddedFrameworkParentDir/ChromiumEmbeddedFramework.framework/ChromiumEmbeddedFramework

And if we run `otool -L` against it we can see its ID is (first line of the output):

  @executable_path/ChromiumEmbeddedFramework

When mmp links the framework into the main app executable, it does this:

  clang -F path/to/ChromiumEmbeddedFrameworkParentDir -framework ChromiumEmbeddedFramework

Which results in the native app executable referencing the framework at:

  @executable_path/ChromiumEmbeddedFramework

HOWEVER, the framework is copied into the app bundle into Contents/Frameworks/ChromiumEmbeddedFramework.framework, so the above path is invalid and will result in a native crash upon startup.

I believe the steps mmp should take are:

  1. copy the framework into the app bundle (currently behaving correctly)

  2. adjust the ID of the copied framework binary:
     install_name_tool -id '@loader_path/../Frameworks/ChromiumEmbeddedFramework.framework/ChromiumEmbeddedFramework' 'bin/Debug/MyApp.app/Contents/Frameworks/ChromiumEmbeddedFramework.framework/ChromiumEmbeddedFramework'

  3. link with clang:
     clang -F bin/Debug/MyApp.app/Contents/Frameworks -framework ChromiumEmbeddedFramework

Note that we add step (2) and modify the framework binary that has already been copied into the bundle by step (1). You do not want to modify the framework as specified as the native reference (the "source" framework).

Step (3) is adjusted to link against the copied and ID-remapped binary, and not the "source" framework.
Comment 1 Chris Hamons 2016-03-08 16:57:33 UTC
In talking to Aaron, this is a nice to have but not requires for C7 to go out. Since we're close to freeze, punting for now.
Comment 2 Chris Hamons 2016-08-18 20:24:54 UTC
I believe this is fixed in https://github.com/xamarin/xamarin-macios/commit/08ba6a7af71acedbf7e713e85d2789ebc64759eb