[ruby-dev:39264] Re: Fwd: [redmine4ruby-lang:253] [Bug #1914] ruby-1.9.1-p243 failed to build from source on aix 5.3 with gcc 4.2.0
From:
Yutaka Kanemoto <kinpoco@...>
Date:
2009-09-08 17:48:23 UTC
List:
ruby-dev #39264
金本と申します。 2009/8/9 Yugui <yugui@yugui.jp>: > Redmine管理用プロジェクトに報告されてしまったので転送します。 AIXでruby 1.9 を使う時の話がいくつかあがっているのですが、 とりあえず最初に見つけたこれに調べたことを報告させていただきます。 rubyのコードの中で、dln.cにAIX固有のコードがあります。 おそらくですが、昔のAIXでdlopenがうまく動かなかったか、なかったときのものと思います。 1.9では#1914,#2063,#2064のようなことがおきる一因になっています。 というところで提案なのですが、このAIX固有のコードではなく、ほかのPlatformのように dlopenを使うように変更するというのはいかがでしょうか?? 最近のAIX(とりあえず5.2と5.3)では添付のパッチでmake testはパスしました。 ほかにも課題はたくさんあるのですが、このパッチで上述の三つの問題は、 とりあえず手元では解決します。 nmでエクスポートする関数を列挙したファイルをつくってリンク時に使用することを止めて、 -bexpallというオプションを代わりに利用したりしてあります。#1914や#2064に対応できます。 ほかのPlatformへの影響はないように気をつけたつもりです。 1.9.1p243とtrunkへのパッチです。 ただ、要するに昔のAIX用のコードがなくなることがどう古いAIXに影響するか わかりません。コードを生かせるようにしようと思ったのですが、 古い情報が手に入らなかったのと、手に入っても試す環境がないので、 あきらめてしまいました。 いかがでしょうか? -- Yutaka KANEMOTO http://d.hatena.ne.jp/kinpoco/
Attachments (2)
r19.diff
(4.92 KB, text/x-diff)
Index: configure.in
===================================================================
--- configure.in (revision 24798)
+++ configure.in (working copy)
@@ -1744,10 +1744,7 @@
: ${LDSHARED='$(CC)'}
fi
LDSHARED="$LDSHARED ${linker_flag}-G"
- DLDFLAGS='-eInit_$(TARGET)'
- XLDFLAGS="${linker_flag}-bE:ruby.imp ${linker_flag}-brtl"
- XLDFLAGS="$XLDFLAGS ${linker_flag}-blibpath:${prefix}/lib:${LIBPATH:-/usr/lib:/lib}"
- : ${ARCHFILE="ruby.imp"}
+ XLDFLAGS="${linker_flag}-bexpall ${linker_flag}-brtl ${linker_flag}-blibpath:${prefix}/lib:${LIBPATH:-/usr/lib:/lib}"
TRY_LINK='$(CC) $(LDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS)'
TRY_LINK="$TRY_LINK"' $(CFLAGS) $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)'
: ${LIBPATHENV=SHLIB_PATH}
@@ -2039,7 +2036,7 @@
LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).sl'
;;
when(aix*)
- LIBRUBY_DLDFLAGS="${linker_flag}-bnoentry $XLDFLAGS"
+ LIBRUBY_DLDFLAGS="${linker_flag}-bnoentry ${linker_flag}-bexpall ${linker_flag}-brtl"
LIBRUBYARG_SHARED='-L${libdir} -l${RUBY_SO_NAME}'
SOLIBS='-lm -lc'
;;
@@ -2196,6 +2193,12 @@
esac
MINIDLNOBJ=dmydln.o
;;
+ when(aix*)
+ if test "$GCC" = yes; then
+ CFLAGS=`echo $CFLAGS | sed -e 's/-g/-gxcoff/'`
+ fi
+ LDFLAGS="$LDFLAGS ${linker_flag}-bmaxdata:0x80000000"
+ ;;
when(*msdosdjgpp*)
FIRSTMAKEFILE=GNUmakefile:djgpp/GNUmakefile.in
;;
Index: dln.c
===================================================================
--- dln.c (revision 24798)
+++ dln.c (working copy)
@@ -79,7 +79,7 @@
#ifndef NO_DLN_LOAD
-#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) && !defined(_AIX) && !defined(MACOSX_DYLD) && !defined(_UNICOSMP)
+#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) && !defined(MACOSX_DYLD) && !defined(_UNICOSMP)
/* dynamic load with dlopen() */
# define USE_DLN_DLOPEN
#endif
@@ -1144,55 +1144,6 @@
#endif
}
-
-#if defined(_AIX) && ! defined(_IA64)
-static void
-aix_loaderror(const char *pathname)
-{
- char *message[8], errbuf[1024];
- int i,j;
-
- struct errtab {
- int errnum;
- char *errstr;
- } load_errtab[] = {
- {L_ERROR_TOOMANY, "too many errors, rest skipped."},
- {L_ERROR_NOLIB, "can't load library:"},
- {L_ERROR_UNDEF, "can't find symbol in library:"},
- {L_ERROR_RLDBAD,
- "RLD index out of range or bad relocation type:"},
- {L_ERROR_FORMAT, "not a valid, executable xcoff file:"},
- {L_ERROR_MEMBER,
- "file not an archive or does not contain requested member:"},
- {L_ERROR_TYPE, "symbol table mismatch:"},
- {L_ERROR_ALIGN, "text alignment in file is wrong."},
- {L_ERROR_SYSTEM, "System error:"},
- {L_ERROR_ERRNO, NULL}
- };
-
-#define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0]))
-#define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1)
-
- snprintf(errbuf, 1024, "load failed - %s ", pathname);
-
- if (!loadquery(1, &message[0], sizeof(message)))
- ERRBUF_APPEND(strerror(errno));
- for(i = 0; message[i] && *message[i]; i++) {
- int nerr = atoi(message[i]);
- for (j=0; j<LOAD_ERRTAB_LEN; j++) {
- if (nerr == load_errtab[i].errnum && load_errtab[i].errstr)
- ERRBUF_APPEND(load_errtab[i].errstr);
- }
- while (isdigit(*message[i])) message[i]++;
- ERRBUF_APPEND(message[i]);
- ERRBUF_APPEND("\n");
- }
- errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */
- rb_loaderror(errbuf);
- return;
-}
-#endif
-
#endif /* NO_DLN_LOAD */
void*
@@ -1202,7 +1153,7 @@
rb_raise(rb_eLoadError, "this executable file can't load extension libraries");
#else
-#if !defined(_AIX) && !defined(NeXT)
+#if !defined(NeXT)
const char *error = 0;
#define DLN_ERROR() (error = dln_strerror(), strcpy(ALLOCA_N(char, strlen(error) + 1), error))
#endif
@@ -1312,23 +1263,6 @@
}
#endif /* hpux */
-#if defined(_AIX) && ! defined(_IA64)
-#define DLN_DEFINED
- {
- void (*init_fct)();
-
- init_fct = (void(*)())load((char*)file, 1, 0);
- if (init_fct == NULL) {
- aix_loaderror(file);
- }
- if (loadbind(0, (void*)dln_load, (void*)init_fct) == -1) {
- aix_loaderror(file);
- }
- (*init_fct)();
- return (void*)init_fct;
- }
-#endif /* _AIX */
-
#if defined(NeXT) || defined(MACOSX_DYLD)
#define DLN_DEFINED
/*----------------------------------------------------
@@ -1460,7 +1394,7 @@
#endif /* USE_DLN_A_OUT */
#endif
-#if !defined(_AIX) && !defined(NeXT)
+#if !defined(NeXT)
failed:
rb_loaderror("%s - %s", error, file);
#endif
Index: ext/socket/sockport.h
===================================================================
--- ext/socket/sockport.h (revision 24798)
+++ ext/socket/sockport.h (working copy)
@@ -15,7 +15,11 @@
#else
# ifdef HAVE_SA_LEN
# define SA_LEN(sa) (sa)->sa_len
-# define SS_LEN(ss) (ss)->ss_len
+# ifdef _AIX
+# define SS_LEN(ss) (ss)->__ss_len
+# else
+# define SS_LEN(ss) (ss)->ss_len
+# endif
# else
# ifdef AF_INET6
# define SA_LEN(sa) \
243.diff
(5.52 KB, text/x-diff)
Only in ruby-1.9.1-p243: autom4te.cache
diff -ur ruby-1.9.1-p243.orig/configure ruby-1.9.1-p243/configure
--- ruby-1.9.1-p243.orig/configure 2009-07-17 23:44:35.000000000 +0900
+++ ruby-1.9.1-p243/configure 2009-09-09 01:14:55.000000000 +0900
@@ -21426,10 +21426,7 @@
: ${LDSHARED='$(CC)'}
fi
LDSHARED="$LDSHARED ${linker_flag}-G"
- DLDFLAGS='-eInit_$(TARGET)'
- XLDFLAGS="${linker_flag}-bE:ruby.imp ${linker_flag}-brtl"
- XLDFLAGS="$XLDFLAGS ${linker_flag}-blibpath:${prefix}/lib:${LIBPATH:-/usr/lib:/lib}"
- : ${ARCHFILE="ruby.imp"}
+ XLDFLAGS="${linker_flag}-bexpall ${linker_flag}-brtl ${linker_flag}-blibpath:${prefix}/lib:${LIBPATH:-/usr/lib:/lib}"
TRY_LINK='$(CC) $(LDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS)'
TRY_LINK="$TRY_LINK"' $(CFLAGS) $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)'
: ${LIBPATHENV=SHLIB_PATH}
@@ -22180,7 +22177,7 @@
LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).sl'
;;
aix*)
- LIBRUBY_DLDFLAGS="${linker_flag}-bnoentry $XLDFLAGS"
+ LIBRUBY_DLDFLAGS="${linker_flag}-bnoentry ${linker_flag}-bexpall ${linker_flag}-brtl"
LIBRUBYARG_SHARED='-L${libdir} -l${RUBY_SO_NAME}'
SOLIBS='-lm -lc'
;;
diff -ur ruby-1.9.1-p243.orig/configure.in ruby-1.9.1-p243/configure.in
--- ruby-1.9.1-p243.orig/configure.in 2009-05-12 00:06:48.000000000 +0900
+++ ruby-1.9.1-p243/configure.in 2009-09-09 01:14:48.000000000 +0900
@@ -1431,10 +1431,7 @@
: ${LDSHARED='$(CC)'}
fi
LDSHARED="$LDSHARED ${linker_flag}-G"
- DLDFLAGS='-eInit_$(TARGET)'
- XLDFLAGS="${linker_flag}-bE:ruby.imp ${linker_flag}-brtl"
- XLDFLAGS="$XLDFLAGS ${linker_flag}-blibpath:${prefix}/lib:${LIBPATH:-/usr/lib:/lib}"
- : ${ARCHFILE="ruby.imp"}
+ XLDFLAGS="${linker_flag}-bexpall ${linker_flag}-brtl ${linker_flag}-blibpath:${prefix}/lib:${LIBPATH:-/usr/lib:/lib}"
TRY_LINK='$(CC) $(LDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS)'
TRY_LINK="$TRY_LINK"' $(CFLAGS) $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)'
: ${LIBPATHENV=SHLIB_PATH}
@@ -1763,7 +1760,7 @@
LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).sl'
;;
aix*)
- LIBRUBY_DLDFLAGS="${linker_flag}-bnoentry $XLDFLAGS"
+ LIBRUBY_DLDFLAGS="${linker_flag}-bnoentry ${linker_flag}-bexpall ${linker_flag}-brtl"
LIBRUBYARG_SHARED='-L${libdir} -l${RUBY_SO_NAME}'
SOLIBS='-lm -lc'
;;
diff -ur ruby-1.9.1-p243.orig/dln.c ruby-1.9.1-p243/dln.c
--- ruby-1.9.1-p243.orig/dln.c 2009-07-12 23:45:12.000000000 +0900
+++ ruby-1.9.1-p243/dln.c 2009-09-09 01:08:24.000000000 +0900
@@ -85,7 +85,7 @@
#ifndef NO_DLN_LOAD
-#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) && !defined(_AIX) && !defined(MACOSX_DYLD) && !defined(_UNICOSMP)
+#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) && !defined(MACOSX_DYLD) && !defined(_UNICOSMP)
/* dynamic load with dlopen() */
# define USE_DLN_DLOPEN
#endif
@@ -1150,55 +1150,6 @@
#endif
}
-
-#if defined(_AIX) && ! defined(_IA64)
-static void
-aix_loaderror(const char *pathname)
-{
- char *message[8], errbuf[1024];
- int i,j;
-
- struct errtab {
- int errnum;
- char *errstr;
- } load_errtab[] = {
- {L_ERROR_TOOMANY, "too many errors, rest skipped."},
- {L_ERROR_NOLIB, "can't load library:"},
- {L_ERROR_UNDEF, "can't find symbol in library:"},
- {L_ERROR_RLDBAD,
- "RLD index out of range or bad relocation type:"},
- {L_ERROR_FORMAT, "not a valid, executable xcoff file:"},
- {L_ERROR_MEMBER,
- "file not an archive or does not contain requested member:"},
- {L_ERROR_TYPE, "symbol table mismatch:"},
- {L_ERROR_ALIGN, "text alignment in file is wrong."},
- {L_ERROR_SYSTEM, "System error:"},
- {L_ERROR_ERRNO, NULL}
- };
-
-#define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0]))
-#define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1)
-
- snprintf(errbuf, 1024, "load failed - %s ", pathname);
-
- if (!loadquery(1, &message[0], sizeof(message)))
- ERRBUF_APPEND(strerror(errno));
- for(i = 0; message[i] && *message[i]; i++) {
- int nerr = atoi(message[i]);
- for (j=0; j<LOAD_ERRTAB_LEN; j++) {
- if (nerr == load_errtab[i].errnum && load_errtab[i].errstr)
- ERRBUF_APPEND(load_errtab[i].errstr);
- }
- while (isdigit(*message[i])) message[i]++;
- ERRBUF_APPEND(message[i]);
- ERRBUF_APPEND("\n");
- }
- errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */
- rb_loaderror(errbuf);
- return;
-}
-#endif
-
#endif /* NO_DLN_LOAD */
void*
@@ -1208,7 +1159,7 @@
rb_raise(rb_eLoadError, "this executable file can't load extension libraries");
#else
-#if !defined(_AIX) && !defined(NeXT)
+#if !defined(NeXT)
const char *error = 0;
#define DLN_ERROR() (error = dln_strerror(), strcpy(ALLOCA_N(char, strlen(error) + 1), error))
#endif
@@ -1313,23 +1264,6 @@
}
#endif /* hpux */
-#if defined(_AIX) && ! defined(_IA64)
-#define DLN_DEFINED
- {
- void (*init_fct)();
-
- init_fct = (void(*)())load((char*)file, 1, 0);
- if (init_fct == NULL) {
- aix_loaderror(file);
- }
- if (loadbind(0, (void*)dln_load, (void*)init_fct) == -1) {
- aix_loaderror(file);
- }
- (*init_fct)();
- return (void*)init_fct;
- }
-#endif /* _AIX */
-
#if defined(NeXT) || defined(MACOSX_DYLD)
#define DLN_DEFINED
/*----------------------------------------------------
@@ -1461,7 +1395,7 @@
#endif /* USE_DLN_A_OUT */
#endif
-#if !defined(_AIX) && !defined(NeXT)
+#if !defined(NeXT)
failed:
rb_loaderror("%s - %s", error, file);
#endif
Only in ruby-1.9.1-p243/ext/win32ole: .document