1 # Copyright (C) 1999, 2001, 2003 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # gcc-patches@gcc.gnu.org
20 # This file defines procs for determining features supported by the target.
22 ###############################
23 # proc check_weak_available { }
24 ###############################
26 # weak symbols are only supported in some configs/object formats
27 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
29 proc check_weak_available { } {
33 # All mips targets should support it
35 if { [ string first "mips" $target_cpu ] >= 0 } {
39 # All solaris2 targets should support it
41 if { [regexp ".*-solaris2.*" $target_triplet] } {
45 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
47 if { [regexp "alpha.*osf.*" $target_triplet] } {
51 # ELF and ECOFF support it. a.out does with gas/gld but may also with
52 # other linkers, so we should try it
54 set objformat [gcc_target_object_format]
65 ###############################
66 # proc check_alias_available { }
67 ###############################
69 # Determine if the target toolchain supports the alias attribute.
71 # Returns 2 if the target supports aliases. Returns 1 if the target
72 # only supports weak aliased. Returns 0 if the target does not
73 # support aliases at all. Returns -1 if support for aliases could not
76 proc check_alias_available { } {
77 global alias_available_saved
79 if [info exists alias_available_saved] {
80 verbose "check_alias_available returning saved $alias_available_saved" 2
82 verbose "check_alias_available compiling testfile" 2
83 set f [open "tmp.c" "w"]
84 # Compile a small test program. The definition of "g" is
85 # necessary to keep the Solaris assembler from complaining
87 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
89 set lines [gcc_target_compile "tmp.c" "tmp.o" object ""]
92 if [string match "" $lines] then {
93 # No error messages, everything is OK.
94 set alias_available_saved 2
96 if [regexp "alias definitions not supported" $lines] {
97 verbose "check_alias_available target does not support aliases" 2
99 set objformat [gcc_target_object_format]
101 if { $objformat == "elf" } {
102 verbose "check_alias_available but target uses ELF format, so it ought to" 2
103 set alias_available_saved -1
105 set alias_available_saved 0
108 if [regexp "only weak aliases are supported" $lines] {
109 verbose "check_alias_available target supports only weak aliases" 2
110 set alias_available_saved 1
112 set alias_available_saved -1
117 verbose "check_alias_available returning $alias_available_saved" 2
120 return $alias_available_saved
123 # Returns true if --gc-sections is supported on the target.
125 proc check_gc_sections_available { } {
126 global gc_sections_available_saved
128 if {![info exists gc_sections_available_saved]} {
129 # Check if the ld used by gcc supports --gc-sections.
130 set gcc_ld [lindex [gcc_target_compile "-print-prog-name=ld" "" "none" ""] 0]
131 set ld_output [remote_exec host "$gcc_ld" "--help"]
132 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
133 set gc_sections_available_saved 1
135 set gc_sections_available_saved 0
138 return $gc_sections_available_saved