From 92c09111f34c464c3dd2b0cfbfa13c3b6c74c3e5 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 9 Jan 2014 09:01:53 -0800 Subject: Add and use check_lto_shared_available 2014-01-09 Vidya Praveen * lib/ld-lib.exp (check_lto_shared_available): New check. * ld-plugin/lto.exp: Use check_lto_shared_available. --- ld/testsuite/lib/ld-lib.exp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'ld/testsuite/lib') diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index c04b56f..54b617f 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -1679,6 +1679,45 @@ proc check_lto_available { } { return $lto_available_saved } +# Returns true if the target compiler supports LTO and -shared +proc check_lto_shared_available { } { + global lto_shared_available_saved + global CC + + set flags "" + + if [board_info [target_info name] exists cflags] { + append flags " [board_info [target_info name] cflags]" + } + + if [board_info [target_info name] exists ldflags] { + append flags " [board_info [target_info name] ldflags]" + } + + if {![info exists lto_shared_available_saved]} { + # Check if gcc supports -flto -fuse-linker-plugin -shared + if { [which $CC] == 0 } { + set lto_shared_available_saved 0 + return 0 + } + set basename "lto_shared" + set src ${basename}[pid].c + set output ${basename}[pid].so + set f [open $src "w"] + puts $f "" + close $f + set status [remote_exec host $CC "$flags -shared -fPIC -B[pwd]/tmpdir/ld/ -flto -fuse-linker-plugin $src -o $output"] + if { [lindex $status 0] == 0 } { + set lto_shared_available_saved 1 + } else { + set lto_shared_available_saved 0 + } + file delete $src + file delete $output + } + return $lto_shared_available_saved +} + # Check if the assembler supports CFI statements. proc check_as_cfi { } { -- cgit v1.1