From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: * X-Spam-Status: No, score=1.1 required=3.0 tests=BAYES_00,FROM_SUSPICIOUS_NTLD, FROM_SUSPICIOUS_NTLD_FP,PDS_OTHER_BAD_TLD autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!tmr9BI+uueYJMT3TC5a5oA.user.46.165.242.75.POSTED!not-for-mail From: Fernando Oleo Blanco Newsgroups: comp.lang.ada Subject: Help: Ada in NetBSD Date: Sun, 29 Aug 2021 13:06:53 +0200 Organization: Aioe.org NNTP Server Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: gioia.aioe.org; logging-data="42901"; posting-host="tmr9BI+uueYJMT3TC5a5oA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.0.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:62571 List-Id: Dear All, I have been trying for the past few months to make GCC/Ada work in NetBSD. I am writing this message to you since I have been stuck in a roadblock for far too long and without concrete answers. Long story short: JMarino, within the Aurora project, already ported GCC/Ada to a lot of systems, namely FreeBSD, DragonflyBSD, NetBSD and Solaris. The last version that works without friction in NetBSD/pkgsrc is GCC v6. I wanted to update GCC to v10 (10.3.0). So, one can compile GCC v10 with C, C++ and Ada support with v6 without any issues. The biggest problem is that the RT (RunTime Files) had no configuration for NetBSD (see the original Makefile.rtl in the gcc/ada directory). I fixed it by copying the FreeBSD support files and modifying a imported C function to be POSIX compilant, since NetBSD did not had the function that FreeBSD used (related to pthreads). The results of compiling GCC v10 with this "small" change are documented in a blog entry I did: https://www.irvise.xyz/Projects%20&%20Engineering/updating-gcc-ada-pkgsrc.html TL;DR: GCC v10 compiles and can generate binaries!!! :D But... The tasking system is not working correctly (I have been testing the compiler with the ACATS test suite provided by Simon). The linker complains about some C functions not being correctly imported within Ada files. And the programs where the linker complains, once compiled, tend to get blocked or die. Here is one such example: /usr/bin/ld: /home/fernando/mysandboxfolder/usr/pkg/gcc10/lib/gcc/x86_64--netbsd/10.3.0/adalib/libgnat.a(s-osprim.o): in function `system__os_primitives__clock': /usr/pkgsrc/wip/gcc10-aux/work/build/gcc/ada/rts/s-osprim.adb:91: warning: warning: reference to compatibility gettimeofday(); include to generate correct reference As you can see, the linker says that, in this case, gettimeofday() is not correctly referenced and that I should include . Notice, it is complaining that the file s-osprim.adb, and Ada file, is at fault here. This happens to all files that use the tasking system in one way or another, so, in summary, all large projects, such as GPRBuild. I thought that an #include may have been missing from a C source file that is required to build the Ada compiler. After all, there were some defined (__NetBSD__) missing from the Ada sources. I added those. Nothing. I took a really good look at JMarino's patches: http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/lang/gcc6-aux/files/diff-ada?rev=1.1&content-type=text/x-cvsweb-markup I applied some extra changes (the configure/configure.ac patches are failing to apply). Still nothing, it keeps failing. I have been looking for the "missing" #include files, they are , and . I searched through the code, there are few occurrences of them and, for example, only appears in a legacy system. I checked the C signature files to make sure that they were also correct in the Ada sources, and they seem to match. I am out of ideas. How come the linker complains about those functions and not the other imported C ones? These files are automatically included with -lc. How could I go about fixing this issue? Any ideas, pointers? Below are the patches that I have created. If you are wondering why am I doing this: I like alternative systems, Ada is portable on paper, but what about in reality? And my end goal would be to see Ada everywhere and upstream these fixes to GCC. Thank you for your time, ------- --- gcc/ada/adaint.c.orig 2021-08-28 18:39:27.509714592 +0000 +++ gcc/ada/adaint.c 2021-08-28 18:40:44.190149364 +0000 @@ -817,7 +817,8 @@ } #if defined (_WIN32) || defined (__linux__) || defined (__sun__) \ - || defined (__FreeBSD__) || defined(__DragonFly__) || defined (__QNX__) + || defined (__FreeBSD__) || defined(__DragonFly__) || defined (__QNX__) \ + || defined (__NetBSD__) #define HAS_TARGET_WCHAR_T #endif --- gcc/ada/cstreams.c.orig 2021-08-28 18:42:21.323680378 +0000 +++ gcc/ada/cstreams.c 2021-08-28 18:43:48.045445919 +0000 @@ -188,7 +188,8 @@ *p = '\\'; } -#elif defined (__FreeBSD__) || defined (__DragonFly__) || defined (__OpenBSD__) +#elif defined (__FreeBSD__) || defined (__DragonFly__) \ + || defined (__OpenBSD__) || defined (__NetBSD__) /* Use realpath function which resolves links and references to . and .. on those Unix systems that support it. Note that GNU/Linux provides it but @@ -270,7 +271,7 @@ } #elif defined (__linux__) || defined (__sun__) || defined (__FreeBSD__) \ - || defined (__APPLE__) + || defined (__APPLE__) || defined (__NetBSD__) /* section for platforms having ftello/fseeko */ __int64 --- gcc/ada/init.c.orig 2021-08-28 20:28:13.261558335 +0000 +++ gcc/ada/init.c 2021-08-28 20:29:48.573288829 +0000 @@ -2183,6 +2183,8 @@ #include #include +#include +#include static void __gnat_error_handler (int sig) --- gcc/ada/s-oscons-tmplt.c.orig 2021-08-28 18:50:50.086632028 +0000 +++ gcc/ada/s-oscons-tmplt.c 2021-08-28 18:53:35.037358487 +0000 @@ -406,9 +406,11 @@ */ -/* ioctl(2) requests are "int" in UNIX, but "unsigned long" on FreeBSD */ +/* ioctl(2) requests are "int" in UNIX, but "unsigned long" on FreeBSD + and NetBSD +*/ -#if defined (__FreeBSD__) || defined (__DragonFly__) +#if defined (__FreeBSD__) || defined (__DragonFly__) || defined (__NetBSD__) # define CNI CNU # define IOCTL_Req_T "Interfaces.C.unsigned" #else @@ -1020,7 +1022,8 @@ */ -#if defined (__FreeBSD__) || defined (__linux__) || defined (__DragonFly__) +#if defined (__FreeBSD__) || defined (__linux__) || defined (__DragonFly__) \ + || defined (__NetBSD__) # define PTY_Library "-lutil" #else # define PTY_Library "" @@ -1833,7 +1836,8 @@ #if defined(__linux__) || defined(__FreeBSD__) \ || (defined(_AIX) && defined(_AIXVERSION_530)) \ - || defined(__DragonFly__) || defined(__QNX__) + || defined(__DragonFly__) || defined(__QNX__) \ + || defined (__NetBSD__) /** On these platforms use system provided monotonic clock instead of ** the default CLOCK_REALTIME. We then need to set up cond var attributes ** appropriately (see thread.c). --- gcc/ada/sysdep.c.orig 2021-08-28 13:11:25.681014624 +0000 +++ gcc/ada/sysdep.c 2021-08-28 13:21:14.748176113 +0000 @@ -320,7 +320,7 @@ || (defined (__svr4__) && defined (__i386__)) || defined (__Lynx__) \ || defined (__CYGWIN__) || defined (__FreeBSD__) || defined (__OpenBSD__) \ || defined (__GLIBC__) || defined (__APPLE__) || defined (__DragonFly__) \ - || defined (__QNX__) + || defined (__QNX__) || defined (__NetBSD__) # ifdef __MINGW32__ # if OLD_MINGW @@ -373,7 +373,7 @@ || defined (_AIX) || (defined (__svr4__) && defined (__i386__)) \ || defined (__Lynx__) || defined (__FreeBSD__) || defined (__OpenBSD__) \ || defined (__GLIBC__) || defined (__APPLE__) || defined (__DragonFly__) \ - || defined (__QNX__) + || defined (__QNX__) || defined (__NetBSD__) char c; int nread; int good_one = 0; @@ -394,7 +394,7 @@ || defined (_AIX) || (defined (__svr4__) && defined (__i386__)) \ || defined (__Lynx__) || defined (__FreeBSD__) || defined (__OpenBSD__) \ || defined (__GLIBC__) || defined (__APPLE__) || defined (__DragonFly__) \ - || defined (__QNX__) + || defined (__QNX__) || defined (__NetBSD__) eof_ch = termios_rec.c_cc[VEOF]; /* If waiting (i.e. Get_Immediate (Char)), set MIN = 1 and wait for @@ -831,7 +831,7 @@ #elif defined (__APPLE__) || defined (__FreeBSD__) || defined (__linux__) \ || defined (__GLIBC__) || defined (__DragonFly__) || defined (__OpenBSD__) \ - || defined (__DJGPP__) || defined (__QNX__) + || defined (__DJGPP__) || defined (__QNX__) || defined (__NetBSD__) { localtime_r (timer, &tp); *off = tp.tm_gmtoff; ------- -- Fernando Oleo Blanco https://irvise.xyz