Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnatcoll-core 25.0.0 fails to compile with GNU/gcc GNAT 12 #88

Closed
sternenseemann opened this issue Nov 1, 2024 · 8 comments
Closed

Comments

@sternenseemann
Copy link

I'm currently working on updating all AdaCore released packages in NixOS/nixpkgs to their 25.0.0 versions. I've noticed that it isn't possible to build gnatcoll-core 25.0.0 (from the GitHub release) with GNAT 12.4.0, i.e. gcc.

Now compilation fails with an apparent compiler bug, but since GNAT 12 is not the latest version of GNU GNAT (I'll have to look up if it'll even receive bug fixes anymore), I'm wondering if we can possibly work around it on gnatcoll-core's side. GNAT 13 and 14 are not affected, so maybe it's easy to backport a specific patch, but I haven't been able to figure out which yet.

Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/dj4r0r1zz47hz3rnmxw7prbz1wc2gl15-source
source root is source
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
patching script interpreter paths in core/gnatcoll_core.gpr.py minimal/gnatcoll_minimal.gpr.py projects/gnatcoll_projects.gpr.py
core/gnatcoll_core.gpr.py: interpreter directive changed from "#!/usr/bin/env python" to "/nix/store/wfbjq35kxs6x83c3ncpfxdyl5gbhdx4h-python3-3.12.6/bin/python"
minimal/gnatcoll_minimal.gpr.py: interpreter directive changed from "#!/usr/bin/env python" to "/nix/store/wfbjq35kxs6x83c3ncpfxdyl5gbhdx4h-python3-3.12.6/bin/python"
projects/gnatcoll_projects.gpr.py: interpreter directive changed from "#!/usr/bin/env python" to "/nix/store/wfbjq35kxs6x83c3ncpfxdyl5gbhdx4h-python3-3.12.6/bin/python"
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: configurePhase
@nix { "action": "setPhase", "phase": "configurePhase" }
no configure script, doing nothing
Running phase: buildPhase
@nix { "action": "setPhase", "phase": "buildPhase" }
build flags: SHELL=/nix/store/717iy55ncqs0wmhdkwc5fg2vci5wbmq8-bash-5.2p32/bin/bash prefix=/nix/store/48dqfq4rx93d1yrqfzl3pndqp2n556fs-gnatcoll-core-25.0.0 PROCESSORS=\$\(NIX_BUILD_CORES\) TARGET=x86_64-unknown-linux-gnu GNATCOLL_MINIMAL_ONLY=no GNATCOLL_PROJECTS=yes
rm -rf local-install
mkdir -p local-install/share/gpr
sed -e 's/^--  with "gnatcoll_projects"/with "gnatcoll_projects"/g' .//gnatcoll.gpr > local-install/share/gpr/gnatcoll.gpr
.//minimal/gnatcoll_minimal.gpr.py build  --jobs=4 --build=PROD --target=x86_64-linux --prefix=local-install --install --enable-shared=yes
GNATCOLL_BUILD_MODE              := "PROD";
GNATCOLL_VERSION                 := "25.0";
GNATCOLL_OS                      := "unix";
['/nix/store/4lh1dppzjlgfj6nqki9y05a814lx1irr-gprbuild-25.0.0/bin/gprbuild', '--relocate-build-tree', '-P/build/source/minimal/gnatcoll_minimal.gpr', '-j4', '--target=x86_64-linux', '-XGNATCOLL_BUILD_MODE=PROD', '-XGNATCOLL_VERSION=25.0', '-XGNATCOLL_OS=unix', '-XLIBRARY_TYPE=static']
Setup
   [mkdir]        object directory for project GNATCOLL_Minimal
   [mkdir]        library directory for project GNATCOLL_Minimal
Compile
   [C]            gnatcoll_support.c
   [C]            getRSS.c
   [Ada]          gnatcoll.ads
   [Ada]          gnatcoll-tribooleans.adb
   [Ada]          gnatcoll-storage_pools.ads
   [Ada]          gnatcoll-storage_pools-headers.adb
   [Ada]          gnatcoll-storage_pools-alignment.adb
   [Ada]          gnatcoll-refcount.adb
   [Ada]          gnatcoll-refcount-weakref.adb
   [Ada]          gnatcoll-promises.adb
   [Ada]          gnatcoll-memory.adb
   [Ada]          gnatcoll-locks.adb
gnatcoll-refcount.ads:90:04: warning: in instantiation at gnatcoll-storage_pools-headers.adb:57 [enabled by default]
gnatcoll-refcount.ads:90:04: warning: possible aliasing problem for type "Header_Access" [enabled by default]
gnatcoll-refcount.ads:90:04: warning: use -fno-strict-aliasing switch for references [enabled by default]
gnatcoll-refcount.ads:90:04: warning: or use "pragma No_Strict_Aliasing (Header_Access);" [enabled by default]
   [Ada]          gnatcoll-damerau_levenshtein_generic.adb
   [Ada]          gnatcoll-damerau_levenshtein_distance.ads
   [Ada]          gnatcoll-coders.adb
   [Ada]          gnatcoll-coders-streams.adb
   [Ada]          gnatcoll-coders-base64.adb
   [Ada]          gnatcoll-boyer_moore.adb
   [Ada]          gnatcoll-atomic.adb
   [Ada]          gnatcoll-asserts.adb
   [Ada]          gnatcoll-any_types.adb
Build Libraries
   [gprlib]       gnatcoll_minimal.lexch
   [archive]      libgnatcoll_minimal.a
   [index]        libgnatcoll_minimal.a
['/nix/store/4lh1dppzjlgfj6nqki9y05a814lx1irr-gprbuild-25.0.0/bin/gprbuild', '--relocate-build-tree', '-P/build/source/minimal/gnatcoll_minimal.gpr', '-j4', '--target=x86_64-linux', '-XGNATCOLL_BUILD_MODE=PROD', '-XGNATCOLL_VERSION=25.0', '-XGNATCOLL_OS=unix', '-XLIBRARY_TYPE=relocatable']
Setup
   [mkdir]        object directory for project GNATCOLL_Minimal
   [mkdir]        library directory for project GNATCOLL_Minimal
Compile
   [C]            gnatcoll_support.c
   [C]            getRSS.c
   [Ada]          gnatcoll.ads
   [Ada]          gnatcoll-tribooleans.adb
   [Ada]          gnatcoll-storage_pools.ads
   [Ada]          gnatcoll-storage_pools-headers.adb
   [Ada]          gnatcoll-storage_pools-alignment.adb
   [Ada]          gnatcoll-refcount.adb
   [Ada]          gnatcoll-refcount-weakref.adb
   [Ada]          gnatcoll-promises.adb
   [Ada]          gnatcoll-memory.adb
gnatcoll-refcount.ads:90:04: warning: in instantiation at gnatcoll-storage_pools-headers.adb:57 [enabled by default]
gnatcoll-refcount.ads:90:04: warning: possible aliasing problem for type "Header_Access" [enabled by default]
gnatcoll-refcount.ads:90:04: warning: use -fno-strict-aliasing switch for references [enabled by default]
gnatcoll-refcount.ads:90:04: warning: or use "pragma No_Strict_Aliasing (Header_Access);" [enabled by default]
   [Ada]          gnatcoll-locks.adb
   [Ada]          gnatcoll-damerau_levenshtein_generic.adb
   [Ada]          gnatcoll-damerau_levenshtein_distance.ads
   [Ada]          gnatcoll-coders.adb
   [Ada]          gnatcoll-coders-streams.adb
   [Ada]          gnatcoll-coders-base64.adb
   [Ada]          gnatcoll-boyer_moore.adb
   [Ada]          gnatcoll-atomic.adb
   [Ada]          gnatcoll-asserts.adb
   [Ada]          gnatcoll-any_types.adb
Build Libraries
   [gprlib]       gnatcoll_minimal.lexch
   [link library] libgnatcoll_minimal.so
['/nix/store/4lh1dppzjlgfj6nqki9y05a814lx1irr-gprbuild-25.0.0/bin/gprbuild', '--relocate-build-tree', '-P/build/source/minimal/gnatcoll_minimal.gpr', '-j4', '--target=x86_64-linux', '-XGNATCOLL_BUILD_MODE=PROD', '-XGNATCOLL_VERSION=25.0', '-XGNATCOLL_OS=unix', '-XLIBRARY_TYPE=static-pic']
Setup
   [mkdir]        library directory for project GNATCOLL_Minimal
Build Libraries
   [gprlib]       gnatcoll_minimal.lexch
   [archive]      libgnatcoll_minimal.a
   [index]        libgnatcoll_minimal.a
['/nix/store/4lh1dppzjlgfj6nqki9y05a814lx1irr-gprbuild-25.0.0/bin/gprinstall', '--relocate-build-tree', '-P/build/source/minimal/gnatcoll_minimal.gpr', '--target=x86_64-linux', '-XGNATCOLL_BUILD_MODE=PROD', '-XGNATCOLL_VERSION=25.0', '-XGNATCOLL_OS=unix', '-p', '-f', '--prefix=/build/source/local-install', '--sources-subdir=include/gnatcoll_minimal', '-XLIBRARY_TYPE=static', '--build-name=static', '--build-var=LIBRARY_TYPE']
Install project GNATCOLL_Minimal - static
['/nix/store/4lh1dppzjlgfj6nqki9y05a814lx1irr-gprbuild-25.0.0/bin/gprinstall', '--relocate-build-tree', '-P/build/source/minimal/gnatcoll_minimal.gpr', '--target=x86_64-linux', '-XGNATCOLL_BUILD_MODE=PROD', '-XGNATCOLL_VERSION=25.0', '-XGNATCOLL_OS=unix', '-p', '-f', '--prefix=/build/source/local-install', '--sources-subdir=include/gnatcoll_minimal', '-XLIBRARY_TYPE=relocatable', '--build-name=relocatable', '--build-var=LIBRARY_TYPE']
Install project GNATCOLL_Minimal - relocatable
['/nix/store/4lh1dppzjlgfj6nqki9y05a814lx1irr-gprbuild-25.0.0/bin/gprinstall', '--relocate-build-tree', '-P/build/source/minimal/gnatcoll_minimal.gpr', '--target=x86_64-linux', '-XGNATCOLL_BUILD_MODE=PROD', '-XGNATCOLL_VERSION=25.0', '-XGNATCOLL_OS=unix', '-p', '-f', '--prefix=/build/source/local-install', '--sources-subdir=include/gnatcoll_minimal', '-XLIBRARY_TYPE=static-pic', '--build-name=static-pic', '--build-var=LIBRARY_TYPE']
Install project GNATCOLL_Minimal - static-pic
.//core/gnatcoll_core.gpr.py build  --jobs=4 --build=PROD --target=x86_64-linux --prefix=local-install --install --enable-shared=yes
blake3 implementation: x86_64-linux
xxhash implementation: x86_64
GNATCOLL_BLAKE3_ARCH             := "x86_64-linux";
GNATCOLL_XXHASH_ARCH             := "x86_64";
GNATCOLL_MMAP                    := "yes";
GNATCOLL_MADVISE                 := "yes";
GNATCOLL_VERSION                 := "25.0";
GNATCOLL_OS                      := "unix";
GNATCOLL_BUILD_MODE              := "PROD";
['/nix/store/4lh1dppzjlgfj6nqki9y05a814lx1irr-gprbuild-25.0.0/bin/gprbuild', '--relocate-build-tree', '-P/build/source/core/gnatcoll_core.gpr', '-j4', '--target=x86_64-linux', '-XGNATCOLL_BLAKE3_ARCH=x86_64-linux', '-XGNATCOLL_XXHASH_ARCH=x86_64', '-XGNATCOLL_MMAP=yes', '-XGNATCOLL_MADVISE=yes', '-XGNATCOLL_VERSION=25.0', '-XGNATCOLL_OS=unix', '-XGNATCOLL_BUILD_MODE=PROD', '-XLIBRARY_TYPE=static']
Setup
   [mkdir]        object directory for project GNATCOLL_Core
Compile
   [Asm_Cpp]      blake3_sse41_x86-64_unix.S
   [Asm_Cpp]      blake3_sse2_x86-64_unix.S
   [Asm_Cpp]      blake3_avx512_x86-64_unix.S
   [Asm_Cpp]      blake3_avx2_x86-64_unix.S
   [C]            xxh_x86dispatch.c
   [C]            process-wrappers.c
   [C]            libc-wrappers.c
   [C]            xxhash.c
/build/source/core/src/os/unix/process-wrappers.c: In function ‘__gnatcoll_wait_for_sigchld’:
/build/source/core/src/os/unix/process-wrappers.c:110:10: warning: ignoring return value of ‘read’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  110 |          read (fd, buf, 1);
      |          ^~~~~~~~~~~~~~~~~
/build/source/core/src/os/unix/process-wrappers.c: In function ‘__gnatcoll_write_on_sigchld’:
/build/source/core/src/os/unix/process-wrappers.c:122:7: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  122 |       write(MONITORING_FDS[i], "a", 1);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   [C]            blake3_portable.c
   [C]            blake3_dispatch.c
   [C]            blake3.c
   [C]            update_path.c
   [C]            terminals.c
   [C]            set_std_prefix.c
   [C]            separate_run_path_option.c
   [C]            run_path_option.c
   [C]            objlist_file.c
   [C]            link_max.c
   [C]            gnatcoll_support.c
   [C]            executable_path.c
   [Ada]          gnatcoll-os-libc.ads
   [Ada]          gnatcoll-os-libc-utime.ads
   [Ada]          gnatcoll-os-libc-stat.ads
   [Ada]          gnatcoll-os-libc-spawn.ads
   [Ada]          gnatcoll-os-libc-dirent.ads
   [Ada]          gnatcoll-hash-blake3.adb
   [Ada]          gnatcoll-hash.ads
   [Ada]          gnatcoll-paragraph_filling.adb
   [Ada]          gnatcoll-paragraph_filling-words.adb
   [Ada]          gnatcoll-paragraph_filling-badnesses.adb
   [Ada]          gnatcoll-os.ads
   [Ada]          gnatcoll-os-stat.adb
   [Ada]          gnatcoll-os-process.adb
   [Ada]          gnatcoll-os-fsutil.adb
   [Ada]          gnatcoll-os-fs.adb
   [Ada]          gnatcoll-os-dir.adb
   [Ada]          gnatcoll-wstring_list_builders.adb
   [Ada]          gnatcoll-wstring_builders.adb
   [Ada]          gnatcoll-vfs_utils.adb
   [Ada]          gnatcoll-vfs_types.ads
   [Ada]          gnatcoll-vfs.adb
   [Ada]          gnatcoll-utils.adb
   [Ada]          gnatcoll-traces.adb
   [Ada]          gnatcoll-terminal.adb
   [Ada]          gnatcoll-templates.adb
   [Ada]          gnatcoll-symbols.adb
   [Ada]          gnatcoll-strings_impl.adb
   [Ada]          gnatcoll-strings.ads
   [Ada]          gnatcoll-string_list_builders.adb
   [Ada]          gnatcoll-string_builders.adb
   [Ada]          gnatcoll-scripts.adb
   [Ada]          gnatcoll-scripts-utils.adb
   [Ada]          gnatcoll-scripts-impl.adb
   [Ada]          gnatcoll-remote.ads
   [Ada]          gnatcoll-remote-db.adb
   [Ada]          gnatcoll-random.adb
   [Ada]          gnatcoll-pools.adb
   [Ada]          gnatcoll-path.adb
   [Ada]          gnatcoll-opt_parse.adb
   [Ada]          gnatcoll-mmap.adb
   [Ada]          gnatcoll-json.adb
   [Ada]          gnatcoll-json-utility.adb
   [Ada]          gnatcoll-io.adb
+===========================GNAT BUG DETECTED==============================+
| 12.4.0 (x86_64-unknown-linux-gnu) GCC error:                             |
| in gnat_to_gnu_entity, at ada/gcc-interface/decl.cc:389                  |
| Error detected at gnatcoll-json.adb:669:14                               |
| Compiling /build/source/core/src/gnatcoll-json.adb                       |
| Please submit a bug report; see https://gcc.gnu.org/bugs/ .              |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact command that you entered.                              |
| Also include sources listed below.                                       |
+==========================================================================+

Please include these source files with error report
Note that list may not be accurate in some cases,
so please double check that the problem can still
be reproduced with the set of files listed.
Consider also -gnatd.n switch (see debug.adb).

/build/source/core/src/gnatcoll-json.adb
/build/source/core/src/gnatcoll-json.ads
/build/source/local-install/include/gnatcoll_minimal/gnatcoll.ads
/build/source/core/src/gnatcoll-strings.ads
/build/source/core/src/gnatcoll-strings_impl.ads
/build/source/local-install/include/gnatcoll_minimal/gnatcoll-atomic.ads
/build/source/core/src/gnatcoll-buffer.ads
/build/source/core/src/os/gnatcoll-os.ads
/build/source/core/src/os/gnatcoll-os-fs.ads
/build/source/core/src/gnatcoll-mmap.ads
/build/source/core/src/gnatcoll-json-utility.ads
/build/source/core/src/gnatcoll-string_builders.ads
/build/source/core/src/gnatcoll-strings_impl.adb
/build/source/local-install/include/gnatcoll_minimal/gnatcoll-refcount.ads
/build/source/local-install/include/gnatcoll_minimal/gnatcoll-storage_pools.ads
/build/source/local-install/include/gnatcoll_minimal/gnatcoll-storage_pools-headers.ads
/build/source/core/src/gnatcoll-buffer.adb
/build/source/core/src/os/gnatcoll-os-stat.ads
/build/source/core/src/gnatcoll-string_builders.adb
/build/source/local-install/include/gnatcoll_minimal/gnatcoll-atomic.adb

compilation abandoned

   compilation of gnatcoll-json.adb failed

gprbuild: *** compilation phase failed
make: *** [Makefile:110: build] Error 4
@Jicquel
Copy link
Collaborator

Jicquel commented Nov 7, 2024

Hi @sternenseemann, thank you for raising this issue. We'll work on addressing this one as well as the issue you mentioned here. We'll keep you updated!

adacore-bot pushed a commit that referenced this issue Nov 28, 2024
The previous code made gnatcoll-core's json package compilation fail
with GNAT 12. The bug has been fixed for GNAT >= 13.

Related github issue: #88
@Jicquel
Copy link
Collaborator

Jicquel commented Nov 28, 2024

Hello @sternenseemann, 515db1c should fix the issue. You can now use the master branch to compile gnatcoll-core with GNAT 12. I will close this issue, but feel free to re-open it if needed.

@Jicquel Jicquel closed this as completed Nov 28, 2024
@sternenseemann
Copy link
Author

Thanks!

@qunying
Copy link

qunying commented Dec 6, 2024

With #515db1c, I still have compile error with gcc 11.2. Inspire by the fix, I did a small modification and it compile fine now. It is based on v25.0.0

compile-error.patch.txt

@Jicquel
Copy link
Collaborator

Jicquel commented Dec 6, 2024

Hello @qunying , thank you for your contribution! Would you like to open a MR with your fix rebased on the master branch?

@Jicquel
Copy link
Collaborator

Jicquel commented Dec 10, 2024

Hello @qunying, I did not manage to reproduce the issue you encountered with GCC 11.2.

I confirm that without the 515db1c fix, I obtain the following error:

+===========================GNAT BUG DETECTED==============================+                                                 
| 11.2.0 (x86_64-pc-linux-gnu) GCC error:                                  |                                                                                                                                                                              
| in gnat_to_gnu_entity, at ada/gcc-interface/decl.c:382                   |                                                                                                                                                                              
| Error detected at gnatcoll-json.adb:669:14                               |                                                                                                                                                                              
| Please submit a bug report; see https://gcc.gnu.org/bugs/ .              |                                                                                                                                                                              
| Use a subject line meaningful to you and us to track the bug.            |                                                                                                                                                                              
| Include the entire contents of this bug box in the report.               |                                                                                                                                                                              
| Include the exact command that you entered.                              |                                                 
| Also include sources listed below.                                       |                                                 
+==========================================================================+  

and with the fix, the build works correctly. Could you double check that you reproduce the issue with the fix already merged ?
Thanks!

@qunying
Copy link

qunying commented Dec 10, 2024

Kind of strange, I got compile error after patching with 515db1c, that is why I did the modification, but now I could not reproduce it with 515db1c only.

@Jicquel
Copy link
Collaborator

Jicquel commented Dec 10, 2024

At least we are observing the same behavior, good news!
I will close this issue. Please reopen it if you identify what caused the issue locally, so we can proceed with merging your PR

@Jicquel Jicquel closed this as completed Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants