链接使用 gnat 构建的库的问题

Issue with linking libraries built with gnat

当尝试构建一些测试用例(只是用 Ada 编写的程序)时,出现以下错误:

gcc -c -shared decimaltests.adb
gnatbind -x decimaltests.ali
gnatlink decimaltests.ali -lGenerics -lNumerics -lTesting
/usr/bin/ld: decimaltests: hidden symbol `_Unwind_Resume' in 
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/libgcc_eh.a(unwind-dw2.o) is referenced by DSO
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
gnatlink: error when calling /usr/bin/gcc
gnatmake: *** link failed.

我正在使用 gnatmake -shared *.ad{b,s} -largs -lGenerics -lNumerics -lTesting 构建它们 显然这不是构建源代码的问题,但只是为了进一步确认,我将源代码复制到此目录并使用 gnatmake -shared *.ad{b,s} 构建构建测试就好了。

依赖库已构建并安装到 gnat 搜索的路径中。找不到那些似乎不是问题。不确定这里发生了什么。

所有库都是使用 gnatmake -O2 -fPIC -shared *.ad{b,s} 以及任何相关的库依赖项构建的。所有依赖这些的库仍然可以构建。只有依赖库的程序才会抛出此错误,并且总是出现相同的错误。

更新: 使用 gprbuild 构建库然后使用 gprinstall 安装它们似乎工作类似,除了现在错误如下:

decimaltests.o: In function `_ada_decimaltests':
decimaltests.adb:(.text+0x43): undefined reference to `testing__start'
decimaltests.adb:(.text+0x4a): undefined reference to 
`generics__testing__default_tolerance'
decimaltests.adb:(.text+0x9e): undefined reference to 
`generics__testing__default_tolerance'
decimaltests.adb:(.text+0x108): undefined reference to 
`generics__testing__default_tolerance'
decimaltests.adb:(.text+0x172): undefined reference to 
`generics__testing__default_tolerance'
decimaltests.adb:(.text+0x1dc): undefined reference to 
`generics__testing__default_tolerance'
decimaltests.o:decimaltests.adb:(.text+0x23f): more undefined references to 
`generics__testing__default_tolerance' follow
decimaltests.o: In function `_ada_decimaltests':
decimaltests.adb:(.text+0x14f5): undefined reference to `testing__stop'
/usr/lib/numerics//libNumerics.so: undefined reference to 
`generics__testing__not_started@SYMS'
/usr/lib/numerics//libNumerics.so: undefined reference to 
`generics__testing__pass@SYMS'
/usr/lib/numerics//libNumerics.so: undefined reference to 
`generics__testing__fail@SYMS'
collect2: error: ld returned 1 exit status
gprbuild: link of decimaltests.adb failed

所以我查看了两种构建方法的符号 table 并注意到,在这两种情况下,符号肯定存在,但对它的引用似乎是错误的位置。我会尝试在不同的 platforms/compilers 上构建,如果出现任何相关内容,我会再次更新。

这两个进程在不同的平台上都正确地构建了库和测试程序,并且测试程序 运行 正确。为了进一步确认这是一个错误,我安装了不同的GCC工具链并在原始平台下重复构建,并没有出现这个问题。我将提交错误报告。