DragonLace.Net
Home of the GNAT AUX and future DRACO Ada compilers.
System Arch Test Failures Snapshot Status Download GNAT AUX
DragonFly i386 None 2011-03-25 Perfect Available via pkgsrc
DragonFly x86_64 None 2011-03-25 Perfect Available via pkgsrc
FreeBSD i386 None 2011-03-25 Perfect Available via ports
FreeBSD x86_64 None 2011-03-25 Perfect Available via ports
NetBSD i386 None 2011-03-25 Perfect Available via pkgsrc
NetBSD x86_64 None 2011-03-25 Perfect Available via pkgsrc
OpenBSD i386 1 Failure 2011-01-04+ Excellent OpenBSD32 4.7 binary
OpenBSD x86_64 1 Failure 2011-03-25 Excellent OpenBSD64 4.8 binary
OpenIndiana i386 None 2011-06-27 Perfect bootstrap compiler
Android 2.3+ ARM None (ACATS only) 2011-06-27 Perfect FreeBSD ports
Posted Sun Nov 14 13:41:39 2010

To fix Ada tasking in FreeBSD 9.0, you have to fix and rebuild the thread library.

Before you start, make sure you have the FreeBSD 9.0 source at /usr/src. If you didn't install it with FreeBSD, you can find src.txz on the install disk. Alternatively, you can download the 89MB file directly from FreeBSD Just extract it in the root directory as it starts with /usr.

  1. Obtain the patch from DragonLace
  2. Apply the patch to /usr/src/lib/libthr/thread/thr_setscheduleparam.c
  3. > cd /usr/src/lib/libthr
  4. > make depend
  5. > make
  6. > make install

Now Ada tasking should function correctly on FreeBSD 9.0. This has already been fixed for the upcoming FreeBSD 9.1.

Posted Thu Jul 26 04:32:09 2012

Quite a few months ago, I discovered that Ada tasking was broken on FreeBSD 9.0. Whenever a task would exit, the system would respond with "thread exits with resources held!" I noticed there was a new panic assertion in the thread library, so my first inclination was that GNAT was misbehaving on all POSIX machines, but only FreeBSD was detecting it. I was a little annoyed that new check actually caused a regression. Since I detected this on the GCC 4.6-based GNAT-Aux, the Adacore folks told me to check GCC 4.7 before they'd take it further. Fair enough.

After porting GCC 4.7 to FreeBSD (it's a new port called lang/gcc-aux), I confirmed that tasking was still broken. After more prodding by Adacore, I also confirmed that the same panic check did not break tasking in DragonFly. Oh Uh, this looks like a FreeBSD problem, not a GNAT bug. Sure enough, it was a bug in FreeBSD 9.0. It's been fixed now, so tasking will work on gnat-aux and gcc-aux on FreeBSD 9.1. A follow-up post will describe how to fix and rebuild the FreeBSD 9.0 thread library.

A second problem was discovered with the AMD64 platform (i386 platform is unaffected). All the stack-check and dereference tests would fail on gnat-aux and gcc-aux on FreeBSD 9.0 AMD64. It turns out that in order to support non-executable stacks (an option only available on AMD64), the signal trampoline had to be moved from just prior to the PS_STRINGS location to a shared page. This caused the end-of-stack detection in the FreeBSD unwind code to fail. A signal trampoline pattern match similar to what is done for NetBSD had to be created for FreeBSD 9.0 AMD. This fix will be included in the first port of gcc-aux.

Posted Thu Jul 26 04:32:09 2012

The following issue is probably not widely known so I'll explain what it was, what platforms it affected, and how it was solved.

The problem was that you couldn't build GCC to support both Ada and C/C++ with long double support perfectly on x86 FreeBSD and x86 DragonFly platforms. You had to choose which language you wanted to provide correct precision: Ada or C/C++. You couldn't have both correct on these platforms.

The reason is that FreeBSD's floating point unit on the i386 platform rounds long doubles down to 53-bit mantissas. GCC knows that FreeBSD does this on its x386 platform and compensates for it. There is a macro for the GCC configuration files called TARGET_96_ROUND_53_LONG_DOUBLE. The default value for this macro is zero (false), but for x86 FreeBSD (and by inheritance, x86 DragonFly), this value must be true. If you build GCC on x86 FreeBSD with this macro set to zero, the results of run time long double calculations (e.g. add, subtract, square root) will be different than expected.

Unfortunately, if you build GCC on x86 FreeBSD with this macro set to 1 (true), then GNAT will fails some precision tests. As long as the builder doesn't build GCC with both GNAT and C++, he could tailor TARGET_96_ROUND_53_LONG_DOUBLE to one language.

Over time, people asked GNAT-AUX and it's successor GCC-AUX to support more than Ada. Currently they support C++, Fortran, and Objective-C as well as the base C language. It was tailored to Ada, so long double calculations with these compilers were suspect. How could it be fixed? The same backend was common to both compiler front ends, presented as libbackend.a during the build.

The solution was to first isolate the source file that initializes the FPU. That file is insn-modes.c, which is generated. During the build, that file is now duplicated and edited to produce insn-modes-ada.c, which ignores the value of TARGET_96_ROUND_53_LONG_DOUBLE (the same as if it were set to false). The object file from this source file is now keep out of the libbackend.a library, but passed along separately to each language front end. The Ada front end gets passed the insn-modes-ada.o object file instead.

That's how the new GCC-AUX compiler (based on gcc-4.7.1) maintains precision quality with both GNAT and the C++ front-end simultaneously. This fix is already available in PKGSRC, and soon I hope to submit a new lang/gcc-aux port for FreeBSD. I'll also publish a comprehensive set of testsuite results that cover all languages and several Operating System / CPU combinations (e.g NetBSD, FreeBSD, DragonFly, OpenSolaris with x86 and x86_64 CPUs).

Posted Sun Jul 15 14:53:57 2012

GCC 4.7 has been available for quite some time. In fact, GCC 4.7.1 was released in mid-June. Originally GNAT AUX was intended to follow the latest trunk, and when that was discovered to be problematic, it was intended to follow the latest release of the latest major branch.

Now even that approach is problematic. For pkgsrc, DragonFly uses GNAT AUX as their way of building DragonFly world and kernel with a GCC 4.6 compiler. For FreeBSD, the GNATDROID cross compilers (and possibly other cross compilers in the future) are based on it. Furthermore, the GNAT AUX port/package are based on individual language tarballs which GCC discontinued after 4.6, so the entire makefile would have to be reworked again to use one monolithic tarball.

An additional problem is GNAT AUX installs at ${LOCALBASE} which means several libraries and binaries would conflict with other GCC-based ports installed there.

To address all these problems, a new compiler package, lang/gcc-aux, was created. It is based on GCC 4.7.1 and installs at ${LOCALBASE}/gcc-aux to avoid file conflicts. It is intended to migrate to GCC 4.8 in the future, so like GNAT AUX, it has a date as a version (currently 20120614).

The pkgsrc make file system was altered to recognize USE_LANGUAGES+= ada. This means that it is no longer required to specify a certain compiler for Ada-based packages. All the Ada packages, including Florist, were updated update to build with lang/gcc-aux instead of lang/gnat_aux.

At the same time, GPRBUILD was updated to version GPL 2012 and Florist was updated from version 3.15p to version GPL 2012. Future updates to xmlada, gtkada, and GPS are coming soon to pkgsrc.

These updates are not yet available for FreeBSD.

Posted Wed Jul 11 07:42:49 2012

GnatDroid on FreeBSD has been updated build from GCC 4.6.3 on both ARMv5 and ARMv7. Now that the FreeBSD GNAT-AUX port is modular, the GnatDroid ports should automatically upgrade with GNAT-AUX is upgraded.

gnatdroid-armv5 20120301
gnatdroid-armv7 20120301

GnatDroid now supports Fortran and Objective-C as another benefit of the port modularity. These additional languages are not built by default, but they are easily activated when building GnatDroid from source. An option configuration screen will appear after "make" command allowing GnatDroid to support one or both of these extra languages. The screen can be forced to appear later with the "make config" command.

C++ is not yet supported as it is in GNAT-AUX. There is a build error on this language that needs to be examined in depth before C++ support can be added.

Posted Sat May 5 03:35:31 2012

GCC 4.6.3 was released on 1 March 2012. Due to recent work on the gnat-aux package, it was relatively easy to update the pkgsrc version of gnat-aux to version 20120301 which syncs with GCC Release 4.6.3. It has already been tested and committed to the pkgsrc CVS trunk.

The same can't be said for the FreeBSD version. The port updated okay, and would work fine on FreeBSD 8.x and below, but it's failing FreeBSD 9.0 ACATS testsuite. It turns out that version 4.6.2 was failing as well. Specifically 23 tasking tests are failing with "Fatal error 'thread exits with resources held!'". This is caused by an update to the thread library that detects this sort of thing and FreeBSD 9.0 is the first version to use the updated library.

I will try to modify GNAT to free the thread's resources so that tasking for FreeBSD will work. Also, the gnatdroid port will use part of the gnat-aux makefiles and patches so that it will automatically update when gnat-aux updates. It is still at gcc version 4.6.1, but an update for that port will follow shortly after gnat-aux is fixed.

Posted Fri Mar 2 10:23:33 2012

This has been a long time coming, but the upgrade of GNAT-Aux to version 4.6.2 was not straight-forward. First, two more languages were added: Fortran and Objective-C. As a result of added these two languages and running their testsuites, platform misconfigurations were uncovered, and fixing them is a long iterative process.

The second major change is that custom tarballs are no longer used. Instead, the basis for the compiler are official GCC releases and then GNAT-AUX changes are applied as patches on top of that. This has two benefits: It will be easier to move to GCC 4.7.0 when it is released and it will be easier to isolate patches to send back to FSF to permanently incorporate into the code base.

Both additional languages and patch isolation have been requested, so this important upgrade satisfies those requests.

  • FreeBSD: PR to upgrade ports submitted: PR 163914
  • DragonFly, NetBSD, OpenIndiana: Available on pkgsrc-trunk lang/gnat-aux It was committed after the 2011Q4 freeze was complete, so if one needs it before 2012Q1 branch is released, they'll have to get it from pkgsrc-trunk.

Test results

Test results over 5 languages on 9 platforms are available on this report. From an Ada view, all pkgsrc and ports platforms still pass 100%.

Posted Sun Jan 8 07:55:19 2012

Unfortunately, OpenSolaris died when Oracle took over Sun Microsystems. However, out of the ashes rose the Illumos project, which took over powering platforms like Nexenta and spawned new distributions such as OpenIndiana. The Illumos-powered platforms gained Pkgsrc through the Illumos Pkgsrc Project, which boasted an impressive 6600 built packages soon after getting launched.

GNAT-AUX was already available on Pkgsrc, but it only works on platforms in which a bootstrap compiler is provided. Before this week, this covered exactly four platforms:

  • x86 NetBSD
  • x86 DragonFly
  • x86_64 NetBSD
  • x86_64 DragonFly

I had previously built a flawless GNAT-AUX on an obsolete OpenSolaris version SXCE 130. It was fairly trivial to built a static bootstrap compiler on the latest version of OpenIndiana (oi_151a).

The lang/gnat-aux package has been updated to support the x86 Solaris target, and also updates all supported platforms to provide working runtime symbolic traceback. It just missed the 2011Q3 branch, so it's only available in the pkgsrc trunk.

Posted Wed Oct 5 13:31:14 2011

After the GNATDroid compiler passed the ACATS testsuite flawlessly, it was submitted officially to the FreeBSD ports tree. It can sometimes take months for new ports to make it through the submission process, but the GNATDroid ports got approved and committed within a week. We are very grateful to FreeBSD committer Frederic Culot for the special attention he affords these Ada ports, and we can't express our appreciation enough.

So now FreeBSD users can obtain the ports through the normal method (e.g. portsnap fetch update) and install the cross-compiler like any other FreeBSD software (e.g. cd /usr/ports/lang/gnatdroid-armv7 && make install). Now its up to you guys to utilize the strength of Ada on the Android platform.

Posted Wed Sep 7 10:52:57 2011

I finally acquired an Android device, a nice ASUS Transformer TF101 equipped with an NVIDIA Tegra2 dual-core CPU. After building GNATDroid-ARMv7, I confirmed that I could compile Ada programs on FreeBSD and execute them on the Android tablet.

After some trial and error, I modified the ACATS test suite to execute the tests remotely on the transformer. After the first run, 57 tests failed with the same error. It turns out that the default location for temporary files (/tmp) doesn't exist on Android. I patched GNATDroid to first attempt to create temporary files at $ANDROID_DATA/local/tmp (/data/local/tmp) which normally requires a rooted device, and then try $EXTERNAL_STORAGE/ (/sdcard) which would require that the user permissions can write to that area.

With that update, the temporary files could be created and the GNATDroid passed the ACATS testsuite without a single failure. Modifying Dejagnu test harness is a little trickier, so the gnat.dg testsuite still hasn't been run. In any case, the confidence in this cross-compiler is now quite high and these ports can be officially submitted to FreeBSD.

The tarball and signature file referenced in the previous post have been updated to include the patch for adaint.c which controls the temporary file creation. If you have already built GNATDroid, you may wish to deinstall it, re-extract the files, and then rebuild it.

-- John

Posted Sat Aug 20 11:03:08 2011
Last edited Mon Nov 15 01:46:57 2010
© 2010 John Marino | design elements by styleshout | artwork by Arturo Aguirre