https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122574

            Bug ID: 122574
           Summary: Link fails because of unresolved refernce
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: [email protected]
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 62717
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62717&action=edit
Minimal set of reproducer source files for gnatchop

There is another problem with my SI library with GNAT 15.2.1
on Windows 11 called via alire.
With GNAT CE 2021, the problem does not exist.
The code reduced to a minimal reproducer and the GNAT project
file are in the attachment for gnatchop.
Here follows the exact compile command with the compiler
output produced.
============================================
The final link fails because of an undefined reference.
This is the command:

PS C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b> alr run
Note: Building hello=1.0.2/hello.gpr...
Compile
   [Ada]          hello.adb
   [Ada]          si.ads
   [Ada]          actual_dimensions.ads
   [Ada]          dimension_signature.ads
   [Ada]          generic_si.adb
   [Ada]          generic_si-generic_symbols.adb
   [Ada]          fake_dimensions.ads
   [Ada]          rational_arithmetics.adb
Bind
   [gprbind]      hello.bexch
   [Ada]          hello.ali
Link
   [link]         hello.adb
C:/Users/Admin/AppData/Local/alire/cache/toolchains/gnat_native_15.2.1_346e2e00/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
hello.o:hello.adb:(.text+0x7): undefined reference to
`si__Omultiply__B_2__string_interface__get__2.0'
collect2.exe: error: ld returned 1 exit status
gprbuild: link of hello.adb failed
gprbuild: failed command was:
c:\users\admin\appdata\local\alire\cache\toolchains\gnat_native_15.2.1_346e2e00\bin\gcc.exe
hello.o b__hello.o
C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\obj\rational_arithmetics.o
C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\obj\dimension_signature.o
C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\obj\fake_dimensions.o
C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\obj\actual_dimensions.o
C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\obj\generic_si-generic_symbols.o
C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\obj\generic_si.o
C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\obj\si.o
-LC:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\obj\
-LC:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\obj\
-LC:/users/admin/appdata/local/alire/cache/toolchains/gnat_native_15.2.1_346e2e00/lib/gcc/x86_64-w64-mingw32/15.2.0/adalib/
-static-libgcc
C:/users/admin/appdata/local/alire/cache/toolchains/gnat_native_15.2.1_346e2e00/lib/gcc/x86_64-w64-mingw32/15.2.0/adalib/libgnat.a
-Wl,--stack=0x2000000 -o
C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\bin\\hello.exe
ERROR: Command ["gprbuild", "-s", "-j0", "-p", "-P",
"C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\hello.gpr"] exited with
code 4
ERROR: Build failed
PS C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b>
============================================
If you comment out the GNAT inline switch -gnatn in the project file hello.gpr,
the link completes and you get the following output:

PS C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b> alr run
Note: Building hello=1.0.2/hello.gpr...
Compile
   [Ada]          hello.adb
   [Ada]          si.ads
   [Ada]          actual_dimensions.ads
   [Ada]          dimension_signature.ads
   [Ada]          generic_si.adb
   [Ada]          generic_si-generic_symbols.adb
   [Ada]          fake_dimensions.ads
   [Ada]          rational_arithmetics.adb
Bind
   [gprbind]      hello.bexch
   [Ada]          hello.ali
Link
   [link]         hello.adb
Success: Build finished successfully in 3.42 seconds.
Unchecked
PS C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b>
============================================
This is the result with GNAT CE 2021 produced with GPS:

GNAT Studio Community 2021 (20210423) hosted on x86_64-w64-mingw32
GNAT Community 2021 (20210519-103) targeting x86_64-w64-mingw32
SPARK Community 2021 (20210519)

GNAT Studio
(c) 2001-2021 AdaCore

gprbuild -d -PC:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\hello.gpr
C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\SI-2025\hello.adb
Compile
   [Ada]          hello.adb
   [Ada]          si.ads
   [Ada]          actual_dimensions.ads
   [Ada]          dimension_signature.ads
   [Ada]          fake_dimensions.ads
   [Ada]          generic_si.adb
   [Ada]          generic_si-generic_symbols.adb
   [Ada]          rational_arithmetics.adb
Bind
   [gprbind]      hello.bexch
   [Ada]          hello.ali
Link
   [link]         hello.adb
[2025-11-05 13:17:55] process terminated successfully, elapsed time: 03.71s

C:\Users\Admin\Desktop\Spielplatz\hello_1.0.2_5715870b\bin\hello.exe
Unchecked
[2025-11-05 13:17:56] process terminated successfully, elapsed time: 00.34s

Reply via email to