https://bugs.winehq.org/show_bug.cgi?id=46053
Bug ID: 46053 Summary: Support cross-toolchains that need target sysroot explicitly passed via '--sysroot' command-line option (Yocto/Poky SDK) Product: Wine Version: 3.19 Hardware: x86-64 OS: Linux Status: NEW Severity: normal Priority: P2 Component: tools Assignee: wine-bugs@winehq.org Reporter: focht@gmx.net Distribution: ---
Hello folks,
I'm currently reviving/polishing up my local aarch64 and armv7-hf cross-compile environments (lost interest some years ago when WinRT died). I seem to fail building Wine with GCC/Clang cross-compilers that weren't built using the '--with-sysroot' option. This is prettly much standard for all Yocto project SDKs (cross-toolchain + full development sysroot, matching the target rootfs).
The Yocto project (https://www.yoctoproject.org/) allows to easily create embedded Linux distros with full cross-development support (SDK). I often use it at my work when porting/adapting various ARM SoC vendor Linux BSPs. No need to go extra mile and manually cross compile any of Wine's dependencies - they are already built into the target development sysroot. Everything is properly set up, cross pkg-config, etc.
Linaro aarch64 Linux toolchains are not an option, they only contain a minimal target sysroot. I want to build Wine with the same featureset as on my 64-Intel host but for various non-Intel targets (armv7, aarch64, ...).
https://www.yoctoproject.org/docs/2.5/sdk-manual/sdk-manual.html
I succeeded on all things - except for the final linking step. I haven't found a way to pass the target sysroot via '--sysroot' command-line option through 'winegcc' wrapper to the cross-compiler.
I've tried 'configure' with
* --with-sysroot="$SDKTARGETSYSROOT" (not supported) * --extra-cflags and/or EXTRACFLAGS (EXTRACFLAGS works, except for winegcc) * CFLAGS (works, except for winegcc) ...
--- snip --- ... aarch64-poky-linux-clang -mlittle-endian --sysroot=/home/focht/projects/poky/install-2.5.1/sysroots/aarch64-poky-linux -o libwine.so.1.0 casemap.o collation.o config.o debug.o ldt.o loader.o mmap.o port.o sortkey.o string.o \ wctype.o version.o -shared -Wl,-soname,libwine.so.1 \
-Wl,--version-script=/home/focht/projects/wine/mainline-src/libs/wine/wine.map \ ../../libs/port/libwine_port.a -ldl -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed rm -f libwine.so.1 && ln -s libwine.so.1.0 libwine.so.1 rm -f libwine.so && ln -s libwine.so.1 libwine.so make[1]: Leaving directory '/home/focht/projects/wine/mainline-build-aarch64/libs/wine' make[1]: Entering directory '/home/focht/projects/wine/mainline-build-aarch64/dlls/acledit' aarch64-poky-linux-clang -mlittle-endian --sysroot=/home/focht/projects/poky/install-2.5.1/sysroots/aarch64-poky-linux -c -o main.o /home/focht/projects/wine/mainline-src/dlls/acledit/main.c -I. \ -I/home/focht/projects/wine/mainline-src/dlls/acledit -I../../include \ -I/home/focht/projects/wine/mainline-src/include -D__WINESRC__ -D_REENTRANT -fPIC -Wall -pipe \ -fno-strict-aliasing -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers \ -Wno-pragma-pack -Wstrict-prototypes -Wtype-limits -Wvla -Wwrite-strings -Wpointer-arith -gdwarf-2 \ -gstrict-dwarf -g /home/focht/projects/wine/mainline-build-x86_64/tools/winegcc/winegcc -o acledit.dll.so \ -B/home/focht/projects/wine/mainline-build-x86_64/tools/winebuild --sysroot=../.. -b \ aarch64-poky-linux -fasynchronous-unwind-tables -shared /home/focht/projects/wine/mainline-src/dlls/acledit/acledit.spec \ main.o ../../libs/port/libwine_port.a -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find crti.o: No such file or directory /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find crtbeginS.o: No such file or directory /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lm /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lc /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lgcc /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lgcc_s /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lc /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lgcc /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lgcc_s /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find crtendS.o: No such file or directory /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find crtn.o: No such file or directory collect2: error: ld returned 1 exit status winegcc: aarch64-poky-linux-gcc failed make[1]: *** [Makefile:205: acledit.dll.so] Error 2 make[1]: Leaving directory '/home/focht/projects/wine/mainline-build-aarch64/dlls/acledit' make: *** [Makefile:8201: dlls/acledit] Error 2 ... --- snip ---
Manually calling 'winegcc' from build directory with verbosity:
--- snip --- ... /home/focht/projects/wine/mainline-build-x86_64/tools/winegcc/winegcc -v -o acledit.dll.so -B/home/focht/projects/wine/mainline-build-x86_64/tools/winebuild --sysroot=../.. -b aarch64-poky-linux -fasynchronous-unwind-tables -shared /home/focht/projects/wine/mainline-src/dlls/acledit/acledit.spec main.o ../../libs/port/libwine_port.a -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed /home/focht/projects/wine/mainline-build-x86_64/tools/winebuild/winebuild -v --target aarch64-poky-linux -fasynchronous-unwind-tables --cc-cmd=aarch64-poky-linux-gcc --ld-cmd=aarch64-poky-linux-ld -D_REENTRANT -fPIC --dll -o acledit.dll-AvWsaD.spec.o -E /home/focht/projects/wine/mainline-src/dlls/acledit/acledit.spec -L../../dlls -L../../libs/wine -- main.o ../../libs/port/libwine_port.a ../../dlls/winecrt0/libwinecrt0.a ../../dlls/kernel32/libkernel32.def ../../dlls/ntdll/libntdll.def aarch64-poky-linux-gcc -xassembler -c -o acledit.9L04OE.o acledit.WRcmS8.s aarch64-poky-linux-ld -r -o acledit.yk2T5a.o acledit.9L04OE.o main.o ../../libs/port/libwine_port.a ../../dlls/winecrt0/libwinecrt0.a aarch64-poky-linux-gcc -xassembler -c -o acledit.dll-AvWsaD.spec.o acledit.t1CbVC.s Creating file try_link-wN64f8.c aarch64-poky-linux-gcc -o try_link-aCKnlD.out -fPIC -shared -Wl,-Bsymbolic -Wl,-z,defs -Wl,-init,__wine_spec_init,-fini,_wine_spec_fini try_link-wN64f8.c Creating file try_link-cxPNsF.c aarch64-poky-linux-gcc -o try_link-6P2iuc.out -fPIC -shared -Wl,-Bsymbolic -Wl,-z,defs try_link-cxPNsF.c Creating file try_link-euN1Nk.c aarch64-poky-linux-gcc -o try_link-eWPN5V.out -fPIC -shared -Wl,-Bsymbolic -Wl,-init,__wine_spec_init,-fini,_wine_spec_fini try_link-euN1Nk.c Creating file try_link-a8UIza.c /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find crti.o: No such file or directory /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find crtbeginS.o: No such file or directory /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lm /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lc /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lgcc /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lgcc_s /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lc /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lgcc /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find -lgcc_s /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find crtendS.o: No such file or directory /home/focht/projects/poky/install-2.5.1/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/real-ld: cannot find crtn.o: No such file or directory collect2: error: ld returned 1 exit status winegcc: aarch64-poky-linux-gcc failed aarch64-poky-linux-gcc -shared -Wl,-Bsymbolic -o acledit.dll.so -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o try_link-29dnCN.out -Wl,-z,max-page-size=0x1000 try_link-a8UIza.c aarch64-poky-linux-gcc -shared -Wl,-Bsymbolic -o acledit.dll.so -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -L../../dlls -L../../libs/wine acledit.dll-AvWsaD.spec.o main.o ../../libs/port/libwine_port.a ../../dlls/winecrt0/libwinecrt0.a -lwine -lm -lc --- snip ---
Calling 'winegcc' with '-save-temps' and re-executing the final link command with the needed '--sysroot' option succeeds:
--- sip --- $ aarch64-poky-linux-gcc --sysroot=$SDKTARGETSYSROOT -shared -Wl,-Bsymbolic -o acledit.dll.so -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -L../../dlls -L../../libs/wine acledit.dll-VVLgHd.spec.o main.o ../../libs/port/libwine_port.a ../../dlls/winecrt0/libwinecrt0.a -lwine -lm -lc --- sip ---
The generated .dll.so is fine.
--- snip --- $ $OBJDUMP -x acledit.dll.so
acledit.dll.so: file format elf64-littleaarch64 acledit.dll.so architecture: aarch64, flags 0x00000150: HAS_SYMS, DYNAMIC, D_PAGED start address 0x00000000000208c0
Program Header: LOAD off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**16 filesz 0x0000000000021038 memsz 0x0000000000021038 flags r-x LOAD off 0x0000000000021db0 vaddr 0x0000000000031db0 paddr 0x0000000000031db0 align 2**16 filesz 0x0000000000000582 memsz 0x0000000000000590 flags rw- DYNAMIC off 0x0000000000021dc0 vaddr 0x0000000000031dc0 paddr 0x0000000000031dc0 align 2**3 filesz 0x00000000000001e0 memsz 0x00000000000001e0 flags rw- NOTE off 0x00000000000001c8 vaddr 0x00000000000001c8 paddr 0x00000000000001c8 align 2**2 filesz 0x0000000000000024 memsz 0x0000000000000024 flags r-- EH_FRAME off 0x0000000000020efc vaddr 0x0000000000020efc paddr 0x0000000000020efc align 2**2 filesz 0x000000000000005c memsz 0x000000000000005c flags r-- STACK off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**4 filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw- RELRO off 0x0000000000021db0 vaddr 0x0000000000031db0 paddr 0x0000000000031db0 align 2**0 filesz 0x0000000000000250 memsz 0x0000000000000250 flags r--
Dynamic Section: NEEDED libwine.so.1 NEEDED libc.so.6 SYMBOLIC 0x0000000000000000 INIT 0x0000000000000840 FINI 0x0000000000020e0c INIT_ARRAY 0x0000000000031db0 INIT_ARRAYSZ 0x0000000000000008 FINI_ARRAY 0x0000000000031db8 FINI_ARRAYSZ 0x0000000000000008 GNU_HASH 0x00000000000001f0 STRTAB 0x0000000000000428 SYMTAB 0x0000000000000260 STRSZ 0x000000000000010e SYMENT 0x0000000000000018 PLTGOT 0x0000000000031fe8 PLTRELSZ 0x0000000000000060 PLTREL 0x0000000000000007 JMPREL 0x00000000000007e0 RELA 0x00000000000005a0 RELASZ 0x0000000000000240 RELAENT 0x0000000000000018 VERNEED 0x0000000000000560 VERNEEDNUM 0x0000000000000002 VERSYM 0x0000000000000536 RELACOUNT 0x0000000000000012
Version References: required from libc.so.6: 0x06969197 0x00 03 GLIBC_2.17 required from libwine.so.1: 0x0e2b27a0 0x00 02 WINE_1.0 private flags = 0:
Sections: Idx Name Size VMA LMA File off Algn 0 .note.gnu.build-id 00000024 00000000000001c8 00000000000001c8 000001c8 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 1 .gnu.hash 0000006c 00000000000001f0 00000000000001f0 000001f0 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA 2 .dynsym 000001c8 0000000000000260 0000000000000260 00000260 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA 3 .dynstr 0000010e 0000000000000428 0000000000000428 00000428 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA 4 .gnu.version 00000026 0000000000000536 0000000000000536 00000536 2**1 CONTENTS, ALLOC, LOAD, READONLY, DATA 5 .gnu.version_r 00000040 0000000000000560 0000000000000560 00000560 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA 6 .rela.dyn 00000240 00000000000005a0 00000000000005a0 000005a0 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA 7 .rela.plt 00000060 00000000000007e0 00000000000007e0 000007e0 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA 8 .init 0002001c 0000000000000840 0000000000000840 00000840 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 9 .plt 00000060 0000000000020860 0000000000020860 00020860 2**4 CONTENTS, ALLOC, LOAD, READONLY, CODE 10 .text 0000054c 00000000000208c0 00000000000208c0 000208c0 2**3 CONTENTS, ALLOC, LOAD, READONLY, CODE 11 .fini 00000010 0000000000020e0c 0000000000020e0c 00020e0c 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 12 .rodata 000000dd 0000000000020e1c 0000000000020e1c 00020e1c 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 13 .eh_frame_hdr 0000005c 0000000000020efc 0000000000020efc 00020efc 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 14 .eh_frame 000000e0 0000000000020f58 0000000000020f58 00020f58 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA 15 .init_array 00000008 0000000000031db0 0000000000031db0 00021db0 2**3 CONTENTS, ALLOC, LOAD, DATA 16 .fini_array 00000008 0000000000031db8 0000000000031db8 00021db8 2**3 CONTENTS, ALLOC, LOAD, DATA 17 .dynamic 000001e0 0000000000031dc0 0000000000031dc0 00021dc0 2**3 CONTENTS, ALLOC, LOAD, DATA 18 .got 00000048 0000000000031fa0 0000000000031fa0 00021fa0 2**3 CONTENTS, ALLOC, LOAD, DATA 19 .got.plt 00000038 0000000000031fe8 0000000000031fe8 00021fe8 2**3 CONTENTS, ALLOC, LOAD, DATA 20 .data 00000312 0000000000032020 0000000000032020 00022020 2**3 CONTENTS, ALLOC, LOAD, DATA 21 .bss 0000000c 0000000000032334 0000000000032334 00022332 2**2 ALLOC 22 .comment 000000c8 0000000000000000 0000000000000000 00022332 2**0 CONTENTS, READONLY 23 .debug_aranges 00000090 0000000000000000 0000000000000000 00022400 2**4 CONTENTS, READONLY, DEBUGGING 24 .debug_pubnames 00000130 0000000000000000 0000000000000000 00022490 2**0 CONTENTS, READONLY, DEBUGGING 25 .debug_info 000004f9 0000000000000000 0000000000000000 000225c0 2**0 CONTENTS, READONLY, DEBUGGING 26 .debug_abbrev 000002d6 0000000000000000 0000000000000000 00022ab9 2**0 CONTENTS, READONLY, DEBUGGING 27 .debug_line 000004af 0000000000000000 0000000000000000 00022d8f 2**0 CONTENTS, READONLY, DEBUGGING 28 .debug_frame 00000100 0000000000000000 0000000000000000 00023240 2**3 CONTENTS, READONLY, DEBUGGING 29 .debug_str 000004f6 0000000000000000 0000000000000000 00023340 2**0 CONTENTS, READONLY, DEBUGGING 30 .debug_macinfo 00000004 0000000000000000 0000000000000000 00023836 2**0 CONTENTS, READONLY, DEBUGGING 31 .debug_pubtypes 000001c1 0000000000000000 0000000000000000 0002383a 2**0 CONTENTS, READONLY, DEBUGGING 32 .debug_ranges 00000090 0000000000000000 0000000000000000 00023a00 2**4 CONTENTS, READONLY, DEBUGGING SYMBOL TABLE: 00000000000001c8 l d .note.gnu.build-id 0000000000000000 .note.gnu.build-id 00000000000001f0 l d .gnu.hash 0000000000000000 .gnu.hash 0000000000000260 l d .dynsym 0000000000000000 .dynsym 0000000000000428 l d .dynstr 0000000000000000 .dynstr 0000000000000536 l d .gnu.version 0000000000000000 .gnu.version 0000000000000560 l d .gnu.version_r 0000000000000000 .gnu.version_r 00000000000005a0 l d .rela.dyn 0000000000000000 .rela.dyn 00000000000007e0 l d .rela.plt 0000000000000000 .rela.plt 0000000000000840 l d .init 0000000000000000 .init 0000000000020860 l d .plt 0000000000000000 .plt 00000000000208c0 l d .text 0000000000000000 .text 0000000000020e0c l d .fini 0000000000000000 .fini 0000000000020e1c l d .rodata 0000000000000000 .rodata 0000000000020efc l d .eh_frame_hdr 0000000000000000 .eh_frame_hdr 0000000000020f58 l d .eh_frame 0000000000000000 .eh_frame 0000000000031db0 l d .init_array 0000000000000000 .init_array 0000000000031db8 l d .fini_array 0000000000000000 .fini_array 0000000000031dc0 l d .dynamic 0000000000000000 .dynamic 0000000000031fa0 l d .got 0000000000000000 .got 0000000000031fe8 l d .got.plt 0000000000000000 .got.plt 0000000000032020 l d .data 0000000000000000 .data 0000000000032334 l d .bss 0000000000000000 .bss 0000000000000000 l d .comment 0000000000000000 .comment 0000000000000000 l d .debug_aranges 0000000000000000 .debug_aranges 0000000000000000 l d .debug_pubnames 0000000000000000 .debug_pubnames 0000000000000000 l d .debug_info 0000000000000000 .debug_info 0000000000000000 l d .debug_abbrev 0000000000000000 .debug_abbrev 0000000000000000 l d .debug_line 0000000000000000 .debug_line 0000000000000000 l d .debug_frame 0000000000000000 .debug_frame 0000000000000000 l d .debug_str 0000000000000000 .debug_str 0000000000000000 l d .debug_macinfo 0000000000000000 .debug_macinfo 0000000000000000 l d .debug_pubtypes 0000000000000000 .debug_pubtypes 0000000000000000 l d .debug_ranges 0000000000000000 .debug_ranges 0000000000000000 l df *ABS* 0000000000000000 /home/focht/projects/poky/install-2.5.1/sysroots/aarch64-poky-linux/usr/lib/crti.o 00000000000208c0 l F .text 0000000000000014 call_weak_fn 0000000000000000 l df *ABS* 0000000000000000 acledit.dll-VVLgHd.spec.o 0000000000000850 l .init 0000000000000000 __wine_spec_pe_header 0000000000020998 l F .text 000000000000001c ... __wine_spec_import_thunks 0000000000000000 l df *ABS* 0000000000000000 /home/focht/projects/poky/install-2.5.1/sysroots/aarch64-poky-linux/usr/lib/crtn.o 0000000000000000 l df *ABS* 0000000000000000 crtstuff.c 00000000000208d8 l F .text 0000000000000000 deregister_tm_clones 0000000000020908 l F .text 0000000000000000 register_tm_clones 0000000000020948 l F .text 0000000000000000 ... __gmon_start__ 0000000000000000 F *UND* 0000000000000000 wine_dbg_log@@WINE_1.0 0000000000032340 g .bss 0000000000000000 _end 0000000000032340 g .bss 0000000000000000 __end__ 0000000000032332 g .bss 0000000000000000 __bss_start 0000000000000000 w *UND* 0000000000000000 _ITM_registerTMCloneTable --- snip ---
Regards