-# Copyright (C) 1992, 1993, 1994, 1996, 1997, 2000 Free Software Foundation, Inc.
+# 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
# it under the terms of the GNU General Public License as published by
# They are also used by the various testsuites to define the environment:
# where to find stdio.h, libc.a, etc.
+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.
#
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 {
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; }
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}"
+ }
}
}
}
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 ".:${objc_libgcc_s_path}"
lappend options "libs=-lobjc"
+
if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
lappend options "libs=${gluefile}"
lappend options "ldflags=$wrap_flags"
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_link_flags "-L[file dirname ${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]
}