Bug 26518 - [2.35|regression|bisected] DWARF error: could not find variable specification
Summary: [2.35|regression|bisected] DWARF error: could not find variable specification
Status: UNCONFIRMED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.35
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-21 13:16 UTC by xantares09
Modified: 2020-08-25 07:01 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description xantares09 2020-08-21 13:16:09 UTC
I have a problem compiling mesa using with binutils 2.35 in archlinux
for mingw i686 target with LLVM enabled + LTO:


if I disable LTO (meson -Db_lto=false) or use binutils 2.34 the problem goes away
if I use the x86_64 target the problem goes away
I tried today's binutils master: the bug is still there

I found a somewhat similar report at debian:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=965247


Here is the error:


[947/947] Linking target src/gallium/targets/libgl-gdi/opengl32.dll
FAILED: src/gallium/targets/libgl-gdi/opengl32.dll 
i686-w64-mingw32-g++  -o src/gallium/targets/libgl-gdi/opengl32.dll src/gallium/targets/libgl-gdi/opengl32.dll.p/libgl_gdi.c.obj -flto -Wl,--allow-shlib-undefined -Wl,-O1 -shared ../src/gallium/targets/libgl-gdi/../../state_trackers/wgl/opengl32.mingw.def -Wl,--start-group -Wl,--out-implib=src/gallium/targets/libgl-gdi/opengl32.dll.a -Wl,--whole-archive src/gallium/state_trackers/wgl/libwgl.a -Wl,--no-whole-archive -Wl,--nxcompat -Wl,--dynamicbase -static-libgcc -static-libstdc++ -Wl,-O1,--sort-common,--as-needed -fstack-protector src/gallium/auxiliary/libgallium.a src/compiler/nir/libnir.a src/compiler/libcompiler.a src/util/libmesa_util.a src/util/format/libmesa_format.a src/compiler/glsl/libglsl.a src/compiler/glsl/glcpp/libglcpp.a src/mesa/libmesa_gallium.a src/mesa/libmesa_common.a src/mesa/libmesa_sse41.a src/gallium/winsys/sw/gdi/libwsgdi.a src/mapi/glapi/libglapi_static.a src/gallium/drivers/llvmpipe/libllvmpipe.a src/gallium/drivers/softpipe/libsoftpipe.a -lws2_32 /usr/i686-w64-mingw32/lib/libz.dll.a -pthread -lm /usr/i686-w64-mingw32/lib/libLLVMAggressiveInstCombine.dll.a /usr/i686-w64-mingw32/lib/libLLVMAnalysis.dll.a /usr/i686-w64-mingw32/lib/libLLVMAsmParser.dll.a /usr/i686-w64-mingw32/lib/libLLVMAsmPrinter.dll.a /usr/i686-w64-mingw32/lib/libLLVMBinaryFormat.dll.a /usr/i686-w64-mingw32/lib/libLLVMBitReader.dll.a /usr/i686-w64-mingw32/lib/libLLVMBitWriter.dll.a /usr/i686-w64-mingw32/lib/libLLVMBitstreamReader.dll.a /usr/i686-w64-mingw32/lib/libLLVMCFGuard.dll.a /usr/i686-w64-mingw32/lib/libLLVMCodeGen.dll.a /usr/i686-w64-mingw32/lib/libLLVMCore.dll.a /usr/i686-w64-mingw32/lib/libLLVMCoroutines.dll.a /usr/i686-w64-mingw32/lib/libLLVMDebugInfoCodeView.dll.a /usr/i686-w64-mingw32/lib/libLLVMDebugInfoDWARF.dll.a /usr/i686-w64-mingw32/lib/libLLVMDebugInfoMSF.dll.a /usr/i686-w64-mingw32/lib/libLLVMDemangle.dll.a /usr/i686-w64-mingw32/lib/libLLVMExecutionEngine.dll.a /usr/i686-w64-mingw32/lib/libLLVMGlobalISel.dll.a /usr/i686-w64-mingw32/lib/libLLVMIRReader.dll.a /usr/i686-w64-mingw32/lib/libLLVMInstCombine.dll.a /usr/i686-w64-mingw32/lib/libLLVMInstrumentation.dll.a /usr/i686-w64-mingw32/lib/libLLVMLinker.dll.a /usr/i686-w64-mingw32/lib/libLLVMMC.dll.a /usr/i686-w64-mingw32/lib/libLLVMMCDisassembler.dll.a /usr/i686-w64-mingw32/lib/libLLVMMCJIT.dll.a /usr/i686-w64-mingw32/lib/libLLVMMCParser.dll.a /usr/i686-w64-mingw32/lib/libLLVMObject.dll.a /usr/i686-w64-mingw32/lib/libLLVMProfileData.dll.a /usr/i686-w64-mingw32/lib/libLLVMRemarks.dll.a /usr/i686-w64-mingw32/lib/libLLVMRuntimeDyld.dll.a /usr/i686-w64-mingw32/lib/libLLVMScalarOpts.dll.a /usr/i686-w64-mingw32/lib/libLLVMSelectionDAG.dll.a /usr/i686-w64-mingw32/lib/libLLVMSupport.dll.a /usr/i686-w64-mingw32/lib/libLLVMTarget.dll.a /usr/i686-w64-mingw32/lib/libLLVMTextAPI.dll.a /usr/i686-w64-mingw32/lib/libLLVMTransformUtils.dll.a /usr/i686-w64-mingw32/lib/libLLVMVectorize.dll.a /usr/i686-w64-mingw32/lib/libLLVMX86AsmParser.dll.a /usr/i686-w64-mingw32/lib/libLLVMX86CodeGen.dll.a /usr/i686-w64-mingw32/lib/libLLVMX86Desc.dll.a /usr/i686-w64-mingw32/lib/libLLVMX86Disassembler.dll.a /usr/i686-w64-mingw32/lib/libLLVMX86Info.dll.a /usr/i686-w64-mingw32/lib/libLLVMX86Utils.dll.a /usr/i686-w64-mingw32/lib/libLLVMipo.dll.a -ldl -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -Wl,--end-group
/usr/lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld: /usr/lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld: DWARF error: could not find variable specification at offset 377
/usr/lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/lib/../lib/libstdc++.a(string-inst.o): in function `ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag':
/build/mingw-w64-gcc/src/build-i686-w64-mingw32/i686-w64-mingw32/libstdc++-v3/include/bits/basic_string.tcc:206: multiple definition of `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag)'; gallivm_lp_bld_misc.cpp.obj (symbol from plugin):(.gnu.linkonce.t._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag+0x0): first defined here
/usr/lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld: /usr/lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/lib/../lib/libstdc++.a(string-inst.o): in function `ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag':
/build/mingw-w64-gcc/src/build-i686-w64-mingw32/i686-w64-mingw32/libstdc++-v3/include/bits/basic_string.tcc:206: multiple definition of `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag)'; gallivm_lp_bld_misc.cpp.obj (symbol from plugin):(.gnu.linkonce.t._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag+0x0): first defined here
In function ‘memcpy’,
    inlined from ‘_glapi_new_nop_table’ at ../src/mapi/glapi/glapi_nop.c:128:7,
    inlined from ‘_mesa_alloc_dispatch_table’ at ../src/mesa/main/context.c:1012:12:
/usr/i686-w64-mingw32/include/string.h:202:10: warning: ‘__builtin_memcpy’ reading 7464 bytes from a region of size 6836 [-Wstringop-overflow=]
  202 |   return __builtin___memcpy_chk(__dst, __src, __n, __mingw_bos(__dst, 0));
      |          ^
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Comment 1 xantares09 2020-08-24 15:30:12 UTC
bisecting leads to:

commit 0e6a3f07f50723d1831291492b96fdf74bcbdc11
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jul 22 03:49:07 2020 -0700

    ld: Properly override the IR definition
    
    We change the previous definition in the IR object to undefweak only
    after all LTO symbols have been read.
Comment 2 xantares09 2020-08-24 15:31:02 UTC
bisecting leads to:

commit 0e6a3f07f50723d1831291492b96fdf74bcbdc11
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jul 22 03:49:07 2020 -0700

    ld: Properly override the IR definition
    
    We change the previous definition in the IR object to undefweak only
    after all LTO symbols have been read.
Comment 3 xantares09 2020-08-24 15:59:32 UTC
reverting this commit on current master fixes the issue (conflicts in changelogs only)
Comment 4 H.J. Lu 2020-08-24 16:25:04 UTC
I think this a latent problem that ld doesn't support some DWARF info generated
by LLVM.
Comment 5 xantares09 2020-08-24 16:33:59 UTC
can you elaborate when you mean generated ?

llvm is not running here, we just link against it (llvm is compiled with gcc)
Comment 6 H.J. Lu 2020-08-24 21:06:59 UTC
The relevant error message is

/usr/lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/lib/../lib/libstdc++.a(string-inst.o): in function `ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag':
/build/mingw-w64-gcc/src/build-i686-w64-mingw32/i686-w64-mingw32/libstdc++-v3/include/bits/basic_string.tcc:206: multiple definition of `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag)'; gallivm_lp_bld_misc.cpp.obj (symbol from plugin):(.gnu.linkonce.t._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag+0x0): first defined here
/usr/lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld: /usr/lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/lib/../lib/libstdc++.a(string-inst.o): in function `ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag':
/build/mingw-w64-gcc/src/build-i686-w64-mingw32/i686-w64-mingw32/libstdc++-v3/include/bits/basic_string.tcc:206: multiple definition of `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag)'; gallivm_lp_bld_misc.cpp.obj (symbol from plugin):(.gnu.linkonce.t._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag+0x0): first defined here

_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag

are defined in .gnu.linkonce.t sections and multiple definition should be
OK.  Why is it a problem?
Comment 7 xantares09 2020-08-25 07:01:57 UTC
I dont know. Maybe windows binary format dont support multiple definitions ?

I thought the most important part was:

ld: DWARF error: could not find variable specification at offset 377