Append $PLT_CFLAGS to CC for NOCROSSREFS tests
[deliverable/binutils-gdb.git] / ld / testsuite / ld-scripts / sysroot-prefix.exp
CommitLineData
b90efa5b 1# Copyright (C) 2014-2015 Free Software Foundation, Inc.
ef1ab8e2
HPN
2#
3# This file is part of the GNU Binutils.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
18# MA 02110-1301, USA.
19
20# Check that scripts using the "=" sysroot-prefix work, for both
21# toolchains with and without --sysroot support.
22
23# We test this by emitting archives into a subdirectory and expect
24# constructs such as GROUP and AS_NEEDED (the only two constructs
25# actually tested) to find them (or not); both quoted and unquoted
26# paths, with different prefixes on the path and with --sysroot
27# present or not, with different arguments.
28
29# Find out if the linker supports sysroot; if it was configured
3f730821 30# "--with-sysroot X" where X is a non-empty string.
ef1ab8e2 31set with_sysroot [check_sysroot_available]
3f730821
HPN
32verbose -log "Has (non-empty) sysroot support: $with_sysroot; \"$ld_sysroot\""
33
34# We also need to know if the sysroot is "/" (a common use) as some of
35# the tests prepend sysroot to the current directory and on most
36# common systems "//dir/path" is handled as "/dir/path".
37if {$ld_sysroot == "/"} {
38 # Use a modified test-subset for testing.
39 set with_sysroot 3
40}
ef1ab8e2
HPN
41
42# Entries in the array-tables:
3f730821
HPN
43# 0: Testtype; an inclusive bitmask indicating that the test should run on a
44# build configured for: 1: non-sysroot, 2: sysroot != "/", 4: sysroot == "/".
ef1ab8e2
HPN
45# 1: Description, forming part of the dejagnu test-name.
46# 2: Replacement for @p@.
47# 3: Option to pass to linker (usually something with --sysroot).
48# 4: Message substring; a substring to match against the error message
49# if an error is expected, or empty if no error is expected.
50#
51# If the replacement or option contains @cwd@, that'll be replaced by
52# "$base_dir/tmpdir", the full path to the location of the script
53# (with the actual files in the "sysroot" subdirectory). If the
54# description contains @cwd@, that will be replaced by "<CWD>".
55
56set sysroot_prefix_tests {
3f730821
HPN
57 {7 "plain -Lpath" "sysroot/" {} ""}
58 {7 "root-anchored but -Lpath" "/sysroot/" {} "cannot find"}
59 {7 "full-path" "@cwd@/sysroot/" {} ""}
60 {7 "root-anchored =-prefixed -Lpath" "=/sysroot/" {} "cannot find"}
61 {7 "full-path =-prefixed with empty" "=@cwd@/sysroot/" "--sysroot=" ""}
62 {7 "plain =-prefixed with empty" "=sysroot/" "--sysroot=" ""}
63 {6 "root-anchored but script outside sysroot" "/" "--sysroot=@cwd@/sysroot" "cannot find"}
64 {6 "root-anchored and script inside sysroot" "/sysroot/" "--sysroot=@cwd@" ""}
65 {6 "root-anchored =-prefixed script outside" "=/" "--sysroot=@cwd@/sysroot" ""}
66 {6 "root-anchored =-prefixed script inside" "=/sysroot/" "--sysroot=@cwd@" ""}
ef1ab8e2
HPN
67 {2 "plain =-prefixed without but -Lpath" "=sysroot/" {} "cannot find"}
68 {2 "full-path =-prefixed without" "=@cwd@/sysroot/" {} "cannot find"}
69 {1 "plain =-prefixed -Lpath" "=sysroot/" {} ""}
70 {1 "full-path =-prefixed without" "=@cwd@/sysroot/" {} ""}
71}
72
73# May have to provide a target-specific assembler option for some targets.
74set gasopt ""
75
76# Intentionally similar to the ubiquitous glibc libc.so script.
77set template "GROUP ( @q@@p@tmp/ldtest-xyzzy/libx.a@q@ AS_NEEDED ( @q@@p@tmp/ldtest-xyzzy/liby.a@q@ ) )"
78
79# Set up everything from the variables above.
80proc sysroot_prefix_test_setup { } {
81 global as gasopt srcdir subdir ar
82
83 if {![ld_assemble_flags $as $gasopt $srcdir/$subdir/pr14962a.s tmpdir/main.o]} {