stcarrez / ada-util

Ada Utility Library - Composing streams, processes, logs, serialization, encoders and more
Apache License 2.0
69 stars 14 forks source link

Can't use Ada-Util under GCC 10 #23

Closed WinterAlexander closed 1 year ago

WinterAlexander commented 2 years ago

System: Dockerized Ubuntu 21 under ArchLinux host machine, both x86_84 Ada Util Version: 2.4.1

Compilation of an example project that uses Ada-Util fails for GCC 10 only, GCC 9, 11 and 12 have no issue. The problem seems to be located in the properties part of the library, despite the example only using the HTTP part of the library.

Question 1: Do you care to fix this? Question 2: Is there a way to fully exclude util-properties from the project when using the HTTP module?

The error in question:

util-properties.ads:301:50: missing ";"
util-properties.ads:304:38: "Manager_Type" is undefined (more references follow)
util-properties.ads:307:10: subprogram "Is_Shared" is not overriding
util-properties.ads:310:10: subprogram "Set_Shared" is not overriding
util-properties.ads:314:10: subprogram "Adjust" is not overriding
util-properties.ads:317:10: subprogram "Finalize" is not overriding

Here is a minimal reproducible example (using docker). To run it, create the 3 files Dockerfile, example.adb and example.gpr as the following:

Dockerfile:

FROM ubuntu:hirsute
MAINTAINER Alexander Winter <alexander@latencetech.com>

ENV ADA_UTIL_VERSION=2.4.1

RUN apt-get update --fix-missing && apt-get install -y gnat-10 gprbuild gcc-10 make autoconf wget unzip libcurl4-openssl-dev
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10

# Ada Util
WORKDIR / 
RUN wget https://github.com/stcarrez/ada-util/archive/refs/tags/$ADA_UTIL_VERSION.zip
RUN unzip $ADA_UTIL_VERSION.zip
WORKDIR /ada-util-$ADA_UTIL_VERSION
RUN ./configure
RUN make
RUN make test
RUN make install prefix=/usr

example.adb:

with Ada.Text_IO;
with Util.Http.Clients;
with Util.Http.Clients.Curl;

procedure Example is
begin
    Util.Http.Clients.Curl.Register;
    declare
        Http     : Util.Http.Clients.Client;
        Response : Util.Http.Clients.Response;
    begin
        Http.Add_Header ("X-Requested-By", "wget");
        Http.Get ("http://www.google.com", Response);
        Ada.Text_IO.Put_Line(Response.Get_Body);
    end;
end Example;

example.gpr:

with "utilada_http";
with "utilada_curl";

project Example is
    type Mode_Type is ("debug", "release");         
    Mode : Mode_Type := external ("mode", "debug"); 

    for Languages use ("Ada");
    for Source_Dirs use ("./");
    for Object_Dir use "obj";
    for Exec_Dir use "bin";
    for Main use ("example.adb");

    package Compiler is
        case Mode is
            when "debug" =>
                for Default_Switches ("Ada") use ("-g", "-gnatX");
            when "release" => 
                for Default_Switches ("Ada") use ("-gnatX", "-O3");
        end case;
    end Compiler;

    package Binder is
        case Mode is
            when "debug" =>
                for Default_Switches ("Ada") use ("-E");
        end case;
    end Binder;
end Example;

Then run from the same directory:

docker build -t example .
docker run --rm -v $(pwd):/build example:latest gprbuild -d -p /build/example.gpr

Best, Alexander Winter

stcarrez commented 2 years ago

Ada Util 2.4.1 builds fine on Debian 11 which is using gcc 10.2.1.

The Util.Properties package is one of the oldest package provided by the library and it has always compiled successfully starting with gcc 4.7 up to now with gcc 12. There is something very suspicious because there is nothing terrific and wrong on line util-properties.ads:301 since line 301 declares the Manager_Type:

     generic
         type Manager_Type is limited new Manager with private;
      package Shared_Implementation is

I'm not able to reproduce your error. I've tried several versions of the compiler including gcc 10.2

I'm in the process of preparing the 2.5.0 release. Would it be possible to check with the latest sources?

stcarrez commented 1 year ago

Fixed.