Arnold Robbins (author and maintainer of GNU gawk) and I have been
collaborating on testing of gawk development releases under the NUE
IA-64 environment, using both gcc 2.9-ia64-000216, and sgicc
0.01.0-13.
While the builds with gcc went as expected, the build with sgicc
failed. Some detective work found the cause, and its effect:
(1) The configure script tests whether the selected C compiler is GNU
gcc, not by name, but rather, by whether the symbol __GNUC__ is
known.
(2) Based on the outcome of that test, configure adds a gcc-specific
flag to LDFLAGS:
if test "$GCC" = yes
then
# Add others here as appropriate,
# one day use GNU libtool.
if uname | egrep -i linux > /dev/null
then
LDFLAGS="$LDFLAGS -rdynamic"
fi
fi
The -rdynamic flag is rarely seen, and indeed, even in this week's
latest gcc 3.x development snapshot, remains undocumented. gawk
uses it to support dynamic loading of modules for language
extensions.
(3) sgicc uses "gcc -E" as its preprocessor, and this results in
__GNUC__ being defined.
(4) While gcc recognizes -rdynamic and converts it to flags
-export-dynamic -dynamic-linker passed to the linker, collect2,
sgicc does not recognize -rdynamic, and linking fails.
Because of the rarity of the -rdynamic switch, very few programs would
ever uncover this problem.
Two fixes are possible:
(1) When sgicc invokes "gcc -E" for the preprocessing step, do it as
"gcc -E -U__GNUC__". This fixes the gawk build problem, since
% env CC='sgicc -U__GNUC__' ./configure
produces a Makefile that does not use -rdynamic.
(2) Extend sgicc to recognize -rdynamic.
Fix (1) is certainly the easiest, and will ensure that other
dependencies on the symbol __GNU__ in configure scripts and inside
source code will not be foiled by suggesting that a gcc extension is
available, when in fact, the host compiler is completely different,
and the extension is not there.
Fix (2) is less desirable, since leaving __GNUC__ defined can have
other side effects, as noted in the previous paragraph. However, it
still may be useful to add support for -rdynamic, possibly under a
different name, provided __GNUC__ remains undefined.
-------------------------------------------------------------------------------
- Nelson H. F. Beebe Tel: +1 801 581 5254 -
- Center for Scientific Computing FAX: +1 801 585 1640, +1 801 581 4148 -
- University of Utah Internet e-mail: beebe@xxxxxxxxxxxxx -
- Department of Mathematics, 322 INSCC beebe@xxxxxxx beebe@xxxxxxxxxxxx -
- 155 S 1400 E RM 233 beebe@xxxxxxxx -
- Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe -
-------------------------------------------------------------------------------
|