summaryrefslogtreecommitdiff
path: root/tools/gccld/gccld.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-06-02 00:10:19 +0000
committerChris Lattner <sabre@nondot.org>2004-06-02 00:10:19 +0000
commit7e88d418bbfbaa1d8cae45354ab576f337f8ab58 (patch)
treed997560eb659ac5074e5ca11ed222d1ff0a0ac42 /tools/gccld/gccld.cpp
parentd6af686d288ed0ca539c40e1f121691ab2d5ec1c (diff)
downloadllvm-7e88d418bbfbaa1d8cae45354ab576f337f8ab58.tar.gz
llvm-7e88d418bbfbaa1d8cae45354ab576f337f8ab58.tar.bz2
llvm-7e88d418bbfbaa1d8cae45354ab576f337f8ab58.tar.xz
Refactor a bit of code into a function, no functionality changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13941 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/gccld/gccld.cpp')
-rw-r--r--tools/gccld/gccld.cpp65
1 files changed, 36 insertions, 29 deletions
diff --git a/tools/gccld/gccld.cpp b/tools/gccld/gccld.cpp
index dcdda4f2f9..e4614dc03e 100644
--- a/tools/gccld/gccld.cpp
+++ b/tools/gccld/gccld.cpp
@@ -194,7 +194,41 @@ void RemoveEnv(const char * name, char ** const envp) {
return;
}
-} // End llvm namespace
+} // end LLVM namespace
+
+/// EmitShellScript - Output the wrapper file that invokes the JIT on the LLVM
+/// bytecode file for the program.
+static void EmitShellScript(char **argv) {
+ // Output the script to start the program...
+ std::ofstream Out2(OutputFilename.c_str());
+ if (!Out2.good())
+ exit(PrintAndReturn(argv[0], "error opening '" + OutputFilename +
+ "' for writing!"));
+
+ Out2 << "#!/bin/sh\n";
+ // Allow user to setenv LLVMINTERP if lli is not in their PATH.
+ Out2 << "lli=${LLVMINTERP-lli}\n";
+ Out2 << "exec $lli \\\n";
+ // gcc accepts -l<lib> and implicitly searches /lib and /usr/lib.
+ LibPaths.push_back("/lib");
+ LibPaths.push_back("/usr/lib");
+ LibPaths.push_back("/usr/X11R6/lib");
+ // We don't need to link in libc! In fact, /usr/lib/libc.so may not be a
+ // shared object at all! See RH 8: plain text.
+ std::vector<std::string>::iterator libc =
+ std::find(Libraries.begin(), Libraries.end(), "c");
+ if (libc != Libraries.end()) Libraries.erase(libc);
+ // List all the shared object (native) libraries this executable will need
+ // on the command line, so that we don't have to do this manually!
+ for (std::vector<std::string>::iterator i = Libraries.begin(),
+ e = Libraries.end(); i != e; ++i) {
+ std::string FullLibraryPath = FindLib(*i, LibPaths, true);
+ if (!FullLibraryPath.empty() && IsSharedObject(FullLibraryPath))
+ Out2 << " -load=" << FullLibraryPath << " \\\n";
+ }
+ Out2 << " $0.bc ${1+\"$@\"}\n";
+ Out2.close();
+}
int main(int argc, char **argv, char **envp) {
cl::ParseCommandLineOptions(argc, argv, " llvm linker for GCC\n");
@@ -304,34 +338,7 @@ int main(int argc, char **argv, char **envp) {
removeFile(CFile);
} else {
- // Output the script to start the program...
- std::ofstream Out2(OutputFilename.c_str());
- if (!Out2.good())
- return PrintAndReturn(argv[0], "error opening '" + OutputFilename +
- "' for writing!");
- Out2 << "#!/bin/sh\n";
- // Allow user to setenv LLVMINTERP if lli is not in their PATH.
- Out2 << "lli=${LLVMINTERP-lli}\n";
- Out2 << "exec $lli \\\n";
- // gcc accepts -l<lib> and implicitly searches /lib and /usr/lib.
- LibPaths.push_back("/lib");
- LibPaths.push_back("/usr/lib");
- LibPaths.push_back("/usr/X11R6/lib");
- // We don't need to link in libc! In fact, /usr/lib/libc.so may not be a
- // shared object at all! See RH 8: plain text.
- std::vector<std::string>::iterator libc =
- std::find(Libraries.begin(), Libraries.end(), "c");
- if (libc != Libraries.end()) Libraries.erase(libc);
- // List all the shared object (native) libraries this executable will need
- // on the command line, so that we don't have to do this manually!
- for (std::vector<std::string>::iterator i = Libraries.begin(),
- e = Libraries.end(); i != e; ++i) {
- std::string FullLibraryPath = FindLib(*i, LibPaths, true);
- if (!FullLibraryPath.empty() && IsSharedObject(FullLibraryPath))
- Out2 << " -load=" << FullLibraryPath << " \\\n";
- }
- Out2 << " $0.bc ${1+\"$@\"}\n";
- Out2.close();
+ EmitShellScript(argv);
}
// Make the script executable...