diff options
author | Derek Schuff <dschuff@chromium.org> | 2013-10-23 08:35:49 -0700 |
---|---|---|
committer | Derek Schuff <dschuff@chromium.org> | 2013-10-23 08:35:49 -0700 |
commit | 99a581677ff9a785f77e9d9d171b87d61f2da25e (patch) | |
tree | 68028c90a26c775aee1bd2834a4d3ec2953f140e /tools | |
parent | 7287c45c13dc887cebe3db6abfa2f1080186bb97 (diff) |
Remove obsolete bitcode wrapper code
We are using our own bitcode reader now, and no longer need this.
R=jvoung@chromium.org, kschimpf@google.com
BUG=cleanup
Review URL: https://codereview.chromium.org/32943005
Diffstat (limited to 'tools')
-rw-r--r-- | tools/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tools/Makefile | 2 | ||||
-rw-r--r-- | tools/bc-wrap/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tools/bc-wrap/LLVMBuild.txt | 22 | ||||
-rw-r--r-- | tools/bc-wrap/Makefile | 20 | ||||
-rw-r--r-- | tools/bc-wrap/bc_wrap.cpp | 123 |
6 files changed, 1 insertions, 172 deletions
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index e32aef3169..8bc805111e 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -47,7 +47,6 @@ add_subdirectory(pnacl-abicheck) add_subdirectory(pnacl-bcanalyzer) add_subdirectory(pnacl-freeze) add_subdirectory(pnacl-thaw) -add_subdirectory(bc-wrap) add_subdirectory(obj2yaml) add_subdirectory(yaml2obj) diff --git a/tools/Makefile b/tools/Makefile index b94f08f81c..4d42b778be 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -34,7 +34,7 @@ PARALLEL_DIRS := opt llvm-as llvm-dis \ bugpoint llvm-bcanalyzer \ llvm-diff macho-dump llvm-objdump llvm-readobj \ llvm-rtdyld llvm-dwarfdump llvm-cov \ - llvm-size llvm-stress llvm-mcmarkup bc-wrap pso-stub \ + llvm-size llvm-stress llvm-mcmarkup pso-stub \ llvm-symbolizer pnacl-abicheck pnacl-bcanalyzer pnacl-freeze \ pnacl-thaw obj2yaml yaml2obj diff --git a/tools/bc-wrap/CMakeLists.txt b/tools/bc-wrap/CMakeLists.txt deleted file mode 100644 index 7d8ce4fc11..0000000000 --- a/tools/bc-wrap/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set(LLVM_LINK_COMPONENTS wrap support ) - -add_llvm_tool(bc-wrap - bc_wrap.cpp - )
\ No newline at end of file diff --git a/tools/bc-wrap/LLVMBuild.txt b/tools/bc-wrap/LLVMBuild.txt deleted file mode 100644 index a91f77625e..0000000000 --- a/tools/bc-wrap/LLVMBuild.txt +++ /dev/null @@ -1,22 +0,0 @@ -;===- ./tools/bc-wrap/LLVMBuild.txt ----------------------------*- Conf -*--===; -; -; The LLVM Compiler Infrastructure -; -; This file is distributed under the University of Illinois Open Source -; License. See LICENSE.TXT for details. -; -;===------------------------------------------------------------------------===; -; -; This is an LLVMBuild description file for the components in this subdirectory. -; -; For more information on the LLVMBuild system, please see: -; -; http://llvm.org/docs/LLVMBuild.html -; -;===------------------------------------------------------------------------===; - -[component_0] -type = Tool -name = bc-wrap -parent = Tools -required_libraries = Wrap Support diff --git a/tools/bc-wrap/Makefile b/tools/bc-wrap/Makefile deleted file mode 100644 index dccff2ecde..0000000000 --- a/tools/bc-wrap/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -#===- tools/bc-wrap/Makefile -----------------------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## - -LEVEL = ../.. -TOOLNAME = bc-wrap - -# Include this here so we can get the configuration of the targets -# that have been configured for construction. We have to do this -# early so we can set up LINK_COMPONENTS before including Makefile.rules -include $(LEVEL)/Makefile.config - -LINK_COMPONENTS := $(TARGETS_TO_BUILD) Wrap - -include $(LLVM_SRC_ROOT)/Makefile.rules diff --git a/tools/bc-wrap/bc_wrap.cpp b/tools/bc-wrap/bc_wrap.cpp deleted file mode 100644 index 5311f714ee..0000000000 --- a/tools/bc-wrap/bc_wrap.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright 2012 The Native Client Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can - * be found in the LICENSE file. - */ -/* - * Utility to wrap a .bc file, using LLVM standard+ custom headers. - */ - -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/FileSystem.h" -#include "llvm/Wrap/bitcode_wrapperer.h" -#include "llvm/Wrap/file_wrapper_input.h" -#include "llvm/Wrap/file_wrapper_output.h" - -#include <ctype.h> -#include <string.h> - -using namespace llvm; - -static cl::opt<std::string> -InputFilename(cl::Positional, cl::desc("<input file>"), cl::Required); - -static cl::opt<std::string> -OutputFilename("o", cl::desc("<output file>")); - -static cl::opt<bool> UnwrapFlag("u", - cl::desc("unwrap rather than wrap the file"), - cl::init(false)); - -static cl::opt<bool> VerboseFlag("v", - cl::desc("print verbose header information"), - cl::init(false)); - -static cl::opt<bool> DryRunFlag("n", - cl::desc("Dry run (implies -v)"), - cl::init(false)); - -// Accept the hash on the command line to avoid having to include sha1 -// library with the LLVM code -static cl::opt<std::string> BitcodeHash("hash", - cl::desc("Hash of bitcode (ignored if -u is given)")); - -const int kMaxBinaryHashLen = 32; - -// Convert ASCII hex hash to binary hash. return buffer and length. -// The caller must free the returned buffer. -static uint8_t* ParseBitcodeHash(int* len) { - if (BitcodeHash.size() > kMaxBinaryHashLen * 2 || - BitcodeHash.size() % 2) return NULL; - *len = BitcodeHash.size() / 2; - uint8_t* buf = new uint8_t[*len]; - const char* arg = BitcodeHash.data(); - for (size_t i = 0; i < BitcodeHash.size() / 2; i++) { - unsigned int r; // glibc has %hhx but it's nonstandard - if (!isxdigit(*(arg + 2 * i + 1)) || // sscanf ignores trailing junk - !sscanf(arg + 2 * i, "%2x", &r) || - r > std::numeric_limits<uint8_t>::max()) { - delete [] buf; - return NULL; - } - buf[i] = static_cast<uint8_t>(r); - } - return buf; -} - -int main(const int argc, const char* argv[]) { - bool success = true; - cl::ParseCommandLineOptions(argc, argv, "bitcode wrapper/unwrapper\n"); - if (OutputFilename == "") { - // Default to input file = output file. The cl lib doesn't seem to - // directly support initializing one opt from another. - OutputFilename = InputFilename; - } - if (DryRunFlag) VerboseFlag = true; - sys::fs::file_status outfile_status; - std::string outfile_temp; - outfile_temp = std::string(OutputFilename) + ".temp"; - if (UnwrapFlag) { - FileWrapperInput inbc(InputFilename); - FileWrapperOutput outbc(outfile_temp); - BitcodeWrapperer wrapperer(&inbc, &outbc); - if (wrapperer.IsInputBitcodeWrapper()) { - if (VerboseFlag) { - fprintf(stderr, "Headers read from infile:\n"); - wrapperer.PrintWrapperHeader(); - } - if (DryRunFlag) - return 0; - success = wrapperer.GenerateRawBitcodeFile(); - } - } else { - FileWrapperInput inbc(InputFilename); - FileWrapperOutput outbc(outfile_temp); - BitcodeWrapperer wrapperer(&inbc, &outbc); - if (BitcodeHash.size()) { - // SHA-2 hash is 256 bit - int hash_len; - uint8_t* buf = ParseBitcodeHash(&hash_len); - if (!buf) { - fprintf(stderr, "Bitcode hash must be a hex string <= 64 chars.\n"); - exit(1); - } - BCHeaderField hash(BCHeaderField::kBitcodeHash, hash_len, buf); - wrapperer.AddHeaderField(&hash); - } - if (VerboseFlag) { - fprintf(stderr, "Headers generated:\n"); - wrapperer.PrintWrapperHeader(); - } - if (DryRunFlag) - return 0; - success = wrapperer.GenerateWrappedBitcodeFile(); - } - error_code ec; - if ((ec = sys::fs::rename(outfile_temp, OutputFilename))) { - fprintf(stderr, "Could not rename temporary: %s\n", ec.message().c_str()); - success = false; - } - if (success) return 0; - fprintf(stderr, "error: Unable to generate a proper %s bitcode file!\n", - (UnwrapFlag ? "unwrapped" : "wrapped")); - return 1; -} |