Skip to content

Failing tests on macOS(aarch64) #2381

@Fusioon

Description

@Fusioon

There are 4 tests that currently fail:

ERROR: Test failed. Assert failed: str == "Test 223 2.2 3.3" at line 82 in /Users/fusion/Dev/Beef/IDEHelper/Tests/src/VarArgs.bf

ERROR: Test failed. Assert failed: ca.mA == 1123 at line 410 in /Users/fusion/Dev/Beef/IDEHelper/Tests/src/Reflection.bf

Failed test 'Tests.Lambdas.TestStructRetCapture' defined at line 103:22 in /Users/fusion/Dev/Beef/IDEHelper/Tests/src/Lambdas.bf

ERROR: Test failed. Assert failed: Func0W(12, sw) == 312 at line 447 in /Users/fusion/Dev/Beef/IDEHelper/Tests/src/Interop.bf
  • I believe the Interop issue is related to arm64 HFA (I haven't looked at ASM yet)

  • TestStructRetCapture - just crashes when returning StructA and doesn't seem to be related to local capture since it does crash when it's just delegate StructA() myTest = scope () => { return StructA(5); }

  • VarArgs - on macOS aarch64 they should be handled the same as on windows (VarList should be just void*)

  • Reflection - seems to be problem with returns, Invoke currently just appends the return value as pointer to arg list
    This can be fixed by adding this piece of code to MethodInfo.bf Invoke method where return is handled

#if BF_MACHINE_AARCH64
				let ffiRetElements = scope:: List<FFIType*>(8);
				for (let fi in retType.GetFields(.Instance | .DeclaredOnly))
				{
					let ffiType = GetFFIType!::(fi.FieldType);
					ffiRetElements.Add(ffiType);
				}
				ffiRetElements.Add(null);
				ffiRetType = scope::FFIType(0, 0, .Struct);
				ffiRetType.mElements = ffiRetElements.Ptr;
#else
				ffiRetType = &FFIType.Void;
				ffiParamList.Add(&FFIType.Pointer);
				ffiArgList.Add(&variantData);
				retData = &unusedRetVal;
#endif

But the return value is still wrong because libffi reads the values from register x0, x1 but beef writes the return value at x8, x10
Clang does use x0, x1 when returning struct with 2 int64 values: https://godbolt.org/z/459r5b5Y4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions