gnustep / libobjc2

Objective-C runtime library intended for use with Clang.
http://www.gnustep.org/
MIT License
426 stars 116 forks source link

Initial RISC-V 64-bit Support #261

Closed hmelder closed 6 months ago

hmelder commented 6 months ago

This pull request adds RISC-V 64-bit (rv64) support to libobjc2. This includes:

All unit tests run successfully on my test machine, and I am planning to run the libs-base testsuite as well.

Things to consider:

Test Results ## Test Machine ```sh OS: Debian GNU/Linux trixie/sid riscv64 Host: riscv-virtio (qemu) Kernel: 6.6.8-riscv64 Clang: Debian clang version 16.0.6 ``` ## CMake ```sh cmake -DTESTS=1 -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_LINKER=ld.lld -GNinja -DCMAKE_BUILD_TYPE=Debug .. ``` ## Test Results ```sh Test project /root/libobjc2/build Start 1: alias 1/186 Test #1: alias ........................................... Passed 0.11 sec Start 2: alias_optimised 2/186 Test #2: alias_optimised ................................. Passed 0.10 sec Start 3: alias_legacy 3/186 Test #3: alias_legacy .................................... Passed 0.10 sec Start 4: alias_legacy_optimised 4/186 Test #4: alias_legacy_optimised .......................... Passed 0.10 sec Start 5: alignTest 5/186 Test #5: alignTest ....................................... Passed 0.10 sec Start 6: alignTest_optimised 6/186 Test #6: alignTest_optimised ............................. Passed 0.10 sec Start 7: alignTest_legacy 7/186 Test #7: alignTest_legacy ................................ Passed 0.10 sec Start 8: alignTest_legacy_optimised 8/186 Test #8: alignTest_legacy_optimised ...................... Passed 0.10 sec Start 9: AllocatePair 9/186 Test #9: AllocatePair .................................... Passed 0.10 sec Start 10: AllocatePair_optimised 10/186 Test #10: AllocatePair_optimised .......................... Passed 0.10 sec Start 11: AllocatePair_legacy 11/186 Test #11: AllocatePair_legacy ............................. Passed 0.10 sec Start 12: AllocatePair_legacy_optimised 12/186 Test #12: AllocatePair_legacy_optimised ................... Passed 0.10 sec Start 13: AssociatedObject 13/186 Test #13: AssociatedObject ................................ Passed 0.10 sec Start 14: AssociatedObject_optimised 14/186 Test #14: AssociatedObject_optimised ...................... Passed 0.10 sec Start 15: AssociatedObject_legacy 15/186 Test #15: AssociatedObject_legacy ......................... Passed 0.10 sec Start 16: AssociatedObject_legacy_optimised 16/186 Test #16: AssociatedObject_legacy_optimised ............... Passed 0.10 sec Start 17: AssociatedObject2 17/186 Test #17: AssociatedObject2 ............................... Passed 0.11 sec Start 18: AssociatedObject2_optimised 18/186 Test #18: AssociatedObject2_optimised ..................... Passed 0.10 sec Start 19: AssociatedObject2_legacy 19/186 Test #19: AssociatedObject2_legacy ........................ Passed 0.10 sec Start 20: AssociatedObject2_legacy_optimised 20/186 Test #20: AssociatedObject2_legacy_optimised .............. Passed 0.10 sec Start 21: BlockImpTest 21/186 Test #21: BlockImpTest .................................... Passed 0.10 sec Start 22: BlockImpTest_optimised 22/186 Test #22: BlockImpTest_optimised .......................... Passed 0.10 sec Start 23: BlockImpTest_legacy 23/186 Test #23: BlockImpTest_legacy ............................. Passed 0.10 sec Start 24: BlockImpTest_legacy_optimised 24/186 Test #24: BlockImpTest_legacy_optimised ................... Passed 0.11 sec Start 25: BlockTest_arc 25/186 Test #25: BlockTest_arc ................................... Passed 0.10 sec Start 26: BlockTest_arc_optimised 26/186 Test #26: BlockTest_arc_optimised ......................... Passed 0.10 sec Start 27: ConstantString 27/186 Test #27: ConstantString .................................. Passed 0.10 sec Start 28: ConstantString_optimised 28/186 Test #28: ConstantString_optimised ........................ Passed 0.10 sec Start 29: ConstantString_legacy 29/186 Test #29: ConstantString_legacy ........................... Passed 0.10 sec Start 30: ConstantString_legacy_optimised 30/186 Test #30: ConstantString_legacy_optimised ................. Passed 0.10 sec Start 31: Category 31/186 Test #31: Category ........................................ Passed 0.10 sec Start 32: Category_optimised 32/186 Test #32: Category_optimised .............................. Passed 0.10 sec Start 33: Category_legacy 33/186 Test #33: Category_legacy ................................. Passed 0.10 sec Start 34: Category_legacy_optimised 34/186 Test #34: Category_legacy_optimised ....................... Passed 0.10 sec Start 35: ExceptionTest 35/186 Test #35: ExceptionTest ................................... Passed 0.10 sec Start 36: ExceptionTest_optimised 36/186 Test #36: ExceptionTest_optimised ......................... Passed 0.10 sec Start 37: ExceptionTest_legacy 37/186 Test #37: ExceptionTest_legacy ............................ Passed 0.10 sec Start 38: ExceptionTest_legacy_optimised 38/186 Test #38: ExceptionTest_legacy_optimised .................. Passed 0.10 sec Start 39: FastARC 39/186 Test #39: FastARC ......................................... Passed 0.10 sec Start 40: FastARC_optimised 40/186 Test #40: FastARC_optimised ............................... Passed 0.10 sec Start 41: FastARC_legacy 41/186 Test #41: FastARC_legacy .................................. Passed 0.10 sec Start 42: FastARC_legacy_optimised 42/186 Test #42: FastARC_legacy_optimised ........................ Passed 0.10 sec Start 43: FastARCPool 43/186 Test #43: FastARCPool ..................................... Passed 0.10 sec Start 44: FastARCPool_optimised 44/186 Test #44: FastARCPool_optimised ........................... Passed 0.10 sec Start 45: FastARCPool_legacy 45/186 Test #45: FastARCPool_legacy .............................. Passed 0.10 sec Start 46: FastARCPool_legacy_optimised 46/186 Test #46: FastARCPool_legacy_optimised .................... Passed 0.10 sec Start 47: FastRefCount 47/186 Test #47: FastRefCount .................................... Passed 0.19 sec Start 48: FastRefCount_optimised 48/186 Test #48: FastRefCount_optimised .......................... Passed 0.16 sec Start 49: FastRefCount_legacy 49/186 Test #49: FastRefCount_legacy ............................. Passed 0.11 sec Start 50: FastRefCount_legacy_optimised 50/186 Test #50: FastRefCount_legacy_optimised ................... Passed 0.10 sec Start 51: Forward 51/186 Test #51: Forward ......................................... Passed 0.10 sec Start 52: Forward_optimised 52/186 Test #52: Forward_optimised ............................... Passed 0.10 sec Start 53: Forward_legacy 53/186 Test #53: Forward_legacy .................................. Passed 0.10 sec Start 54: Forward_legacy_optimised 54/186 Test #54: Forward_legacy_optimised ........................ Passed 0.10 sec Start 55: ManyManySelectors 55/186 Test #55: ManyManySelectors ............................... Passed 22.42 sec Start 56: ManyManySelectors_optimised 56/186 Test #56: ManyManySelectors_optimised ..................... Passed 22.63 sec Start 57: ManyManySelectors_legacy 57/186 Test #57: ManyManySelectors_legacy ........................ Passed 22.95 sec Start 58: ManyManySelectors_legacy_optimised 58/186 Test #58: ManyManySelectors_legacy_optimised .............. Passed 22.60 sec Start 59: NestedExceptions 59/186 Test #59: NestedExceptions ................................ Passed 0.11 sec Start 60: NestedExceptions_optimised 60/186 Test #60: NestedExceptions_optimised ...................... Passed 0.10 sec Start 61: NestedExceptions_legacy 61/186 Test #61: NestedExceptions_legacy ......................... Passed 0.11 sec Start 62: NestedExceptions_legacy_optimised 62/186 Test #62: NestedExceptions_legacy_optimised ............... Passed 0.10 sec Start 63: PropertyAttributeTest 63/186 Test #63: PropertyAttributeTest ........................... Passed 0.10 sec Start 64: PropertyAttributeTest_optimised 64/186 Test #64: PropertyAttributeTest_optimised ................. Passed 0.10 sec Start 65: PropertyAttributeTest_legacy 65/186 Test #65: PropertyAttributeTest_legacy .................... Passed 0.10 sec Start 66: PropertyAttributeTest_legacy_optimised 66/186 Test #66: PropertyAttributeTest_legacy_optimised .......... Passed 0.10 sec Start 67: ProtocolExtendedProperties 67/186 Test #67: ProtocolExtendedProperties ...................... Passed 0.10 sec Start 68: ProtocolExtendedProperties_optimised 68/186 Test #68: ProtocolExtendedProperties_optimised ............ Passed 0.10 sec Start 69: ProtocolExtendedProperties_legacy 69/186 Test #69: ProtocolExtendedProperties_legacy ............... Passed 0.10 sec Start 70: ProtocolExtendedProperties_legacy_optimised 70/186 Test #70: ProtocolExtendedProperties_legacy_optimised ..... Passed 0.10 sec Start 71: PropertyIntrospectionTest 71/186 Test #71: PropertyIntrospectionTest ....................... Passed 0.10 sec Start 72: PropertyIntrospectionTest_optimised 72/186 Test #72: PropertyIntrospectionTest_optimised ............. Passed 0.10 sec Start 73: PropertyIntrospectionTest_legacy 73/186 Test #73: PropertyIntrospectionTest_legacy ................ Passed 0.10 sec Start 74: PropertyIntrospectionTest_legacy_optimised 74/186 Test #74: PropertyIntrospectionTest_legacy_optimised ...... Passed 0.10 sec Start 75: ProtocolCreation 75/186 Test #75: ProtocolCreation ................................ Passed 0.10 sec Start 76: ProtocolCreation_optimised 76/186 Test #76: ProtocolCreation_optimised ...................... Passed 0.10 sec Start 77: ProtocolCreation_legacy 77/186 Test #77: ProtocolCreation_legacy ......................... Passed 0.10 sec Start 78: ProtocolCreation_legacy_optimised 78/186 Test #78: ProtocolCreation_legacy_optimised ............... Passed 0.10 sec Start 79: ResurrectInDealloc_arc 79/186 Test #79: ResurrectInDealloc_arc .......................... Passed 0.10 sec Start 80: ResurrectInDealloc_arc_optimised 80/186 Test #80: ResurrectInDealloc_arc_optimised ................ Passed 0.10 sec Start 81: RuntimeTest 81/186 Test #81: RuntimeTest ..................................... Passed 0.11 sec Start 82: RuntimeTest_optimised 82/186 Test #82: RuntimeTest_optimised ........................... Passed 0.10 sec Start 83: RuntimeTest_legacy 83/186 Test #83: RuntimeTest_legacy .............................. Passed 0.11 sec Start 84: RuntimeTest_legacy_optimised 84/186 Test #84: RuntimeTest_legacy_optimised .................... Passed 0.10 sec Start 85: SuperMethodMissing 85/186 Test #85: SuperMethodMissing .............................. Passed 0.10 sec Start 86: SuperMethodMissing_optimised 86/186 Test #86: SuperMethodMissing_optimised .................... Passed 0.10 sec Start 87: SuperMethodMissing_legacy 87/186 Test #87: SuperMethodMissing_legacy ....................... Passed 0.10 sec Start 88: SuperMethodMissing_legacy_optimised 88/186 Test #88: SuperMethodMissing_legacy_optimised ............. Passed 0.10 sec Start 89: WeakBlock_arc 89/186 Test #89: WeakBlock_arc ................................... Passed 0.10 sec Start 90: WeakBlock_arc_optimised 90/186 Test #90: WeakBlock_arc_optimised ......................... Passed 0.10 sec Start 91: WeakRefLoad 91/186 Test #91: WeakRefLoad ..................................... Passed 0.10 sec Start 92: WeakRefLoad_optimised 92/186 Test #92: WeakRefLoad_optimised ........................... Passed 0.10 sec Start 93: WeakRefLoad_legacy 93/186 Test #93: WeakRefLoad_legacy .............................. Passed 0.10 sec Start 94: WeakRefLoad_legacy_optimised 94/186 Test #94: WeakRefLoad_legacy_optimised .................... Passed 0.10 sec Start 95: WeakReferences_arc 95/186 Test #95: WeakReferences_arc .............................. Passed 29.39 sec Start 96: WeakReferences_arc_optimised 96/186 Test #96: WeakReferences_arc_optimised .................... Passed 27.22 sec Start 97: WeakImportClass 97/186 Test #97: WeakImportClass ................................. Passed 0.10 sec Start 98: WeakImportClass_optimised 98/186 Test #98: WeakImportClass_optimised ....................... Passed 0.10 sec Start 99: WeakImportClass_legacy 99/186 Test #99: WeakImportClass_legacy .......................... Passed 0.10 sec Start 100: WeakImportClass_legacy_optimised 100/186 Test #100: WeakImportClass_legacy_optimised ................ Passed 0.10 sec Start 101: ivar_arc 101/186 Test #101: ivar_arc ........................................ Passed 0.10 sec Start 102: ivar_arc_optimised 102/186 Test #102: ivar_arc_optimised .............................. Passed 0.10 sec Start 103: ivar_atomic 103/186 Test #103: ivar_atomic ..................................... Passed 0.10 sec Start 104: ivar_atomic_optimised 104/186 Test #104: ivar_atomic_optimised ........................... Passed 0.10 sec Start 105: ivar_atomic_legacy 105/186 Test #105: ivar_atomic_legacy .............................. Passed 0.10 sec Start 106: ivar_atomic_legacy_optimised 106/186 Test #106: ivar_atomic_legacy_optimised .................... Passed 0.10 sec Start 107: IVarOverlap 107/186 Test #107: IVarOverlap ..................................... Passed 0.10 sec Start 108: IVarOverlap_optimised 108/186 Test #108: IVarOverlap_optimised ........................... Passed 0.10 sec Start 109: IVarOverlap_legacy 109/186 Test #109: IVarOverlap_legacy .............................. Passed 0.10 sec Start 110: IVarOverlap_legacy_optimised 110/186 Test #110: IVarOverlap_legacy_optimised .................... Passed 0.10 sec Start 111: IVarSuperclassOverlap 111/186 Test #111: IVarSuperclassOverlap ........................... Passed 0.10 sec Start 112: IVarSuperclassOverlap_optimised 112/186 Test #112: IVarSuperclassOverlap_optimised ................. Passed 0.10 sec Start 113: IVarSuperclassOverlap_legacy 113/186 Test #113: IVarSuperclassOverlap_legacy .................... Passed 0.10 sec Start 114: IVarSuperclassOverlap_legacy_optimised 114/186 Test #114: IVarSuperclassOverlap_legacy_optimised .......... Passed 0.10 sec Start 115: objc_msgSend 115/186 Test #115: objc_msgSend .................................... Passed 0.10 sec Start 116: objc_msgSend_optimised 116/186 Test #116: objc_msgSend_optimised .......................... Passed 0.10 sec Start 117: objc_msgSend_legacy 117/186 Test #117: objc_msgSend_legacy ............................. Passed 0.10 sec Start 118: objc_msgSend_legacy_optimised 118/186 Test #118: objc_msgSend_legacy_optimised ................... Passed 0.10 sec Start 119: msgInterpose 119/186 Test #119: msgInterpose .................................... Passed 0.10 sec Start 120: msgInterpose_optimised 120/186 Test #120: msgInterpose_optimised .......................... Passed 0.10 sec Start 121: msgInterpose_legacy 121/186 Test #121: msgInterpose_legacy ............................. Passed 0.10 sec Start 122: msgInterpose_legacy_optimised 122/186 Test #122: msgInterpose_legacy_optimised ................... Passed 0.10 sec Start 123: NilException 123/186 Test #123: NilException .................................... Passed 0.10 sec Start 124: NilException_optimised 124/186 Test #124: NilException_optimised .......................... Passed 0.10 sec Start 125: NilException_legacy 125/186 Test #125: NilException_legacy ............................. Passed 0.10 sec Start 126: NilException_legacy_optimised 126/186 Test #126: NilException_legacy_optimised ................... Passed 0.10 sec Start 127: MethodArguments 127/186 Test #127: MethodArguments ................................. Passed 0.10 sec Start 128: MethodArguments_optimised 128/186 Test #128: MethodArguments_optimised ....................... Passed 0.10 sec Start 129: MethodArguments_legacy 129/186 Test #129: MethodArguments_legacy .......................... Passed 0.10 sec Start 130: MethodArguments_legacy_optimised 130/186 Test #130: MethodArguments_legacy_optimised ................ Passed 0.10 sec Start 131: zeroSizedIVar 131/186 Test #131: zeroSizedIVar ................................... Passed 0.10 sec Start 132: zeroSizedIVar_optimised 132/186 Test #132: zeroSizedIVar_optimised ......................... Passed 0.10 sec Start 133: zeroSizedIVar_legacy 133/186 Test #133: zeroSizedIVar_legacy ............................ Passed 0.10 sec Start 134: zeroSizedIVar_legacy_optimised 134/186 Test #134: zeroSizedIVar_legacy_optimised .................. Passed 0.10 sec Start 135: exchange 135/186 Test #135: exchange ........................................ Passed 0.10 sec Start 136: exchange_optimised 136/186 Test #136: exchange_optimised .............................. Passed 0.10 sec Start 137: exchange_legacy 137/186 Test #137: exchange_legacy ................................. Passed 0.10 sec Start 138: exchange_legacy_optimised 138/186 Test #138: exchange_legacy_optimised ....................... Passed 0.10 sec Start 139: hash_table_delete 139/186 Test #139: hash_table_delete ............................... Passed 0.10 sec Start 140: hash_table_delete_optimised 140/186 Test #140: hash_table_delete_optimised ..................... Passed 0.10 sec Start 141: hash_table_delete_legacy 141/186 Test #141: hash_table_delete_legacy ........................ Passed 0.10 sec Start 142: hash_table_delete_legacy_optimised 142/186 Test #142: hash_table_delete_legacy_optimised .............. Passed 0.10 sec Start 143: hash_test 143/186 Test #143: hash_test ....................................... Passed 19.43 sec Start 144: hash_test_optimised 144/186 Test #144: hash_test_optimised ............................. Passed 1.19 sec Start 145: hash_test_legacy 145/186 Test #145: hash_test_legacy ................................ Passed 24.99 sec Start 146: hash_test_legacy_optimised 146/186 Test #146: hash_test_legacy_optimised ...................... Passed 1.22 sec Start 147: setSuperclass 147/186 Test #147: setSuperclass ................................... Passed 0.11 sec Start 148: setSuperclass_optimised 148/186 Test #148: setSuperclass_optimised ......................... Passed 0.11 sec Start 149: setSuperclass_legacy 149/186 Test #149: setSuperclass_legacy ............................ Passed 0.11 sec Start 150: setSuperclass_legacy_optimised 150/186 Test #150: setSuperclass_legacy_optimised .................. Passed 0.11 sec Start 151: BoxedForeignException 151/186 Test #151: BoxedForeignException ........................... Passed 0.10 sec Start 152: BoxedForeignException_optimised 152/186 Test #152: BoxedForeignException_optimised ................. Passed 0.10 sec Start 153: BoxedForeignException_legacy 153/186 Test #153: BoxedForeignException_legacy .................... Passed 0.10 sec Start 154: BoxedForeignException_legacy_optimised 154/186 Test #154: BoxedForeignException_legacy_optimised .......... Passed 0.10 sec Start 155: ForeignException 155/186 Test #155: ForeignException ................................ Passed 0.10 sec Start 156: ForeignException_optimised 156/186 Test #156: ForeignException_optimised ...................... Passed 0.10 sec Start 157: ForeignException_legacy 157/186 Test #157: ForeignException_legacy ......................... Passed 0.10 sec Start 158: ForeignException_legacy_optimised 158/186 Test #158: ForeignException_legacy_optimised ............... Passed 0.10 sec Start 159: ARCTest_arc 159/186 Test #159: ARCTest_arc ..................................... Passed 0.10 sec Start 160: ARCTest_arc_optimised 160/186 Test #160: ARCTest_arc_optimised ........................... Passed 0.10 sec Start 161: PropertyIntrospectionTest2_arc 161/186 Test #161: PropertyIntrospectionTest2_arc .................. Passed 0.11 sec Start 162: PropertyIntrospectionTest2_arc_optimised 162/186 Test #162: PropertyIntrospectionTest2_arc_optimised ........ Passed 0.11 sec Start 163: UnexpectedException 163/186 Test #163: UnexpectedException ............................. Passed 0.10 sec Start 164: UnexpectedException_optimised 164/186 Test #164: UnexpectedException_optimised ................... Passed 0.10 sec Start 165: UnexpectedException_legacy 165/186 Test #165: UnexpectedException_legacy ...................... Passed 0.10 sec Start 166: UnexpectedException_legacy_optimised 166/186 Test #166: UnexpectedException_legacy_optimised ............ Passed 0.10 sec Start 167: category_properties 167/186 Test #167: category_properties ............................. Passed 0.10 sec Start 168: category_properties_optimised 168/186 Test #168: category_properties_optimised ................... Passed 0.10 sec Start 169: CXXExceptions 169/186 Test #169: CXXExceptions ................................... Passed 0.10 sec Start 170: CXXExceptions_optimised 170/186 Test #170: CXXExceptions_optimised ......................... Passed 0.10 sec Start 171: CXXExceptions_legacy 171/186 Test #171: CXXExceptions_legacy ............................ Passed 0.10 sec Start 172: CXXExceptions_legacy_optimised 172/186 Test #172: CXXExceptions_legacy_optimised .................. Passed 0.10 sec Start 173: ForwardDeclareProtocolAccess 173/186 Test #173: ForwardDeclareProtocolAccess .................... Passed 0.10 sec Start 174: ForwardDeclareProtocolAccess_optimised 174/186 Test #174: ForwardDeclareProtocolAccess_optimised .......... Passed 0.10 sec Start 175: ForwardDeclareProtocolAccess_legacy 175/186 Test #175: ForwardDeclareProtocolAccess_legacy ............. Passed 0.10 sec Start 176: ForwardDeclareProtocolAccess_legacy_optimised 176/186 Test #176: ForwardDeclareProtocolAccess_legacy_optimised ... Passed 0.10 sec Start 177: ObjCXXEHInterop 177/186 Test #177: ObjCXXEHInterop ................................. Passed 0.10 sec Start 178: ObjCXXEHInterop_optimised 178/186 Test #178: ObjCXXEHInterop_optimised ....................... Passed 0.10 sec Start 179: ObjCXXEHInterop_legacy 179/186 Test #179: ObjCXXEHInterop_legacy .......................... Passed 0.10 sec Start 180: ObjCXXEHInterop_legacy_optimised 180/186 Test #180: ObjCXXEHInterop_legacy_optimised ................ Passed 0.10 sec Start 181: ObjCXXEHInteropTwice 181/186 Test #181: ObjCXXEHInteropTwice ............................ Passed 0.10 sec Start 182: ObjCXXEHInteropTwice_optimised 182/186 Test #182: ObjCXXEHInteropTwice_optimised .................. Passed 0.10 sec Start 183: ObjCXXEHInteropTwice_legacy 183/186 Test #183: ObjCXXEHInteropTwice_legacy ..................... Passed 0.10 sec Start 184: ObjCXXEHInteropTwice_legacy_optimised 184/186 Test #184: ObjCXXEHInteropTwice_legacy_optimised ........... Passed 0.10 sec Start 185: ObjCXXEHInterop_arc 185/186 Test #185: ObjCXXEHInterop_arc ............................. Passed 0.10 sec Start 186: ObjCXXEHInterop_arc_optimised 186/186 Test #186: ObjCXXEHInterop_arc_optimised ................... Passed 0.10 sec 100% tests passed, 0 tests failed out of 186 Total Test time (real) = 213.15 sec ```
hmelder commented 6 months ago

I have used https://gitlab.com/giomasce/dqib to get a qemu rv64 instance of Debian sid up and running.

davidchisnall commented 6 months ago

We already have CI in QEMU for Arm, adding RV should be easy.

it would be nice if this could also support RV32, most of the changes would just be changing magic constants to a multiple of XLEN, but I’m happy to land 64-bit support first.

Can you also add a bullet in ANNOUNCE? I think adding a new architecture counts as something worth mentioning in the release notes.

Note that clang will need to be patched to add RV64 to the set of architectures that it used non-legacy dispatch for (when using a runtime version of 2.2 or newer). I think you can pass something like -fno-legacy-dispatch, but please make sure that it actually is emitting objc_msgSend and not the two-stage approach that we use on architectures without the assembly fast paths.

hmelder commented 6 months ago

It would be nice if this could also support rv32

Sure, should only be a matter of using macros for ld/sd and changing offsets. What about fp support? I can add support for single-precision fp (rv{32,64}f) as well.

I’m happy to land 64-bit support first.

We can either merge this first, or I add support for rv32 and CI in this PR.

Can you also add a bullet in ANNOUNCE?

Good idea!

Note that clang will need to be patched to add RV64 to the set of architectures that it used non-legacy dispatch for (when using a runtime version of 2.2 or newer)

That is strange. I was debugging my message send logic, because of the different sret calling convention, and the compiler always emitted objc_msgSend.

Here is the ninja configuration for the objc_msgSend unit test:

image

There is no -fno-legacy-dispatch flag set.

hmelder commented 6 months ago

Here the Ghidra C reconstruction:

[...]
  local_18 = (int)local_a0;
                    /* try { // try from 00102cd6 to 00102ce1 has its CatchHandler @ 00102d04 */
  FUN_00101f20(TestCls,.objc_selector_foo_);
  if (local_18 == 0) {
    FUN_00101e90("exceptionThrown && \"An exception was thrown\"",
                 "/root/libobjc2/Test/objc_msgSend.m",0xbd,"int main(void)");
  }
  [..]

void FUN_00101f20(void)

{
  gp = &__global_pointer$;
  objc_msgSend();
  return;
}
davidchisnall commented 6 months ago

Sure, should only be a matter of using macros for ld/sd and changing offsets. What about fp support? I can add support for single-precision fp (rv{32,64}f) as well.

That would be great. Not sure what the calling conventions look like for the SIMD and Vector extensions. If either of these can carry arguments then we would also need to spill them.

We can either merge this first, or I add support for rv32 and CI in this PR.

Up to you.

Here is the ninja configuration for the objc_msgSend unit test:

Ah, this one calls objc_msgSend explicitly. The other tests are probably calling objc_msg_lookup and then calling the returned IMP. If that test is passing, it's probably fine - that tests a load of the painful corner cases.

Here the Ghidra C reconstruction:

It's probably a bad sign that I find that harder to read than RISC-V assembly.

hmelder commented 6 months ago

Ah, this one calls objc_msgSend explicitly. The other tests are probably calling objc_msg_lookup and then calling the returned IMP. If that test is passing, it's probably fine - that tests a load of the painful corner cases.

Oh yeah I forgot about this.

Note that clang will need to be patched to add RV64 to the set of architectures that it used non-legacy dispatch for

I have never worked with the clang sources. Where can I find this set?

Up to you.

It seems like there is no Linux distribution supporting riscv32. Debian supports riscv64 in unstable, but not riscv32, as it is mostly used by microcontrollers anyway.

So there are two options:

  1. Build the gnu rv32 tool chain, and deploy it on the existing Debian rv64 emulator (Run 32-bit Applications on 64-bit Linux Kernel RISC-V)
  2. Use buildroot or just busybox, gnu tool chain, and the Linux kernel for rv32

I would like to get the CI up and running in this PR, and add rv32 support later. This is mostly due to the fact, that I setting up an environment is not trivial.

It's probably a bad sign that I find that harder to read than RISC-V assembly.

:)

davidchisnall commented 6 months ago

It seems like there is no Linux distribution supporting riscv32

Huh, it looks as if FreeBSD doesn’t either. I support a RISC-V profile (CHERIoT, based on RV32E) that doesn’t support *NIX systems but I thought there was Linux support for larger embedded systems. Happy to not bother with 32-bit if it’s painful. We probably can’t support Objective-C on our platform since we’re mostly targeting systems with tens to hundreds of KiBs of RAM (though I may revisit the low memory profile at some point).

I have never worked with the clang sources. Where can I find this set?

This should be the right place:

https://github.com/llvm/llvm-project/blob/f33245a5c4411ce586efe2e12fc29aabb241f5e1/clang/include/clang/Basic/ObjCRuntime.h#L102

It looks as if we don’t use the fast paths for AArch64 either, which probably should be fixed at the same time, since that’s been working in the runtime for 5 years. Should at least be enabled for 2.0 or later…

hmelder commented 6 months ago

CI is now up and running! I had to add LLVM 15 and exclude 13, and 14 because lld did not support R_RISCV_ALIGN relocations until version 15.

Waiting for your review!

though I may revisit the low memory profile at some point

Sounds like an interesting project :)

It looks as if we don’t use the fast paths for AArch64 either, which probably should be fixed at the same time, since that’s been working in the runtime for 5 years. Should at least be enabled for 2.0 or later…

I will open a PR. Thank you!

davidchisnall commented 6 months ago

LGTM, please can you fix ANNOUNCE and squash?