Skip to content

Conversation

@chamons
Copy link
Contributor

@chamons chamons commented Feb 2, 2018

- 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 addded real "Release"
configuration option
- dotnet#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 --native-strip to allow customization of behavior, as not everyone
uses app store
@monojenkins
Copy link
Collaborator

Build failure

Copy link
Contributor

@spouliot spouliot left a comment

Choose a reason for hiding this comment

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

❤️ the tests

string archToRemove = arch == "i386" ? "x86_64" : "i386";
int ret = XcodeRun ("lipo", $"{dest} -remove {archToRemove} -output {dest}");
if (ret != 0)
throw new MonoMacException (5310, true, "lipo failed with an error code '{0}'. Check build log for details.", ret);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this a new error? if so it should be documented

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I forgot.

if (ret != 0)
throw new MonoMacException (5310, true, "lipo failed with an error code '{0}'. Check build log for details.", ret);
if (name != "MonoPosixHelper")
ErrorHelper.Warning (1501, $"{name} was stripped of architecture {archToRemove} to comply with App Store restrictions. This could break exisiting codesigning signatures. Consider stripping the library with lipo or disabling with --native-strip=skip");
Copy link
Contributor

Choose a reason for hiding this comment

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

same


bool isStaticLib = real_src.EndsWith (".a", StringComparison.Ordinal);
bool isDynamicLib = real_src.EndsWith (".dylib", StringComparison.Ordinal);
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens for frameworks ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing, but something very likely should. Let me get someone in to test this case in submission to Apple.


test.Release = true;
buildOutput = TI.TestUnifiedExecutable (test).BuildOutput;
Assert.AreEqual (releaseStrips, didStrip (buildOutput), "Release lipo usage did not match expectations");
Copy link
Member

Choose a reason for hiding this comment

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

Maybe also test that the binary only has the desired architectures? We already have code to get the architectures of a binary file: https://github.com/xamarin/xamarin-macios/blob/bec116c273ab119c648522a28c3f650881ed4d9e/tests/mtouch/MTouch.cs#L3996

if (!string.IsNullOrEmpty (configuration))
buildArgs.Append ($" /property:Configuration={configuration} ");
} else
}
Copy link
Member

Choose a reason for hiding this comment

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

Style: else goes on the same line as the closing brace.

CopyFileAndRemoveReadOnly (real_src, dest);
}

Copy link
Member

Choose a reason for hiding this comment

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

Whitespace noise.

@monojenkins
Copy link
Collaborator

Build failure

@chamons
Copy link
Contributor Author

chamons commented Feb 16, 2018

I believe I've handled the current code review issues and added framework stripping.

I did not build after merging master, as a mono bump took too long before end of day. I'll check back tomorrow. Please consider re-reviewing as a lot has changed.

@monojenkins
Copy link
Collaborator

Build failure

1 similar comment
@monojenkins
Copy link
Collaborator

Build failure

Copy link
Contributor

@spouliot spouliot left a comment

Choose a reason for hiding this comment

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

Needs to discuss optimizations/docs
But otherwise it seems good :)

default:
ErrorHelper.Error (26, $"Could not parse the command line argument '-native-strip:{v}'");
break;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if that should be added in the new optimizations ? c.c. @rolfbjarne
It behaves just like them, i.e. a sane default (computed based on the project settings) and overrides for enabling and disabling it.
In any case it needs to be documented outside the errors code it introduce.

Copy link
Member

Choose a reason for hiding this comment

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

We already have two interpretations of strip: mtouch takes the arguments nostrip (to not strip IL from managed assemblies) and nosymbolstrip (to not strip native symbols from the executable). Both of these makes sense (their command-line tools are named mono-cil-strip and strip, respectively), but for this case, the work "strip" doesn't even show up in the man page for lipo.

My suggestion: --trim-architectures.

I think this could make sense to include as an optimization (it even makes sense for XI as well, since we do the same thing there, the only difference would be the default: enabled for device builds (faster deploy), and disabled for sim builds (faster build). It's never been optional for XI though).

{
static class StringExtensions
{
internal static string [] SplitLines (this string s) => s.Split (new [] { Environment.NewLine }, StringSplitOptions.None);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe tools/common/StringUtils.cs is a better place for this?

if (ret != 0)
throw new MonoMacException (5311, true, "lipo failed with an error code '{0}'. Check build log for details.", ret);
if (name != "MonoPosixHelper")
ErrorHelper.Warning (2108, $"{name} was stripped of architecture {archToRemove} to comply with App Store restrictions. This could break exisiting codesigning signatures. Consider stripping the library with lipo or disabling with --native-strip=skip");
Copy link
Member

Choose a reason for hiding this comment

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

Won't this warning show up for all libraries, independent of their original architecture(s)? You don't seem to have any logic to detect which architecture(s) the libraries had before running lipo.

That said, mtouch also does the same thing, and has code to do this without running lipo: https://github.com/xamarin/xamarin-macios/blob/96085adb66129c42e9ae8e28f44d06112f9e1896/tools/common/MachO.cs#L194-L200

the only problem is that I don't think that code can handle slices of non-standard architectures like PPC (see bug #42464).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The "obvious" thing to do here is to first write a test that says "if I'm 64-bit and i have a 64-bit library there should be no warning".

And yes, it looks like that test would fail right now. :(

default:
ErrorHelper.Error (26, $"Could not parse the command line argument '-native-strip:{v}'");
break;
}
Copy link
Member

Choose a reason for hiding this comment

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

We already have two interpretations of strip: mtouch takes the arguments nostrip (to not strip IL from managed assemblies) and nosymbolstrip (to not strip native symbols from the executable). Both of these makes sense (their command-line tools are named mono-cil-strip and strip, respectively), but for this case, the work "strip" doesn't even show up in the man page for lipo.

My suggestion: --trim-architectures.

I think this could make sense to include as an optimization (it even makes sense for XI as well, since we do the same thing there, the only difference would be the default: enabled for device builds (faster deploy), and disabled for sim builds (faster build). It's never been optional for XI though).

@chamons
Copy link
Contributor Author

chamons commented Feb 20, 2018

I've moved to --optimize=-trim-architectures instead of a new option and fixed the location of common string utils.

I'm going to work on fixing the likely every present warning w\ native libraries.

@rolfbjarne please review my optimization changes, first time I've added one.

@chamons
Copy link
Contributor Author

chamons commented Feb 22, 2018

build

@monojenkins
Copy link
Collaborator

Build failure

@monojenkins
Copy link
Collaborator

Build failure

@chamons
Copy link
Contributor Author

chamons commented Feb 23, 2018

I can reproduce them when run from the command line but not from the IDE, which is strange. In any case, looking.

@chamons chamons self-assigned this Feb 23, 2018
@chamons chamons added the do-not-merge Do not merge this pull request label Feb 23, 2018
…ly from mdb/pdb files copied

- I am uncertain why this started failing, but a number of test changes might have triggered it.
- In any case, the code was flat wrong before.
…libMonoPosixHelper.dylib will strip in Release
@monojenkins
Copy link
Collaborator

Build failure

@chamons
Copy link
Contributor Author

chamons commented Feb 23, 2018

This PR has started to turn into a monster, just like every other time I touch mmp...

A few more tests are failing locally after the last set of pushes. Looking now.

… to release/debug changes and output more failure info
@chamons
Copy link
Contributor Author

chamons commented Feb 23, 2018

Looks clean enough locally now. 🤞

@chamons chamons removed the do-not-merge Do not merge this pull request label Feb 23, 2018
@monojenkins
Copy link
Collaborator

Build failure

1 similar comment
@monojenkins
Copy link
Collaborator

Build failure

@chamons
Copy link
Contributor Author

chamons commented Feb 26, 2018

Looks like some tests are comparing strings that changed when I added a message. Fixing.

@monojenkins
Copy link
Collaborator

Build failure

@monojenkins
Copy link
Collaborator

Build failure

@chamons
Copy link
Contributor Author

chamons commented Mar 1, 2018

@chamons
Copy link
Contributor Author

chamons commented Mar 1, 2018

https://github.com/xamarin/maccore/issues/655 for the protocol failures.

@chamons chamons merged commit ca43601 into dotnet:master Mar 1, 2018
@chamons chamons deleted the xm_32_lipo branch March 1, 2018 15:36
chamons added a commit to chamons/xamarin-macios that referenced this pull request Mar 1, 2018
…ictions (dotnet#3387)

- dotnet#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
rolfbjarne pushed a commit that referenced this pull request Mar 2, 2018
…ictions (#3387) (#3633)

- #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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants