Bug 37781 - mono-4.2.1 doesnt build on s390x
Summary: mono-4.2.1 doesnt build on s390x
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: 4.2.0 (C6)
Hardware: Other Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-01-18 22:37 UTC by than
Modified: 2016-01-22 16:47 UTC (History)
5 users (show)

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 GitHub or Developer Community 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:

Description than 2016-01-18 22:37:47 UTC
i tried to build mono-4.2.1 on s390x and it fails with following errors:

Compilation succeeded - 15 warning(s)
mkdir -p -- ../../class/lib/build/
MCS     [build] mscorlib.dll
error CS1904: `612,618' is not a valid warning number
../../build/library.make:282: recipe for target '../../class/lib/build/mscorlib.dll' failed
make[8]: *** [../../class/lib/build/mscorlib.dll] Error 1
../../build/rules.make:143: recipe for target 'do-all' failed
make[7]: *** [do-all] Error 2
../build/rules.make:170: recipe for target 'all-recursive' failed
make[6]: *** [all-recursive] Error 1
build/rules.make:170: recipe for target 'all-recursive' failed
make[5]: *** [all-recursive] Error 1
Makefile:46: recipe for target 'profile-do--build--all' failed
make[4]: *** [profile-do--build--all] Error 2
Makefile:42: recipe for target 'profiles-do--all' failed
make[3]: *** [profiles-do--all] Error 2
Makefile:545: recipe for target 'all-local' failed
make[2]: *** [all-local] Error 2
make[2]: Leaving directory '/home/than/rpmbuild/BUILD/mono-4.2.1/runtime'
Makefile:516: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/than/rpmbuild/BUILD/mono-4.2.1'
Makefile:445: recipe for target 'all' failed
make: *** [all] Error 2

This issue does only happen on s390 arch,
Comment 1 Neale Ferguson 2016-01-19 17:18:08 UTC
I have encountered this on a 6.5 system. This is on the same machine as the Mono Jenkins bot which does build successfully. I have not been able to determine why this is happening and more to the point why it works in one account and not another (i.e. not even on different machines). I raised this on the list some months ago but got no suggestions.
Comment 2 than 2016-01-19 17:28:30 UTC
Ferguson, this issue doesn't happen in mono-4.0.5.
Comment 3 Neale Ferguson 2016-01-19 18:08:34 UTC
Building from today's head on the same account I now get:

MCS     [build] mscorlib.dll
Assembly/AssemblyInfo.cs(33,5): error CS8025: Parsing error
System/AndroidPlatform.cs(66,246): error CS1525: Unexpected symbol `end-of-file', expecting `end-of-file'
System/Console.iOS.cs(127,246): error CS1525: Unexpected symbol `end-of-file', expecting `end-of-file'
System/Guid.MonoTouch.cs(24,253): error CS1525: Unexpected symbol `end-of-file', expecting `end-of-file'
System/TimeZoneInfo.Android.cs(737,246): error CS1525: Unexpected symbol `end-of-file', expecting `end-of-file'
System/TimeZoneInfo.MonoTouch.cs(109,246): error CS1525: Unexpected symbol `end-of-file', expecting `end-of-file'
System.Globalization/RegionInfo.MonoTouch.cs(54,246): error CS1525: Unexpected symbol `end-of-file', expecting `end-of-file'
System.IO/LogcatTextWriter.cs(80,246): error CS1525: Unexpected symbol `end-of-file', expecting `end-of-file'
System.Security/SecurityManager_mobile.cs(215,246): error CS1525: Unexpected symbol `end-of-file', expecting `end-of-file'
System.Security.Cryptography/CryptoConfig.fullaot.cs(239,246): error CS1525: Unexpected symbol `end-of-file', expecting `end-of-file'
../../../external/referencesource/mscorlib/system/resources/__hresults.cs(26,246): error CS1525: Unexpected symbol `end-of-file', expecting `end-of-file'
../../../external/referencesource/mscorlib/system/resources/looselylinkedresourcereference.cs(89,246): error CS1525: Unexpected symbol `end-of-file', expecting `end-of-file'
Comment 4 than 2016-01-20 14:31:27 UTC
yes, i got the exactly the same errors when building from mono-4.3.2-branch.
Comment 5 Neale Ferguson 2016-01-21 17:58:18 UTC
What level of gcc are you running?
Comment 6 Neale Ferguson 2016-01-21 19:16:33 UTC
It appears mono is not initializing character arrays. For example, when parsing strings and splitting them based on an array of separator characters only the first element of the array is being initialized.

With this array:

static readonly char[] numeric_value_separator = { ';', ',', ' ' };

When each element is being accessed only the 1st has a non-null value. The other two elements are present but are 0x0000.
Comment 7 Neale Ferguson 2016-01-21 22:50:53 UTC
Try this:

--- a/mono/metadata/icall.c
+++ b/mono/metadata/icall.c
@@ -823,10 +823,10 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoAr
 #define SWAP(n) {\
        guint ## n *data = (guint ## n *) mono_array_addr (array, char, 0); \
        guint ## n *src = (guint ## n *) field_data; \
-       guint ## n *end = (guint ## n *)((char*)src + size); \
+       int i;  \
-       for (; src < end; data++, src++) { \
-               *data = read ## n (src); \
+       for (i = 0; i < (size / sizeof(guint ## n)); i++) { \
+               data[i] = read ## n (&src[i]);  \
        } \
There seems to be an issue with the compiler. Out of curiosity what level of gcc are you using?
Comment 8 Neale Ferguson 2016-01-22 03:42:57 UTC
PR 2488 merged into master
Comment 9 Alexander Köplinger [MSFT] 2016-01-22 12:38:22 UTC
Neale: with the PR merged we seem to be getting now the exact same error on the older gcc:


So now the question is if you can find a workaround that works on both :)
Comment 10 than 2016-01-22 13:38:18 UTC
Fergusson, i tried the above workaround from comment 7, it really fixes the reported build issue on s390x. I have used gcc-5.1.1 to build mono. With the same gcc-5.1.1 version i could build 4.0.5 without any problem.
Comment 11 than 2016-01-22 13:41:18 UTC
Köplinger, it seems the errors from comment 3 is caused by this commit

commit fb11d2b71d8f29160353e33415f9f67177980804
Author: Marek Safar <marek.safar@gmail.com>
Date:   Mon Aug 31 14:14:51 2015 +0200

    [mcs] Don't report error for warnings which are not intended to be compiler warnings. Fixes #

try to to revert this, it should build fine with the workaround from comment 7
Comment 12 Neale Ferguson 2016-01-22 15:55:37 UTC
Updated patch so that it now works with 4.3.4 and 4.4.7. PR 2494 merged.
Comment 13 Alexander Köplinger [MSFT] 2016-01-22 16:47:02 UTC
Confirmed it builds now on both Jenkins workers with gcc 4.3.4 and 4.4.7. Thanks Neale!