Hi all,

I took another stab at building for Windows, and using a fresh MSYS2 
installation and the latest dependencies and Clang version I was able to make a 
bit of progress and run into some new issues...

After building libobjc2 in a Visual Studio prompt and getting Make to build 
(more on that below), I got Base building as well but it fails when linking:

>  Linking library libgnustep-base ...
> lld-link: warning: obj/libgnustep-base.obj/GSLocale.m.o: locally defined 
> symbol imported: $_OBJC_CLASS_NSConstantString (defined in 
> obj/libgnustep-base.obj/GSString.m.o) [LNK4217]
> ...

These warnings (a couple pages of them) are probably harmless but maybe someone 
knows what they are about?

> lld-link: error: undefined symbol: objc_skip_type_qualifiers
> lld-link: error: undefined symbol: objc_skip_typespec
> lld-link: error: undefined symbol: objc_alignof_type
> lld-link: error: undefined symbol: objc_sizeof_type
> lld-link: error: undefined symbol: objc_layout_structure
> lld-link: error: undefined symbol: objc_layout_structure_next_member
> lld-link: error: undefined symbol: objc_layout_structure_get_info
> lld-link: error: undefined symbol: objc_get_type_qualifiers
> lld-link: error: undefined symbol: objc_promoted_size

These were built as part of libobjc2 (encoding2.c), but they don’t seem to be 
exported in the DLL. Is encoding.h missing some export statements?

> lld-link: error: undefined symbol: __gnustep_objc_personality_v0
> >>> referenced by obj/libgnustep-base.obj/GSICUString.m.o:(.xdata)
> >>> referenced by obj/libgnustep-base.obj/NSRegularExpression.m.o:(.xdata)
> >>> referenced by 
> >>> obj/libgnustep-base.obj/NSRegularExpression.m.o:(GCC_except_table11)
> 
> lld-link: error: undefined symbol: __declspec(dllimport) 
> _objc_class_for_boxing_foreign_exception
> >>> referenced by 
> >>> obj/libgnustep-base.obj/CXXException.m.o:(_c_CXXException__load)
> 
> lld-link: error: undefined symbol: __declspec(dllimport) _objc_weak_load
> >>> referenced by obj/libgnustep-base.obj/NSObject.m.o:(_c_NSObject__load)
> 
> lld-link: error: undefined symbol: __declspec(dllimport) _objc_load_callback
> >>> referenced by obj/libgnustep-base.obj/objc-load.m.o:(GSPrivateLoadModule)


Not sure about these...


I’d appreciate anyone’s thoughts on the above, but also this seems a lot 
further than what I got back in May when I tried last, so that’s very 
encouraging.

Following all the steps to get to the point I’m at just for reference.


1. Install MSYS2 and dependencies

pacman -S git make pkg-config libxml2-devel libxslt-devel libffi-devel 
libgnutls-devel icu-devel
pacman -S mingw-w64-x86_64-pkg-config mingw-w64-x86_64-libxml2 
mingw-w64-x86_64-libxslt mingw-w64-x86_64-libffi mingw-w64-x86_64-gnutls 
mingw-w64-x86_64-icu mingw-w64-x86_64-clang mingw-w64-x86_64-lld

2. Build libobjc2 in "x64 Native Tools Command Prompt for VS 2019"

cmake .. -G Ninja -DTESTS=off -DCMAKE_BUILD_TYPE=RelWithDebInfo 
-DCMAKE_INSTALL_PREFIX:PATH=C:\GNUstep\x64 -DCMAKE_C_COMPILER=clang 
-DCMAKE_CXX_COMPILER=clang
ninja install

3. Build GNUstep Make in MinGW64 prompt

./configure --prefix=/c/GNUstep/x64 --with-library-combo=ng-gnu-gnu 
--with-runtime-abi=gnustep-2.0 LDFLAGS="-fuse-ld=lld -L/c/GNUstep/x64/lib" 
CFLAGS="-I/c/GNUstep/x64/include"

This required a couple tries to get all the config checks to pass. For some 
reason some of the checks don’t seem to search the prefix for libraries or 
headers, so I had to add -L and -I flags manually as well. Also I think using 
lld instead of ld is key.

It still shows the following warning, which seems incorrect though as lld _is_ 
being used successfully for all linking:

checking for an gnustep-2.0 ABI compatible linker... unlikely (GNU ld)
configure: WARNING: The detected linker might not produce working Objective-C 
binaries using the gnustep-2.0 ABI. Consider using gold or LLD.

Also it native exceptions are not recognized for some reason:

checking whether the compiler supports native ObjC exceptions... no

4. Building GNUstep Base in MinGW64 prompt

. /c/GNUstep/x64/share/GNUstep/Makefiles/GNUstep.sh
cp /c/GNUstep/x64/lib/objc.dll .
./configure
make

The only important point here is to copy objc.dll into the source directory so 
that the config tests will find it when being run. Maybe configure should do 
that automatically?


Thanks,
Frederik


Reply via email to