[Go to BBS]
All articles in a thread
SubjectIntel MacにおけるSADの現状
Article No99
Date: 2006/04/06(Thu) 00:33:55
ContributorShin-ichi Yoshimoto < >
吉本@自宅です

最近は、MacBook ProおよびIntel Mac miniでSADを動かそうと色々と試しているんですが、
一応現状報告をしますと、

1)GCC 3系列は全滅でg77を作るのはかなり難しいので、他力本願モードになっています。
2)GCC 4.1.0がリリースされましたが、これもmakeできないのでSADどころかgfortranもできない。
3)GCC 4.2.0では一応gfrotranをmakeすることができ、SADのコンパイルも通ります。ただし、
examplesを走らせると、こけます。
4)既に森田さんから報告がありましたが、Intelコンパイラだと問題なく動く

といった感じです。といことで、Intelコンパイラを除くと、今一番可能性のあるのはGCC 4.2.0
なんですが、もう、絶えずいじられているので、なかなか見極めるのが大変ですが、もし、Intel Mac
でSADを試してみたい方は、GCC 4.2.0で粘ってみるのが今一番可能性があるように思います。なお、
GCC 4.2.0でgfortranを作るときのポイントをかいつまんで説明すると、

a) gmp-4.2をmakeする際には--host=non-apple-darwinをつける。こうすれば
make checkまでは通ります。
b) mpfr-2.2.0をmakeする際には、webページにある最新のパッチを当てた方がよい

あとはひたすらsvn update && ./configure && make bootstrapしてgfortranがmakeできることを
祈りつつ待つだけです。

SubjectRe: Intel MacにおけるSADの現状
Article No100
Date: 2006/04/08(Sat) 03:23:07
ContributorShin-ichi Yoshimoto < >
吉本@羽田エクセルホテル東急です。

すこし進展がありました。昨夜gmp関係のメーリングリストでパッチが投げられ、

> a) gmp-4.2をmakeする際には--host=non-apple-darwinをつける。こうすれば
> make checkまでは通ります。

ですが、--host=non-apple-darwinをつけなくても良いようになりました。パッチは以下の通り。

--- gmp-4.2.orig/tests/x86call.asm 2006-03-14 16:57:54.000000000 +0100
+++ gmp-4.2/tests/x86call.asm 2006-04-07 09:58:50.000000000 +0200
@@ -115,3 +115,14 @@

EPILOGUE()

+C void gmp_x86check_workaround_apple_ld_bug()
+C
+C Apple ld has an annoying bug that causes it to only load members from
+C static archives that satisfy text symbol dependencies. This procedure
+C creates a bogus dependency on a text symbol in x86check.o (in libtests.a)
+C to ensure that ld loads it, also making all of the needed non-text
+C symbols available.
+
+PROLOGUE(gmp_x86check_workaround_apple_ld_bug)
+ jmp *G(calling_conventions_check)
+EPILOGUE()

これを当てれば、./configure && make && make check が問題なく通るようになりました。
これから、このgmpを使ってgfortranを作って、SADの方を試してみます。

SubjectRe: Intel MacにおけるSADの現状
Article No101
Date: 2006/04/08(Sat) 06:06:56
ContributorShin-ichi Yoshimoto < >
> これから、このgmpを使ってgfortranを作って、SADの方を試してみます。

最後の名前解決こけてしまいます。
原因は時間が出来たら調べてみますが、これまで出なかったパターンです。

/usr/pkg/libexec/gcc/i386-apple-darwin8.6.1/4.2.0/collect2 -dynamic -arch i386 -macosx_version_min 10.3 -multiply_defined suppress -weak_reference_mismatches non-weak -o sad1.exe -lcrt1.o /usr/pkg/lib/gcc/i386-apple-darwin8.6.1/4.2.0/crt3.o -L/Users/yosimoto/SAD/arch/i386-Darwin8/lib -L/usr/X11R6/lib -L/usr/pkg/lib/gcc/i386-apple-darwin8.6.1/4.2.0 -L/usr/pkg/lib/gcc/i386-apple-darwin8.6.1/4.2.0/../../.. MAIN.o tfXlib_.o tfTkInter_.o tfTclArg.o tfcanvasclip.o tfPyInter_dummy.o dummyroutCA.o dummyrout.o libsad.a -ltk8.4 -ltcl8.4 -lX11 -lm -lgfortranbegin -lgfortran -lgcc_s.10.4 -lgcc -lSystem
/usr/bin/ld: Undefined symbols:
___dso_handle
collect2: ld returned 1 exit status
make[2]: *** [sad1.exe] Error 1
make[1]: *** [all] Error 2
make: *** [all] Error 2

SubjectRe: Intel MacにおけるSADの現状
Article No111
Date: 2006/04/20(Thu) 14:46:54
ContributorShin-ichi Yoshimoto < >
> 最後の名前解決こけてしまいます。
> 原因は時間が出来たら調べてみますが、これまで出なかったパターンです。

これは以下のパッチで解決します。

--- gcc/config/darwin-crt3.c.orig 2006-04-05 16:22:09.000000000 +0900
+++ gcc/config/darwin-crt3.c 2006-04-10 18:37:32.000000000 +0900
@@ -518,15 +518,11 @@

int atexit (atexit_callback func) __attribute__((visibility("hidden")));

-/* Use __dso_handle to allow even bundles that call atexit() to be unloaded
- on 10.4. */
-extern void __dso_handle;
-
int
atexit (atexit_callback func)
{
struct one_atexit_routine r;
r.callback.ac = func;
r.has_arg = 0;
- return atexit_common (&r, &__dso_handle);
+ return atexit_common (&r, NULL);
}

そして、SADのmakeにも成功しますが、

mkdir -p /Users/yosimoto/SAD/src/oldsad-amorita-snapshot-563/Documents/example
/Users/yosimoto/SAD/src/oldsad-amorita-snapshot-563/bin/gs /Users/yosimoto/SAD/src/oldsad-amorita-snapshot-563/script/help2HTML.sad
make[2]: *** [/Users/yosimoto/SAD/src/oldsad-amorita-snapshot-563/Documents/SADHelp.html] Illegal instruction (core dumped)
make[1]: *** [all] Error 2
make: *** [all] Error 2

といったように、何かスクリプトを動かすとcore dumpします。試しに、全く何も書いていないスクリプトをgdb上で走らせてみると

% cat test.sad
%
% ./gs
GNU gdb 6.3.50-20050815 (Apple version gdb-467) (Wed Mar 22 19:04:00 GMT 2006)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin"...Reading symbols for shared libraries .... done

(gdb) run -c test.sad
Starting program: /Users/yosimoto/SAD/src/oldsad-amorita-snapshot-557/obj/i386-Darwin8/sad1.exe -c test.sad
Reading symbols for shared libraries .++ done

Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/operand.
0x8fe136e4 in __dyld_stub_binding_helper_interface ()
(gdb) bt
#0 0x8fe136e4 in __dyld_stub_binding_helper_interface ()
#1 0x00001000 in ?? ()
#2 0x001ac9d2 in main (argc=3, argv=0xbffff624) at ../../../gcc/libgfortran/fmain.c:18
(gdb) up
#1 0x00001000 in ?? ()
(gdb) up
#2 0x001ac9d2 in main (argc=3, argv=0xbffff624) at ../../../gcc/libgfortran/fmain.c:18
18 MAIN__ ();
(gdb) l
13 /* Set up the runtime environment. */
14 set_args (argc, argv);
15
16 /* Call the Fortran main program. Internally this is a function
17 called MAIN__ */
18 MAIN__ ();
19
20 /* Bye-bye! */
21 return 0;
22 }
(gdb) quit
The program is running. Exit anyway? (y or n) y

というように、mainを呼ぶ所で死んでいます。ということで、SADが悪いのかgfortranが悪いのかを切り
分けるため、gfortranをtestsuiteにかけてみました。

% make check-f95
Making a new config file...
echo "set tmpdir /Users/yosimoto/src/obj/gcc/testsuite" >> ./tmp0
test -d testsuite || mkdir testsuite
test -d testsuite/gfortran || mkdir testsuite/gfortran
(rootme=`${PWDCMD-pwd}`; export rootme; \
srcdir=`cd ../../gcc/gcc; ${PWDCMD-pwd}` ; export srcdir ; \
cd testsuite/gfortran; \
rm -f tmp-site.exp; \
sed '/set tmpdir/ s|testsuite|testsuite/gfortran|' \
< ../../site.exp > tmp-site.exp; \
/bin/sh ${srcdir}/../move-if-change tmp-site.exp site.exp; \
EXPECT=`if [ -f ${rootme}/../expect/expect ] ; then echo ${rootme}/../expect/expect ; else echo expect ; fi` ; export EXPECT ; \
if [ -f ${rootme}/../expect/expect ] ; then \
TCL_LIBRARY=`cd .. ; cd ${srcdir}/../tcl/library ; ${PWDCMD-pwd}` ; \
export TCL_LIBRARY ; fi ; \
`if [ -f ${srcdir}/../dejagnu/runtest ] ; then echo ${srcdir}/../dejagnu/runtest ; else echo runtest; fi` --tool gfortran )
WARNING: Couldn't find the global config file.
Test Run By yosimoto on Thu Apr 20 14:07:42 2006
Native configuration is i386-apple-darwin8.6.1

=== gfortran tests ===

Schedule of variations:
unix

Running target unix
Using /usr/pkg/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /usr/pkg/share/dejagnu/config/unix.exp as generic interface file for target.
Using /Users/yosimoto/src/gcc/gcc/testsuite/config/default.exp as tool-and-target-specific interface file.
Running /Users/yosimoto/src/gcc/gcc/testsuite/gfortran.dg/dg.exp ...
FAIL: gfortran.dg/assign_2.f90 -O0 (test for excess errors)
Running /Users/yosimoto/src/gcc/gcc/testsuite/gfortran.dg/gomp/gomp.exp ...
Running /Users/yosimoto/src/gcc/gcc/testsuite/gfortran.dg/vect/vect.exp ...
Running /Users/yosimoto/src/gcc/gcc/testsuite/gfortran.fortran-torture/compile/compile.exp ...
Running /Users/yosimoto/src/gcc/gcc/testsuite/gfortran.fortran-torture/execute/execute.exp ...

=== gfortran Summary ===

# of expected passes 12821
# of unexpected failures 1
# of expected failures 7
# of unresolved testcases 1
# of unsupported tests 46
/Users/yosimoto/src/obj/gcc/testsuite/gfortran/../../gfortran version 4.2.0 20060420 (experimental)

make: [check-gfortran] Error 1 (ignored)

となるので、まあ、gfortranは比較的まともそうには見えるんですがCC自体が駄目かもしれないので
引き続き調査続行、と行った感じです。