Windows-on-ARM-Experiments / mingw-woarm64-build

Workflows and build scripts for Windows on Arm64 GNU cross-compiler for `aarch64-w64-mingw32` target.
GNU General Public License v2.0
32 stars 4 forks source link

libxml2 crosscompile fails with ld errors #92

Closed laggykiller closed 9 months ago

laggykiller commented 9 months ago

Not sure if this is known issue (Feel free to close if known), but libxml2 fails to crosscompile.

I have tried on both Arch Linux x86_64 and Windows x86_64 msys2 (By adding woarm64 repo and install mingw-w64-cross, replace ~/cross with /opt), both failing to compile with similar error.

Below is script for test cross-compiling on Linux:

cd
git clone https://github.com/Windows-on-ARM-Experiments/mingw-woarm64-build.git
cd mingw-woarm64-build
./build.sh
cd

export CC=~/cross/bin/aarch64-w64-mingw32-gcc
export AR=~/cross/bin/aarch64-w64-mingw32-ar
export RANLIB=~/cross/bin/aarch64-w64-mingw32-ranlib
export RC=~/cross/bin/aarch64-w64-mingw32-windres
export STRIP=~/cross/bin/aarch64-w64-mingw32-strip
export NM=~/cross/bin/aarch64-w64-mingw32-nm

# xz
cd
curl -O -L https://github.com/tukaani-project/xz/releases/download/v5.4.4/xz-5.4.4.tar.xz
tar -xf xz-5.4.4.tar.xz
cd xz-5.4.4
./configure --disable-doc --disable-lzma-links --disable-lzmadec --disable-lzmainfo --disable-nls --disable-scripts --disable-xz --disable-xzdec --disable-static --enable-shared --libdir=$HOME/cross/lib --prefix=$HOME/cross --host=aarch64-w64-mingw32
make clean install

# zlib
cd
curl -O -L https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.xz
tar -xf zlib-1.3.1.tar.xz
cd zlib-1.3.1
make -f win32/Makefile.gcc DESTDIR=~/cross CC=~/cross/bin/aarch64-w64-mingw32-gcc AR=~/cross/bin/aarch64-w64-mingw32-ar RANLIB=~/cross/bin/aarch64-w64-mingw32-ranlib RC=~/cross/bin/aarch64-w64-mingw32-windres STRIP=~/cross/bin/aarch64-w64-mingw32-strip BINARY_PATH=$PREFIXDIR/bin INCLUDE_PATH=$PREFIXDIR/include LIBRARY_PATH=$PREFIXDIR/lib SHARED_MODE=1 PREFIX=aarch64-w64-mingw32- clean install

# xml2
cd
curl -O -L https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.13.tar.xz
tar -xf libxml2-2.9.13.tar.xz
cd libxml2-2.9.13
./configure --without-python --disable-static --enable-shared --libdir=$HOME/cross/lib --prefix=$HOME/cross --host=aarch64-w64-mingw32 --with-zlib=$HOME/cross/lib --with-lzma=$HOME/cross/lib
make clean install

This is the error:

/home/laggykiller/cross/lib/gcc/aarch64-w64-mingw32/14.0.1/../../../../aarch64-w64-mingw32/bin/ld: /home/mcchau/libxml2-2.9.13/xmllint.c:3797:(.text.startup+0x2160): undefined reference to `__imp_xmlNewParserCtxt'
/home/laggykiller/cross/lib/gcc/aarch64-w64-mingw32/14.0.1/../../../../aarch64-w64-mingw32/bin/ld: xmllint.o: 12 bit relocation not currently supported.
eukarpov commented 9 months ago

@laggykiller Thank you for reporting the issue. It looks like this is the problem "xmllint.o: 12 bit relocation not currently supported" The investigation has been started to reproduce and resolve the issue.

Blackhex commented 9 months ago

@laggykiller Thank you for your report. It seems that it's libxml2 configure/Makefile issue as the linker is trying to link static library instead of the DLL. This leads to the "undefined references" errors. The "12 bit relocation not currently supported" messages, though they seem scary, are just aftermath - they were added for debugging purposes and will be removed before upstreaming. The CMake build of the shared library https://github.com/Windows-on-ARM-Experiments/mingw-woarm64-build/pull/94/files#diff-20383000acdec90d8b8e4421c4178e773f1eb27f5c6ca6df777a232687ed9dfe seems to compelete fine. We haven't tested the produced binaries for functional correctness yet, though.