OSDN Git Service

* gcc.exp (gcc_target_compile): Put braces around
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / objc.exp
index 7bd03ca..5041b70 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001
+# Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2004
 # Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -28,6 +28,7 @@
 load_lib libgloss.exp
 load_lib prune.exp
 load_lib gcc-defs.exp
+load_lib target-libpath.exp
 
 #
 # OBJC_UNDER_TEST is the compiler under test.
@@ -56,7 +57,7 @@ proc default_objc_version { } {
        set tmp [remote_exec host "$compiler -v"]
        set status [lindex $tmp 0];
        set output [lindex $tmp 1];
-       regexp "version.*$" $output version
+       regexp " version \[^\n\r\]*" $output version
        if { $status == 0 && [info exists version] } then {
            clone_output "$compiler_name $version\n"
        } else {
@@ -85,12 +86,18 @@ proc objc_version { } {
 set objc_initialized 0
 
 proc objc_init { args } {
+    global rootme
     global tmpdir
     global libdir
     global gluefile wrap_flags
     global objc_initialized
     global OBJC_UNDER_TEST
     global TOOL_EXECUTABLE
+    global objc_libgcc_s_path
+
+    # We set LC_ALL and LANG to C so that we get the same error messages as expected.
+    setenv LC_ALL C
+    setenv LANG C
 
     if { $objc_initialized == 1 } { return; }
 
@@ -105,14 +112,22 @@ proc objc_init { args } {
     if ![info exists tmpdir] then {
        set tmpdir /tmp
     }
-    if { [target_info needs_status_wrapper]!="" && ![info exists gluefile] } {
-       set gluefile ${tmpdir}/testglue.o;
-       set result [build_wrapper $gluefile];
-       if { $result != "" } {
-           set gluefile [lindex $result 0];
-           set wrap_flags [lindex $result 1];
-       } else {
-           unset gluefile
+
+    objc_maybe_build_wrapper "${tmpdir}/objc-testglue.o"
+
+    set objc_libgcc_s_path "${rootme}"
+    set compiler [lindex $OBJC_UNDER_TEST 0]
+    if { [is_remote host] == 0 && [which $compiler] != 0 } {
+       foreach i "[exec $compiler --print-multi-lib]" {
+           set mldir ""
+           regexp -- "\[a-z0-9=/\.-\]*;" $i mldir
+           set mldir [string trimright $mldir "\;@"]
+           if { "$mldir" == "." } {
+               continue
+           }
+           if { [llength [glob -nocomplain ${rootme}/${mldir}/libgcc_s*.so.*]] >= 1 } {
+               append objc_libgcc_s_path ":${rootme}/${mldir}"
+           }
        }
     }
 }
@@ -121,11 +136,13 @@ proc objc_target_compile { source dest type options } {
     global rootme;
     global tmpdir;
     global gluefile wrap_flags;
+    global srcdir
     global OBJC_UNDER_TEST
     global TOOL_OPTIONS
     global ld_library_path
+    global objc_libgcc_s_path
 
-    set ld_library_path ".:${rootme}"
+    set ld_library_path ".:${objc_libgcc_s_path}"
     lappend options "libs=-lobjc"
 
     if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
@@ -142,21 +159,37 @@ proc objc_target_compile { source dest type options } {
     if [target_info exists objc,no_label_values] {
        lappend options "additional_flags=-DNO_LABEL_VALUES"
     }
+    # TOOL_OPTIONS must come first, so that it doesn't override testcase
+    # specific options.
     if [info exists TOOL_OPTIONS] {
-       lappend options "additional_flags=$TOOL_OPTIONS"
-    }
-    if [target_info exists objc,no_varargs] {
-       lappend options "additional_flags=-DNO_VARARGS"
+       set options [concat "{additional_flags=$TOOL_OPTIONS}" $options];
     }
+
+    # If we have built libobjc along with the compiler (which usually
+    # _is not_ the case on Mac OS X systems), point the test harness
+    # at it (and associated headers).
+
     set objcpath "[get_multilibs]"
+
     set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a]
+    if { $libobjc_dir == ""} {
+      verbose "see if we have -fgnu-runtime in [target_info name]"
+      if [regexp ".*-fgnu-runtime.*" [target_info name]] {
+        set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a]
+      }
+    }
     if { $libobjc_dir != "" } {
+       set objc_include_dir "${srcdir}/../../libobjc"
+       lappend options "additional_flags=-I${objc_include_dir}"
        set libobjc_dir [file dirname ${libobjc_dir}]
        set objc_link_flags "-L${libobjc_dir}"
        lappend options "additional_flags=${objc_link_flags}"
        append ld_library_path ":${libobjc_dir}"
     }
     lappend options "compiler=$OBJC_UNDER_TEST"
+
+    set_ld_library_path_env_vars
+
     return [target_compile $source $dest $type $options]
 }
 
@@ -241,20 +274,6 @@ if { [info procs prune_warnings] == "" } then {
     }
 }
 
-# On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
-# called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
-# (for the 64-bit ABI).  The right way to do this would be to modify
-# unix.exp -- but that's not an option since it's part of DejaGNU
-# proper, so we do it here, by trickery.  We really only need to do 
-# this on IRIX, but it shouldn't hurt to do it anywhere else.
-
-proc ${tool}_set_ld_library_path { name element op } {
-  setenv LD_LIBRARYN32_PATH [getenv LD_LIBRARY_PATH]
-  setenv LD_LIBRARY64_PATH [getenv LD_LIBRARY_PATH]
-}
-
-trace variable env(LD_LIBRARY_PATH) w ${tool}_set_ld_library_path
-
 # Utility used by mike-gcc.exp and c-torture.exp.
 # Check the compiler(/assembler/linker) output for text indicating that
 # the testcase should be marked as "unsupported".