From 96052a8d122874401d419f16ef85c43bc453713b Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 3 Jul 2014 19:40:08 +0000 Subject: [PATCH] Add support for inline asm symbols in llvm-ar. This should allow llvm-ar to be used instead of gnu ar + plugin in a LTO build. I will add a release note about it once I finish a LTO bootstrap with it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212287 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Object/X86/archive-ir-asm.ll | 20 ++++++++++++++++++++ tools/llvm-ar/CMakeLists.txt | 1 + tools/llvm-ar/Makefile | 2 +- tools/llvm-ar/llvm-ar.cpp | 5 +++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/Object/X86/archive-ir-asm.ll diff --git a/test/Object/X86/archive-ir-asm.ll b/test/Object/X86/archive-ir-asm.ll new file mode 100644 index 00000000000..31ef6c6ac3d --- /dev/null +++ b/test/Object/X86/archive-ir-asm.ll @@ -0,0 +1,20 @@ +; RUN: llvm-as %s -o=%t1 +; RUN: rm -f %t2 +; RUN: llvm-ar rcs %t2 %t1 +; RUN: llvm-nm -s %t2 | FileCheck %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +module asm ".global global_asm_sym" +module asm "global_asm_sym:" +module asm "local_asm_sym:" +module asm ".long undef_asm_sym" + +; CHECK: Archive map +; CHECK-NEXT: global_asm_sym in archive-ir-asm.ll + +; CHECK: archive-ir-asm.ll +; CHECK-NEXT: T global_asm_sym +; CHECK-NEXT: t local_asm_sym +; CHECK-NEXT: U undef_asm_sym diff --git a/tools/llvm-ar/CMakeLists.txt b/tools/llvm-ar/CMakeLists.txt index 9295efeeee7..0e809a705bb 100644 --- a/tools/llvm-ar/CMakeLists.txt +++ b/tools/llvm-ar/CMakeLists.txt @@ -1,4 +1,5 @@ set(LLVM_LINK_COMPONENTS + ${LLVM_TARGETS_TO_BUILD} Object Support ) diff --git a/tools/llvm-ar/Makefile b/tools/llvm-ar/Makefile index 16a828396cb..e10d6ac6ab6 100644 --- a/tools/llvm-ar/Makefile +++ b/tools/llvm-ar/Makefile @@ -10,7 +10,7 @@ LEVEL := ../.. TOOLNAME := llvm-ar TOOLALIAS = llvm-ranlib -LINK_COMPONENTS := bitreader support object +LINK_COMPONENTS := all-targets bitreader support object # This tool has no plugins, optimize startup time. TOOL_NO_EXPORTS := 1 diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index 60886bb7b11..4bd586be451 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -24,6 +24,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" +#include "llvm/Support/TargetSelect.h" #include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/raw_ostream.h" #include @@ -903,6 +904,10 @@ int main(int argc, char **argv) { " This program archives bitcode files into single libraries\n" ); + llvm::InitializeAllTargetInfos(); + llvm::InitializeAllTargetMCs(); + llvm::InitializeAllAsmParsers(); + StringRef Stem = sys::path::stem(ToolName); if (Stem.find("ar") != StringRef::npos) return ar_main(argv); -- 2.34.1