diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 55727a85f37..50f5859b34d 100755 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -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) diff --git a/test/Makefile b/test/Makefile index d9e90a3c8c3..9da22b20417 100644 --- a/test/Makefile +++ b/test/Makefile @@ -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 diff --git a/test/lit.cfg b/test/lit.cfg index 59d6aa29909..7b7a269b94b 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -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() diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 64ad0c39842..9336c76369a 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -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@" diff --git a/test/tools/gold/alias.ll b/test/tools/gold/alias.ll index dbf3af57a7b..b4edb05a4e4 100644 --- a/test/tools/gold/alias.ll +++ b/test/tools/gold/alias.ll @@ -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 diff --git a/test/tools/gold/bad-alias.ll b/test/tools/gold/bad-alias.ll index e0fc788a612..a98bf710b45 100644 --- a/test/tools/gold/bad-alias.ll +++ b/test/tools/gold/bad-alias.ll @@ -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 diff --git a/test/tools/gold/bcsection.ll b/test/tools/gold/bcsection.ll index 8565d9ddc4c..37d2994cc78 100644 --- a/test/tools/gold/bcsection.ll +++ b/test/tools/gold/bcsection.ll @@ -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 diff --git a/test/tools/gold/coff.ll b/test/tools/gold/coff.ll index b66f028a14d..5d8a1c9da5f 100644 --- a/test/tools/gold/coff.ll +++ b/test/tools/gold/coff.ll @@ -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 diff --git a/test/tools/gold/comdat.ll b/test/tools/gold/comdat.ll index 2edd7822c91..370bf5641f3 100644 --- a/test/tools/gold/comdat.ll +++ b/test/tools/gold/comdat.ll @@ -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 diff --git a/test/tools/gold/common.ll b/test/tools/gold/common.ll index f3092310a1d..ef18e683104 100644 --- a/test/tools/gold/common.ll +++ b/test/tools/gold/common.ll @@ -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 diff --git a/test/tools/gold/emit-llvm.ll b/test/tools/gold/emit-llvm.ll index 2c43147a2ea..f851fbfb5e0 100644 --- a/test/tools/gold/emit-llvm.ll +++ b/test/tools/gold/emit-llvm.ll @@ -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 diff --git a/test/tools/gold/invalid.ll b/test/tools/gold/invalid.ll index 8db76446a3d..858cd47adbe 100644 --- a/test/tools/gold/invalid.ll +++ b/test/tools/gold/invalid.ll @@ -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 diff --git a/test/tools/gold/linker-script.ll b/test/tools/gold/linker-script.ll index 35a769453e5..7c88b0ffd5f 100644 --- a/test/tools/gold/linker-script.ll +++ b/test/tools/gold/linker-script.ll @@ -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 diff --git a/test/tools/gold/linkonce-weak.ll b/test/tools/gold/linkonce-weak.ll index 765275b09d5..a0cccea56cf 100644 --- a/test/tools/gold/linkonce-weak.ll +++ b/test/tools/gold/linkonce-weak.ll @@ -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 diff --git a/test/tools/gold/mtriple.ll b/test/tools/gold/mtriple.ll index 6395af6f1ab..94211ed299d 100644 --- a/test/tools/gold/mtriple.ll +++ b/test/tools/gold/mtriple.ll @@ -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 diff --git a/test/tools/gold/no-map-whole-file.ll b/test/tools/gold/no-map-whole-file.ll index 21a0c46d28b..4c261d70a24 100644 --- a/test/tools/gold/no-map-whole-file.ll +++ b/test/tools/gold/no-map-whole-file.ll @@ -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 diff --git a/test/tools/gold/option.ll b/test/tools/gold/option.ll index 8154e435b4e..59e3f1ee4aa 100644 --- a/test/tools/gold/option.ll +++ b/test/tools/gold/option.ll @@ -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 \ diff --git a/test/tools/gold/pr19901.ll b/test/tools/gold/pr19901.ll index 304246bca47..72c54ab9c96 100644 --- a/test/tools/gold/pr19901.ll +++ b/test/tools/gold/pr19901.ll @@ -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 { diff --git a/test/tools/gold/slp-vectorize.ll b/test/tools/gold/slp-vectorize.ll index d378902e32f..d39aa768364 100644 --- a/test/tools/gold/slp-vectorize.ll +++ b/test/tools/gold/slp-vectorize.ll @@ -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 diff --git a/test/tools/gold/stats.ll b/test/tools/gold/stats.ll index 7c353e6ab2a..b3c829798df 100644 --- a/test/tools/gold/stats.ll +++ b/test/tools/gold/stats.ll @@ -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 diff --git a/test/tools/gold/vectorize.ll b/test/tools/gold/vectorize.ll index 3d305db1e31..c1626d7afcd 100644 --- a/test/tools/gold/vectorize.ll +++ b/test/tools/gold/vectorize.ll @@ -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 diff --git a/test/tools/gold/weak.ll b/test/tools/gold/weak.ll index e05e905cc14..6d8d7a871f1 100644 --- a/test/tools/gold/weak.ll +++ b/test/tools/gold/weak.ll @@ -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 diff --git a/tools/gold/CMakeLists.txt b/tools/gold/CMakeLists.txt index a70905c84bf..1a6169d65c2 100644 --- a/tools/gold/CMakeLists.txt +++ b/tools/gold/CMakeLists.txt @@ -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 )