Opened 8 years ago

Last modified 21 months ago

#50953 new enhancement

gambit-c @4.7.6 Change compiler and add desirable ./configure option — at Version 1

Reported by: somebody-237654 Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 2.3.4
Keywords: haspatch Cc:
Port: gambit-c

Description (last modified by ryandesign (Ryan Carsten Schmidt))

Executive Summary:

The Gambit-C package should be compiled using recent versions of the “macports-gcc” compiler package. Note that I am deliberately distinguishing between the Apple version of GCC (“gcc-4.0”, “apple-gcc-4.0”, etc.) and the purer MacPorts version. Additionally, the “--enable-single-host” option should be specified to the “./configure” script when gambit is built.

Justification:

The Gambit-C package is a high-performance interpreter and compiler for the Scheme (LISP-family) programming language. The gambit compiler works by first translating Scheme source code into C code, which is then compiled using the system’s C compiler. Because Scheme programs can have a very nonlinear flow of control, including advanced features such as first class continuations, the C code produced by the gambit compiler is complicated and not intended for human consumption - it is an intermediate form generated by one compiler for another compiler, principally consisting of a single, exceedingly large, C function (a “trampoline” function).

Note that the gambit compiler itself is mostly written in Scheme, so the choice of C compiler affects the building of the gambit package by the Macports buildbot, not just the usage of the gambit package by the end user.

The complex nature of the intermediate C code generated by gambit tests the limits of even modern C compilers. My recommendation that the purest version of GCC (“macports-gcc”) be used to compile gambit is not based on compiler favouritism; past versions of all of the common compilers, GCC, LLVM, clang, and the Apple versions of these compilers, have had troubles compiling gambit C code in the past. But the original author of gambit “highly recommends” using GCC [see 1]. And currently it seems that recent versions [4] of the GCC compiler perform the best, and the difference between GCC and the other compilers is significant (30 times faster to compiler the gambit scheme compiler than even the Apple GCC compiler!) [3].

Lastly, I would argue that the “--enable-single-host” option should be specified to “./configure” when gambit is built because this option dramatically improves the efficiency of the compiled code, and because this option is highly recommended by the original author of the gambit package [2]. Note that adding “--enable-single-host” increases the time needed to compile gambit, and this has caused problems for the macports buildbot in the past, when the pure macports gcc compiler was not used [for example, see #46013]. The improvement in compile-time when using the macports-gcc package should more than offset the increased build time incurred by highly desirable “--enable-single-host” option.

- William

Notes:

From: http://gambitscheme.org/wiki/index.php/Configure_script_options

[1] “It is also highly recommended to use the GCC compiler to build the system as the source code can take advantage of some GCC extensions. Notably the use of GCC's computed gotos reduces the execution time by roughly 35%.”

[2] “It is highly recommended to use the --enable-single-host option to improve the execution speed and compactness of the executables … [for example] the speed of the Gambit-C interpreter improves by a factor of 2 as a result.”

[3] From: https://webmail.iro.umontreal.ca/pipermail/gambit-list/2015-January/007698.html

“As can be seen, the Apple C compilers build Gambit in roughly 30 minutes, which is about 30x slower than when using GNU gcc 4.9.2 . The execution time is also better for GNU gcc, about 2.3x faster. So on OS X it is clearly advantageous to install GNU gcc when using Gambit.”

[4] From: https://github.com/Homebrew/homebrew/commit/beb68f8a63243587ea736fd61e7cea2af4fdf9ab#Library/Formula/gambit-scheme.rb

“don't try to build with GCC 4.2 or 4.3 … requires absurd amounts of RAM”

Change History (1)

comment:1 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: macports@… removed
Description: modified (diff)
Keywords: haspatch added

The compiler value macports-gcc means "the version of FSF gcc selected by the user by running sudo port select gcc". No port should specify this compiler value, because it would result in the port building differently depending on which compiler the user has selected (see ReproducibleBuilds), and causing the port to fail to build on the buildbot and for any users who have not selected any gcc. In my opinion, MacPorts should not offer macports-gcc as a possible value for configure.compiler.

Ports that need to use FSF gcc should offer variants so the user can choose which version of FSF gcc to use, with one (usually the most recent stable version, which at the present time is gcc5) being the default. The compilers 1.0 portgroup should be used to offer these variants.

Using FSF gcc is problematic on OS X because software built with it will use FSF gcc's libgcc_s. On non OS X systems this is not a problem because the OS and everything else is already using that libgcc_s. On OS X, the OS and software compiled using clang, llvm-gcc or Apple gcc use Apple's copy of libgcc_s, a.k.a. libSystem, which might not be 100% compatible with FSF gcc's. I don't know what effect these issues might have on gambit-c or other software that might be built using gambit-c but it is the usual reason why we do not use FSF gcc, even if upstream developers state that it is preferred, because upstream developers often do not understand this nuanced situation as it applies to OS X.

Additional complications arise if any C++ code is used; see wiki:FAQ#libcpp. (I don't know if gambit-c uses any C++.)

Note: See TracTickets for help on using tickets.