Improving underscore detection
Alexandre Oliva
kaffe@rufus.w3.org
15 Aug 1998 22:00:09 -0300
--Multipart_Sat_Aug_15_22:00:10_1998-1
Content-Type: text/plain; charset=US-ASCII
Hi!
Petter Reinholdtsen <pere@cc.uit.no> has just called my attention to
the underscore detection mechanism of Kaffe. There's much room for
improvement.
First of all, the C code that detects whether the C compiler inserts
underscores needs not be executed; linking is enough, so the attached
patch does exactly that, which allows the test to be performed even
when cross-compiling. I've tested it on several platforms, and the
existing functionality was retained.
The second issue has to do with the code that tests whether dlopen
needs leading underscores in symbol names. On SunOS 4.1.3, leading
underscores are optional (but it's better to use them). However, the
test fails to run because dlopen() cannot be used to link libc in.
This problem may explain why Kaffe can't run on SunOS 4.1.3; I'll
investigate.
The correct approach, that is taken by Japhar, is to created a shared
library that defines a known symbol, create a test program that
dlopen()s the just-created library and tries to find the symbol in it.
If we used libtool in Kaffe, the test used in Japhar could be simply
copied into Kaffe. I can do that for sure, because I contributed
myself the test code to Japhar.
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil
--Multipart_Sat_Aug_15_22:00:10_1998-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="underscore.diff"
Content-Transfer-Encoding: 7bit
Alexandre Oliva <oliva@dcc.unicamp.br>
* configure.in (ac_cv_underscore_c_names): no need to run the
test; linking is enough, and allows it to run even when cross
compiling
Index: configure.in
===================================================================
RCS file: /home/cvspublic/kaffe/configure.in,v
retrieving revision 1.15
diff -u -r1.15 configure.in
--- configure.in 1998/08/06 21:50:50 1.15
+++ configure.in 1998/08/16 00:46:48
@@ -611,8 +611,9 @@
dnl Some C compilers add '_' to C names.
dnl -------------------------------------------------------------------------
AC_CACHE_CHECK(for underscore in C assembly names, ac_cv_underscore_c_names,
-AC_TRY_RUN(extern int main_symbol();void* x;asm("\n_main_symbol:");main(){ x = &main_symbol; exit(0); },
-ac_cv_underscore_c_names=yes, ac_cv_underscore_c_names=no, ac_cv_underscore_c_names=cross))
+AC_TRY_LINK([extern int foo_alias();asm("\n_foo_alias:");void foo() {};],
+ [foo_alias();],
+ac_cv_underscore_c_names=yes, ac_cv_underscore_c_names=no))
if test "$ac_cv_underscore_c_names" = "yes"; then
AC_DEFINE(HAVE_UNDERSCORED_C_NAMES)
fi
--Multipart_Sat_Aug_15_22:00:10_1998-1--