Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.

Conversation

@sergign60
Copy link
Contributor

@sergign60 sergign60 commented Feb 22, 2017

This pull request contains some fixes for test cross building on arm32 systems.

There are several problems:

  1. Some linux on arm does not give information about processor cache sizes. There are no the directories /sys/devices/system/cpu/cpu*/cache and lscpu does not show this info also. I've checked out for example
    Linux raspberrypi 4.1.19-v7+ Remove Encoding workaround #858 SMP armv7l GNU/Linux and
    Linux odroid 4.9.6 Add .gitattributes and .gitignore files #3 SMP PREEMPT armv7l armv7l armv7l GNU/Linux
  2. There are no implementation for src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunHelperNode.cs: EmitCode. After I comment throw Exception in this method the issue [arm32 unix] The test Hello fails on arm32 because of difference between initializing and using structures #2780 disappears so it can be closed if this pull request is accepted
  3. There is another issue with the Hello test on arm32 about string processing. It is under investigation.

@dnfclas
Copy link

dnfclas commented Feb 22, 2017

Hi @sergign60, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

@sergign60
Copy link
Contributor Author

CC: @jkotas @Dmitri-Botcharnikov

switch (os)
{
case TargetOS.Windows:
case TargetOS.Linux:
Copy link
Member

Choose a reason for hiding this comment

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

ARM calling convention is same on all OSes. It would be better to delete this switch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jkotas changed

</ItemGroup>

<ItemGroup>
<IlsArg Include="--targetarch=$(Platform)" />
Copy link
Member

Choose a reason for hiding this comment

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

IlsArg ?

Copy link
Contributor Author

@sergign60 sergign60 Feb 22, 2017

Choose a reason for hiding this comment

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

@jkotas
of course it's misprinting. I've tested 'IlcArg'

if (g_cbLargestOnDieCache == 0)
{
if ((strncmp(cpuEntry->d_name, "cpu", 3) == 0) && isdigit(cpuEntry->d_name[3]))
DIR* cpuDir = opendir("/sys/devices/system/cpu");
Copy link
Member

Choose a reason for hiding this comment

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

@janvorli I do not see a similar logic in CoreCLR. Is there a good reason for having it in CoreRT?

Copy link
Member

Choose a reason for hiding this comment

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

This additional logic theoretically enables getting cache size on non-intel processors (intel ones should be handled by the sysconf stuff).
But I am not sure if the /sys/devices/system/cpu contains cache details on other architectures at all. On my Raspberry Pi 3, both with aarch64 and arm32 Linux distros, the cache details are not in there and I remember that @sdmaclea said that on his aarch64 Linux device, there were no cache details either.
@sergign60 are these present on your arm32 Linux distro / device?

Copy link
Contributor Author

@sergign60 sergign60 Feb 24, 2017

Choose a reason for hiding this comment

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

@janvorli I've written about it above - two arm-based systems
Linux raspberrypi 4.1.19-v7+ #858 SMP armv7l GNU/Linux and
Linux odroid 4.9.6 #3 SMP PREEMPT armv7l armv7l armv7l GNU/Linux
that I've checked out doesn't have this information. I guess that one of the possible and simplest way is to include into corert the table with info about arm processors and get out it from this table.

Copy link
Member

Choose a reason for hiding this comment

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

@janvorli Should we delete this parsing of sys/devices/system/cpu then?

Copy link
Member

Choose a reason for hiding this comment

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

I would recommend deleting it. We can introduce it in the future if we support targets that provide this information.

Copy link
Member

Choose a reason for hiding this comment

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

@sergign60 Could you please do it as part of this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jkotas @janvorli Should I close parsing sys/devices/system/cpu for arm processors only?

_targetArchitecture = TargetArchitecture.ARMEL;
else if (_targetArchitectureStr.Equals("arm64"))
_targetArchitecture = TargetArchitecture.ARM64;
else
Copy link
Member

Choose a reason for hiding this comment

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

This should be command line exception with message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jkotas changed

// Set target Architecture and OS
//
if (_targetArchitectureStr != null)
{
Copy link
Member

Choose a reason for hiding this comment

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

It maybe nice to do the comparisons case-insensitive for convenience. _targetArchitectureStr.Equals("x86", StringComparison.OrdinalIgnoreCase)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jkotas added

@jkotas
Copy link
Member

jkotas commented Feb 22, 2017

src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/Target_ARM/ARMReadyToRunHelperNode.cs:EmitCode.

Are you hitting this method with CppCodeGen? This method should not be called with CppCodeGen at all.

@sergign60
Copy link
Contributor Author

@jkotas
the mistake mentioned by me arises when

       IlcCompile:
         Creating directory "/home/signatov/CORERT/corert/tests/src/Simple/Hello/obj/Debug/armel/native/".
         "/home/signatov/CORERT/corert/tests/../bin/Product/Linux.armel.Debug/packaging/publish1/corerun" "/home/signatov/CORERT/corert/tests/../bin/Product/Linux.armel.Debug/packaging/publish1/ilc.dll" @"/home/signatov/CORERT/corert/tests/src/Simple/Hello/obj/Debug/armel/native/Hello.ilc.rsp"
         
         Unhandled Exception: System.NotImplementedException: The method or operation is not implemented.
            at ILCompiler.DependencyAnalysis.ReadyToRunHelperNode.EmitCode(NodeFactory factory, ARMEmitter& encoder, Boolean relocsOnly)
            at ILCompiler.DependencyAnalysis.AssemblyStubNode.GetData(NodeFactory factory, Boolean relocsOnly)
            at ILCompiler.DependencyAnalysis.ObjectNode.GetStaticDependencies(NodeFactory factory)
            at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1 node)
            at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependencies(DependencyNodeCore`1 node)
            at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack()
            at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes()
            at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.get_MarkedNodeList()
            at ILCompiler.CppCodegenCompilation.CompileInternal(String outputFile)
            at ILCompiler.Compilation.ILCompiler.ICompilation.Compile(String outputFile)
            at ILCompiler.Program.Run(String[] args)
            at ILCompiler.Program.Main(String[] args)
         Aborted (core dumped)```

@jkotas
Copy link
Member

jkotas commented Feb 22, 2017

@MichalStrehovsky We end up creating AssembyStubNodes during CppCodeGen. Where would be the best place to cut it off?

@MichalStrehovsky
Copy link
Member

@MichalStrehovsky We end up creating AssembyStubNodes during CppCodeGen. Where would be the best place to cut it off?

This is two things (both of the brought in from EETypeNode):

  • Unboxing stubs referenced from vtables of valuetypes. AFAIK we don't have an implementation of the unboxing stubs for CppCodegen, so we end up with the machine code stub that is probably thrown away. This is done in CppCodegenFactory.cs around the // TODO: this is wrong line.
  • Virtual call R2R helpers. EETypeNode currently drags these in based on seeing a VirtualMethodUse for these. They end up being unused for CppCodegen. We probably need a better factoring.

I could try to come up with a way to avoid this (it would be a general improvement), but it might be easier to just not throw from the stubs and have them generate machine code that crashes at runtime.

@jkotas
Copy link
Member

jkotas commented Feb 27, 2017

LGTM. Thank!

@jkotas jkotas merged commit 3e057ae into dotnet:master Feb 27, 2017
@sergign60 sergign60 deleted the arm_build branch February 27, 2017 17:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants