llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.58k stars 11.81k forks source link

Linking wine 32-bit binaries fails #45015

Open orgads opened 4 years ago

orgads commented 4 years ago
Bugzilla Link 45670
Version unspecified
OS Linux

Extended Description

In /usr/bin: ln -sf ld.lld ld (Here I used a script that outputs the flags before executing)

In wine build directory: mkdir test cd test echo 'int wmain() {}' > test.c

../tools/winegcc/winegcc -v -save-temps --wine-objdir .. -m32 -fno-PIC -fasynchronous-unwind-tables -mconsole -municode -mno-cygwin test.c

/usr/bin/gcc -m32 -fno-PIC -c -o test-hAIw1D.o -save-temps -fno-PIC -fasynchronous-unwind-tables test.c

../tools/winebuild/winebuild -v --save-temps -fasynchronous-unwind-tables "--cc-cmd=/usr/bin/gcc -m32" --ld-cmd=/usr/bin/ld -m32 -D_REENTRANT --exe -o a.out-4B52c7.spec.o -F a.out --subsystem console --entry __wine_spec_exe_wentry -L../dlls -L../libs/wine -- test-hAIw1D.o ../dlls/winecrt0/libwinecrt0.a ../dlls/msvcrt/libmsvcrt.a ../dlls/kernel32/libkernel32.def ../dlls/ntdll/libntdll.def /usr/bin/gcc -m32 -xassembler -c -m32 -o a.2BcJJ5.o a.YRlrYC.s /usr/bin/ld -m elf_i386 -r -o a.cZrasB.o a.2BcJJ5.o test-hAIw1D.o ../dlls/winecrt0/libwinecrt0.a ../dlls/msvcrt/libmsvcrt.a ld.lld -m elf_i386 -r -o a.cZrasB.o a.2BcJJ5.o test-hAIw1D.o ../dlls/winecrt0/libwinecrt0.a ../dlls/msvcrt/libmsvcrt.a /usr/bin/nm -u a.cZrasB.o /usr/bin/gcc -m32 -xassembler -c -m32 -o a.out-4B52c7.spec.o a.Ocbvm8.s Creating file try_link-5wRn6H.c /usr/bin/gcc -m32 -m32 -o try_link-aAe0Zi.out -Wl,-z,max-page-size=0x1000 try_link-5wRn6H.c Creating file try_link-6M3xBx.c ld.lld -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccnUfjaP.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_i386 --hash-style=gnu --as-needed -shared -o a.out.so /usr/lib/gcc/x86_64-linux-gnu/9/../../../i386-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/32/crtbeginS.o -L../dlls -L../libs/wine -L/usr/lib/gcc/x86_64-linux-gnu/9/32 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../i386-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib32 -L/lib/i386-linux-gnu -L/lib/../lib32 -L/usr/lib/i386-linux-gnu -L/usr/lib/../lib32 -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../i386-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. -L/lib/i386-linux-gnu -L/usr/lib/i386-linux-gnu -Bsymbolic -z max-page-size=0x1000 -z defs -init wine_spec_init -fini wine_spec_fini a.out-4B52c7.spec.o test-hAIw1D.o ../dlls/winecrt0/libwinecrt0.a ../dlls/msvcrt/libmsvcrt.a -lwine -lm -lc -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/9/32/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../i386-linux-gnu/crtn.o ld.lld: error: can't create dynamic relocation R_386_32 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output

defined in a.out-4B52c7.spec.o referenced by a.out-4B52c7.spec.o:(__wine_spec_import_thunks)

ld.lld: error: can't create dynamic relocation R_386_32 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output

defined in a.out-4B52c7.spec.o referenced by a.out-4B52c7.spec.o:(__wine_spec_import_thunks)

ld.lld: error: can't create dynamic relocation R_386_32 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output

defined in a.out-4B52c7.spec.o referenced by a.out-4B52c7.spec.o:(__wine_spec_import_thunks)

ld.lld: error: can't create dynamic relocation R_386_32 against symbol: __wine_spec_init_state in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output

defined in ../dlls/winecrt0/libwinecrt0.a(init.o) referenced by exe_wentry.c:99 (../../../dlls/winecrt0/exe_wentry.c:99) exe_wentry.o:(__wine_spec_exe_wentry) in archive ../dlls/winecrt0/libwinecrt0.a

ld.lld: error: can't create dynamic relocation R_386_32 against symbol: __wine_spec_init_state in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output

defined in ../dlls/winecrt0/libwinecrt0.a(init.o) referenced by init.c:38 (../../../dlls/winecrt0/init.c:38) init.o:(__wine_spec_init) in archive ../dlls/winecrt0/libwinecrt0.a

etc...

llvmbot commented 4 years ago

Does it work if you pass '-Wl,-z,notext'?

ELF backend prints the same errors for various programs and with '-Wl,-z,notext' they build correctly.