gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Building GNUstep for Windows using Clang


From: Frederik Seiffert
Subject: Re: Building GNUstep for Windows using Clang
Date: Wed, 20 Jan 2021 16:54:58 +0100

So it seems that we need to generate a module definition (.def) file in order to have all the ObjC class symbols exported in the DLL. This is also what WinObjC is doing, I’ll try to come up with a script to generate this file from the object file symbols.


However after manually creating a .def file with a few relevant symbols I still get the following linker error, which happens for any referenced Foundation class (NSArray is just an example):

lld-link: error: undefined symbol: $_OBJC_REF_CLASS_NSArray
>>> referenced by test.m:16
>>>               C:\msys64\tmp\test-b84674.o:(WinMain)

I confirmed with dumpbin /exports that the .lib and DLL both contain these $_OBJC_REF_CLASS_ symbols, so I really don’t understand why it’s not found.


I’ve reproduced the issue from scratch using only libobjc2 and have written down the steps to reproduce here:
https://github.com/gnustep/libobjc2/issues/191

Hopefully I’m just missing some flag somewhere when creating the DLL. I’d appreciate any thoughts.


Thanks!
Frederik



Am 19.01.2021 um 20:50 schrieb Frederik Seiffert <frederik@algoriddim.com>:

Hi David,

Am 19.01.2021 um 18:40 schrieb David Chisnall <gnustep@theravensnest.org>:

On ELF platforms, there were some issues with the ld -r invocation that -base Additions did.  Can you try just adding the .m files from Additions directly to the -base project and see if that makes the problem go away?  I don't think that PE/COFF linkage really has any concept that maps to how we do the subproject thing in -make.

I’m using "ar cr ..." instead of "ld -r" as the subproject merge command, as that’s what the MinGW targets were using with Clang. I can also see all the NS*.m.o object files of the various classes that I’m getting errors for being passed directly to the linker, so I’m guessing that’s not it.

I can see with nm that the object files contain the relevant symbols, but the generated gnustep-base.lib does not (not sure about the DLL). I’m wondering if these symbols need to be specially marked to be exported or I’m missing some linker flag? With MinGW we’re passing the object files between --whole-archive / --no-whole-archive, but that flag isn’t recognized by lld-link.

This is the (abbreviated) linker invocation I have right now:

clang -Wl,-dll -Wl,-export-all-symbols -fuse-ld=lld -Wl,/subsystem:console -o ./obj/gnustep-base-1_27.dll obj/libgnustep-base.obj/GSArray.m.o <all-other-object-files> Additions/obj/subproject.o win32/obj/subproject.o -lffi -lWs2_32 -lpthread -ladvapi32 -luser32 -lshell32 -lnetapi32 -lobjc 

Thanks!

Frederik



reply via email to

[Prev in Thread] Current Thread [Next in Thread]