[gold] Consolidate the gold plugin options and actually search for
authorChandler Carruth <chandlerc@gmail.com>
Sat, 14 Feb 2015 09:43:57 +0000 (09:43 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 14 Feb 2015 09:43:57 +0000 (09:43 +0000)
a gold binary explicitly. Substitute this binary into the tests rather
than just directly executing the 'ld' binary.

This should allow folks to inject a cross compiling gold binary, or in
my case to use a gold binary built and installed somewhere other than
/usr/bin/ld. It should also allow the tests to find 'ld.gold' so that
things work even if gold isn't the default on the system.

I've only stubbed out support in the makefile to preserve the existing
behavior with none of the fancy logic. If someone else wants to add
logic here, they're welcome to do so.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229251 91177308-0d34-0410-b5e6-96231b3b80d8

23 files changed:
cmake/config-ix.cmake
test/Makefile
test/lit.cfg
test/lit.site.cfg.in
test/tools/gold/alias.ll
test/tools/gold/bad-alias.ll
test/tools/gold/bcsection.ll
test/tools/gold/coff.ll
test/tools/gold/comdat.ll
test/tools/gold/common.ll
test/tools/gold/emit-llvm.ll
test/tools/gold/invalid.ll
test/tools/gold/linker-script.ll
test/tools/gold/linkonce-weak.ll
test/tools/gold/mtriple.ll
test/tools/gold/no-map-whole-file.ll
test/tools/gold/option.ll
test/tools/gold/pr19901.ll
test/tools/gold/slp-vectorize.ll
test/tools/gold/stats.ll
test/tools/gold/vectorize.ll
test/tools/gold/weak.ll
tools/gold/CMakeLists.txt

index 55727a85f37d60c4a5cbbd17941ab0f53c8b2d4f..50f5859b34d85dd1cf3289cfbb83df84e3d1af65 100755 (executable)
@@ -538,6 +538,12 @@ else()
   endif()
 endif()
 
+find_program(GOLD_EXECUTABLE NAMES ld.gold ld DOC "The gold linker")
+if(GOLD_EXECUTABLE)
+       set(LLVM_BINUTILS_INCDIR "" CACHE PATH
+               "PATH to binutils/include containing plugin-api.h for gold plugin.")
+endif()
+
 include(FindOCaml)
 include(AddOCaml)
 if(WIN32)
index d9e90a3c8c3fa03840fd871129d18c1ffba9dfac..9da22b20417e33eed2379dde0105d5e5afce95e4 100644 (file)
@@ -128,6 +128,7 @@ lit.site.cfg: FORCE
        @$(ECHOPATH) s=@SHLIBEXT@=$(SHLIBEXT)=g >> lit.tmp
        @$(ECHOPATH) s=@EXEEXT@=$(EXEEXT)=g >> lit.tmp
        @$(ECHOPATH) s=@PYTHON_EXECUTABLE@=$(PYTHON)=g >> lit.tmp
+       @$(ECHOPATH) s=@GOLD_EXECUTABLE@=ld=g >> lit.tmp
        @$(ECHOPATH) s=@OCAMLFIND@=$(OCAMLFIND)=g >> lit.tmp
        @$(ECHOPATH) s!@OCAMLFLAGS@!$(addprefix -cclib ,$(LDFLAGS))!g >> lit.tmp
        @$(ECHOPATH) s=@HAVE_OCAMLOPT@=$(HAVE_OCAMLOPT)=g >> lit.tmp
index 59d6aa29909d737b00aa925ce5d13e09b61c4f6b..7b7a269b94b0d0490a5e52fd90ec2b8f1b698aa5 100644 (file)
@@ -187,6 +187,7 @@ if re.search(r'win32', config.target_triple):
 config.substitutions.append( ('%llc_dwarf', llc_dwarf) )
 
 # Add site-specific substitutions.
+config.substitutions.append( ('%gold', config.gold_executable) )
 config.substitutions.append( ('%go', config.go_executable) )
 config.substitutions.append( ('%llvmshlibdir', config.llvm_shlib_dir) )
 config.substitutions.append( ('%shlibext', config.llvm_shlib_ext) )
@@ -333,7 +334,7 @@ def have_ld_plugin_support():
     if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')):
         return False
 
-    ld_cmd = subprocess.Popen(['ld', '--help'], stdout = subprocess.PIPE)
+    ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE)
     ld_out = ld_cmd.stdout.read().decode()
     ld_cmd.wait()
 
@@ -352,7 +353,7 @@ def have_ld_plugin_support():
     if 'elf32ppc' not in emulations or 'elf_x86_64' not in emulations:
         return False
 
-    ld_version = subprocess.Popen(['ld', '--version'], stdout = subprocess.PIPE)
+    ld_version = subprocess.Popen([config.gold_executable, '--version'], stdout = subprocess.PIPE)
     if not 'GNU gold' in ld_version.stdout.read().decode():
         return False
     ld_version.wait()
index 64ad0c3984208001df130e38c67ea1bf72c979e2..9336c76369a7bb48f8279d71f9664838213b86fc 100644 (file)
@@ -13,6 +13,7 @@ config.llvm_shlib_ext = "@SHLIBEXT@"
 config.llvm_exe_ext = "@EXEEXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
+config.gold_executable = "@GOLD_EXECUTABLE@"
 config.ocamlfind_executable = "@OCAMLFIND@"
 config.have_ocamlopt = "@HAVE_OCAMLOPT@"
 config.have_ocaml_ounit = "@HAVE_OCAML_OUNIT@"
index dbf3af57a7b4c299ee94d27b02d85a976cd63f7e..b4edb05a4e460f546186dca42b436b479c1df8e5 100644 (file)
@@ -1,6 +1,6 @@
 ; RUN: llvm-as %s -o %t.o
 ; RUN: llvm-as %p/Inputs/alias-1.ll -o %t2.o
-; RUN: ld -shared -o %t3.o -plugin %llvmshlibdir/LLVMgold.so %t2.o %t.o \
+; RUN: %gold -shared -o %t3.o -plugin %llvmshlibdir/LLVMgold.so %t2.o %t.o \
 ; RUN:  -plugin-opt=emit-llvm
 ; RUN: llvm-dis < %t3.o -o - | FileCheck %s
 
index e0fc788a6123272e921630113abb601ee59f6428..a98bf710b454ca819d36f323928907d3d04389b3 100644 (file)
@@ -1,6 +1,6 @@
 ; RUN: llvm-as %s -o %t.o
 
-; RUN: not ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: not %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:    --plugin-opt=emit-llvm \
 ; RUN:    -shared %t.o -o %t2.o 2>&1 | FileCheck %s
 
index 8565d9ddc4c1798ce7d9c2c8e36ce7bda49283b7..37d2994cc780b5e49351d11bb80b42143681fc63 100644 (file)
@@ -2,7 +2,7 @@
 
 ; RUN: llvm-mc -I=%T -filetype=obj -o %T/bcsection.bco %p/Inputs/bcsection.s
 ; RUN: llvm-nm -no-llvm-bc %T/bcsection.bco | count 0
-; RUN: ld -r -o %T/bcsection.o -plugin %llvmshlibdir/LLVMgold.so %T/bcsection.bco
+; RUN: %gold -r -o %T/bcsection.o -plugin %llvmshlibdir/LLVMgold.so %T/bcsection.bco
 ; RUN: llvm-nm -no-llvm-bc %T/bcsection.o | FileCheck %s
 
 ; CHECK: main
index b66f028a14d86466a8f0586b79253e9c7f1139da..5d8a1c9da5fca79403479c18518670adf6d3aeb1 100644 (file)
@@ -1,5 +1,5 @@
 ; RUN: llvm-as %s -o %t.o
-; RUN: ld      -plugin %llvmshlibdir/LLVMgold.so -plugin-opt=emit-llvm \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so -plugin-opt=emit-llvm \
 ; RUN:    -shared %t.o -o %t2.o
 ; RUN: llvm-dis %t2.o -o - | FileCheck %s
 
index 2edd7822c91a07733364090306a470b64808931d..370bf5641f31b80f0d37a5d5fc89cb9ca93212dd 100644 (file)
@@ -1,6 +1,6 @@
 ; RUN: llvm-as %s -o %t.o
 ; RUN: llvm-as %p/Inputs/comdat.ll -o %t2.o
-; RUN: ld -shared -o %t3.o -plugin %llvmshlibdir/LLVMgold.so %t.o %t2.o \
+; RUN: %gold -shared -o %t3.o -plugin %llvmshlibdir/LLVMgold.so %t.o %t2.o \
 ; RUN:  -plugin-opt=emit-llvm
 ; RUN: llvm-dis %t3.o -o - | FileCheck %s
 
index f3092310a1da7a26d5d95770cd34566be9f2d952..ef18e683104530387fe6a96a18e65cee6e900a11 100644 (file)
@@ -1,7 +1,7 @@
 ; RUN: llvm-as %s -o %t1.o
 ; RUN: llvm-as %p/Inputs/common.ll -o %t2.o
 
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:    --plugin-opt=emit-llvm \
 ; RUN:    -shared %t1.o %t2.o -o %t3.o
 ; RUN: llvm-dis %t3.o -o - | FileCheck %s
@@ -11,7 +11,7 @@
 ; Shared library case, we merge @a as common and keep it for the symbol table.
 ; CHECK: @a = common global i16 0, align 8
 
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:    --plugin-opt=emit-llvm \
 ; RUN:    %t1.o %t2.o -o %t3.o
 ; RUN: llvm-dis %t3.o -o - | FileCheck --check-prefix=EXEC %s
@@ -20,7 +20,7 @@
 ; EXEC: @a = internal global i16 0, align 8
 
 ; RUN: llc %p/Inputs/common.ll -o %t2.o -filetype=obj
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:    --plugin-opt=emit-llvm \
 ; RUN:    %t1.o %t2.o -o %t3.o
 ; RUN: llvm-dis %t3.o -o - | FileCheck --check-prefix=MIXED %s
index 2c43147a2eabc9c235d802ff7f705ec3b222f807..f851fbfb5e024177b1663e4a700e04e60d77bd62 100644 (file)
@@ -1,20 +1,20 @@
 ; RUN: llvm-as %s -o %t.o
 
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:    --plugin-opt=emit-llvm \
 ; RUN:    --plugin-opt=generate-api-file \
 ; RUN:    -shared %t.o -o %t2.o
 ; RUN: llvm-dis %t2.o -o - | FileCheck %s
 ; RUN: FileCheck --check-prefix=API %s < %T/../apifile.txt
 
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:     -m elf_x86_64 --plugin-opt=save-temps \
 ; RUN:    -shared %t.o -o %t3.o
 ; RUN: llvm-dis %t3.o.bc -o - | FileCheck %s
 ; RUN: llvm-dis %t3.o.opt.bc -o - | FileCheck --check-prefix=OPT %s
 
 ; RUN: rm -f %t4.o
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:     -m elf_x86_64 --plugin-opt=disable-output \
 ; RUN:    -shared %t.o -o %t4.o
 ; RUN: not test -a %t4.o
index 8db76446a3d73573857b9b9aba2fa6fdb495a113..858cd47adbed4293dbdbbf7be2df5821d8db55cc 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: not ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: not %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:    %p/Inputs/invalid.bc -o %t2 2>&1 | FileCheck %s
 
 ; test that only one error gets printed
index 35a769453e57980659fbc46cc370910cee8a68e5..7c88b0ffd5fbb82b94b9192db09b7fc0b2e09ff0 100644 (file)
@@ -1,6 +1,6 @@
 ; RUN: llvm-as %s -o %t.o
 
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:    --plugin-opt=emit-llvm \
 ; RUN:    -shared %t.o -o %t2.o \
 ; RUN:    -version-script=%p/Inputs/linker-script.export
index 765275b09d509331cd52725c9ca34ec1dd5e0c40..a0cccea56cfe7b219a4fd5beab1b0f904dcff654 100644 (file)
@@ -1,12 +1,12 @@
 ; RUN: llvm-as %s -o %t.o
 ; RUN: llvm-as %p/Inputs/linkonce-weak.ll -o %t2.o
 
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:    --plugin-opt=emit-llvm \
 ; RUN:    -shared %t.o %t2.o -o %t3.o
 ; RUN: llvm-dis %t3.o -o - | FileCheck %s
 
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:    --plugin-opt=emit-llvm \
 ; RUN:    -shared %t2.o %t.o -o %t3.o
 ; RUN: llvm-dis %t3.o -o - | FileCheck %s
index 6395af6f1ab94b8ced914534fc9a8c85dee6dbb0..94211ed299da7350d16ff9b6147cec704bca89e7 100644 (file)
@@ -1,5 +1,5 @@
 ; RUN: llvm-as %s -o %t.o
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so -m elf32ppc \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so -m elf32ppc \
 ; RUN:    -plugin-opt=mtriple=powerpc-linux-gnu \
 ; RUN:    -plugin-opt=obj-path=%t3.o \
 ; RUN:    -shared %t.o -o %t2
index 21a0c46d28b003d1537cac20fb439c29e9f668f0..4c261d70a2497266da8d02d077b3a1ef21d6eb6d 100644 (file)
@@ -1,5 +1,5 @@
 ; RUN: llvm-as -o %t.bc %s
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so -plugin-opt=emit-llvm \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so -plugin-opt=emit-llvm \
 ; RUN:    --no-map-whole-files -r -o %t2.bc %t.bc
 ; RUN: llvm-dis < %t2.bc -o - | FileCheck %s
 
index 8154e435b4ed0853fec359b7017b7148ab15de22..59e3f1ee4aa36648b111532448869f99dfa7ad59 100644 (file)
@@ -1,5 +1,5 @@
 ; RUN: llvm-as %s -o %t.o
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so -m elf_x86_64 \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so -m elf_x86_64 \
 ; RUN:    --plugin-opt=-jump-table-type=arity \
 ; RUN:    --plugin-opt=-mattr=+aes \
 ; RUN:    --plugin-opt=mcpu=core-avx2 \
index 304246bca47a0858e099a35fcbc005198e7118b1..72c54ab9c96e6349ba5b24e8e237c5e21f5362a5 100644 (file)
@@ -1,6 +1,6 @@
 ; RUN: llc %s -o %t.o -filetype=obj -relocation-model=pic
 ; RUN: llvm-as %p/Inputs/pr19901-1.ll -o %t2.o
-; RUN: ld -shared -o %t.so -plugin %llvmshlibdir/LLVMgold.so %t2.o %t.o
+; RUN: %gold -shared -o %t.so -plugin %llvmshlibdir/LLVMgold.so %t2.o %t.o
 ; RUN: llvm-readobj -t %t.so | FileCheck %s
 
 ; CHECK:       Symbol {
index d378902e32f6a0e9a95a9e1b920fb5f05fc5704c..d39aa768364ce2d41c18a2e5020acec616fd8765 100644 (file)
@@ -1,6 +1,6 @@
 ; RUN: llvm-as %s -o %t.o
 
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:    --plugin-opt=save-temps \
 ; RUN:    -shared %t.o -o %t2.o
 ; RUN: llvm-dis %t2.o.opt.bc -o - | FileCheck %s
index 7c353e6ab2a6bad14bbb919a0a312bdc9ec41903..b3c829798df260053339a0c3d34c06cbb576144f 100644 (file)
@@ -1,7 +1,7 @@
 ; REQUIRES: asserts
 
 ; RUN: llvm-as %s -o %t.o
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so  -shared \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so  -shared \
 ; RUN:    -plugin-opt=-stats %t.o -o %t2 2>&1 | FileCheck %s
 
 ; CHECK: Statistics Collected
index 3d305db1e31bf512c014bf8b6a8604c7294cb78d..c1626d7afcd43d0fca0fb4638d6dc079c980c10d 100644 (file)
@@ -1,6 +1,6 @@
 ; RUN: llvm-as %s -o %t.o
 
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:    --plugin-opt=save-temps \
 ; RUN:    -shared %t.o -o %t2.o
 ; RUN: llvm-dis %t2.o.opt.bc -o - | FileCheck %s
index e05e905cc140fdd67ecb57017f72f0ba784adb8f..6d8d7a871f1b09ee7e27d272f61b4783cad5105b 100644 (file)
@@ -1,7 +1,7 @@
 ; RUN: llvm-as %s -o %t.o
 ; RUN: llvm-as %p/Inputs/weak.ll -o %t2.o
 
-; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
 ; RUN:    --plugin-opt=emit-llvm \
 ; RUN:    -shared %t.o %t2.o -o %t3.o
 ; RUN: llvm-dis %t3.o -o - | FileCheck %s
index a70905c84bf0788879cd853cbfc1af8e038db349..1a6169d65c2ca78a00d6382c1f270bb1a86d41d2 100644 (file)
@@ -1,6 +1,3 @@
-set(LLVM_BINUTILS_INCDIR "" CACHE PATH
-  "PATH to binutils/include containing plugin-api.h for gold plugin.")
-
 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/gold.exports)
 
 if( LLVM_ENABLE_PIC AND LLVM_BINUTILS_INCDIR )