Nicholas Riley
2005-Aug-01 22:13 UTC
[LLVMdev] [patch] gccld not passing -export-dynamic to gcc for link
gccld passes -shared through if it's generating a shared library, but if you're compiling a program that needs to have its symbols externally accessible, it doesn't pass -export-dynamic through to gcc for the final link. The attached patch fixes this. I've tested with a small test case I sent Chris, and with Python; both seem to work. I also fixed some inaccurate comments in GenerateCode.cpp. -- Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley> -------------- next part -------------- Index: tools/gccld/GenerateCode.cpp ==================================================================RCS file: /var/cvs/llvm/llvm/tools/gccld/GenerateCode.cpp,v retrieving revision 1.50 diff -u -r1.50 GenerateCode.cpp --- tools/gccld/GenerateCode.cpp 8 Jul 2005 16:48:52 -0000 1.50 +++ tools/gccld/GenerateCode.cpp 1 Aug 2005 22:06:26 -0000 @@ -325,8 +325,7 @@ return sys::Program::ExecuteAndWait(llc, &args[0]); } -/// GenerateAssembly - generates a native assembly language source file from the -/// specified bytecode file. +/// GenerateCFile - generates a C source file from the specified bytecode file. int llvm::GenerateCFile(const std::string &OutputFile, const std::string &InputFile, const sys::Path &llc, @@ -344,7 +343,7 @@ return sys::Program::ExecuteAndWait(llc, &args[0]); } -/// GenerateNative - generates a native assembly language source file from the +/// GenerateNative - generates a native executable file from the /// specified assembly source file. /// /// Inputs: @@ -365,6 +364,7 @@ const std::vector<std::string> &Libraries, const sys::Path &gcc, char ** const envp, bool Shared, + bool ExportAllAsDynamic, const std::string &RPath, const std::string &SOName, bool Verbose) { @@ -400,6 +400,7 @@ args.push_back(InputFilename.c_str()); if (Shared) args.push_back("-shared"); + if (ExportAllAsDynamic) args.push_back("-export-dynamic"); if (!RPath.empty()) { std::string rp = "-Wl,-rpath," + RPath; args.push_back(rp.c_str()); Index: tools/gccld/gccld.cpp ==================================================================RCS file: /var/cvs/llvm/llvm/tools/gccld/gccld.cpp,v retrieving revision 1.102 diff -u -r1.102 gccld.cpp --- tools/gccld/gccld.cpp 8 Jul 2005 03:08:58 -0000 1.102 +++ tools/gccld/gccld.cpp 1 Aug 2005 22:06:26 -0000 @@ -308,8 +308,8 @@ Verbose); if (Verbose) std::cout << "Generating Native Code\n"; GenerateNative(OutputFilename, AssemblyFile.toString(), - LibPaths, Libraries, gcc, envp, LinkAsLibrary, RPath, - SOName, Verbose); + LibPaths, Libraries, gcc, envp, LinkAsLibrary, + NoInternalize, RPath, SOName, Verbose); if (!SaveTemps) { // Remove the assembly language file. @@ -340,8 +340,8 @@ GenerateCFile(CFile.toString(), RealBytecodeOutput, llc, Verbose); if (Verbose) std::cout << "Generating Native Code\n"; GenerateNative(OutputFilename, CFile.toString(), - LibPaths, Libraries, gcc, envp, LinkAsLibrary, RPath, - SOName, Verbose); + LibPaths, Libraries, gcc, envp, LinkAsLibrary, + NoInternalize, RPath, SOName, Verbose); if (!SaveTemps) { // Remove the assembly language file. Index: tools/gccld/gccld.h ==================================================================RCS file: /var/cvs/llvm/llvm/tools/gccld/gccld.h,v retrieving revision 1.16 diff -u -r1.16 gccld.h --- tools/gccld/gccld.h 21 Apr 2005 23:59:28 -0000 1.16 +++ tools/gccld/gccld.h 1 Aug 2005 22:06:26 -0000 @@ -45,6 +45,7 @@ const sys::Path &gcc, char ** const envp, bool Shared, + bool ExportAllAsDynamic, const std::string &RPath, const std::string &SOName, bool Verbose=false);
Nicholas Riley
2005-Aug-02 04:15 UTC
[LLVMdev] [patch] gccld not passing -export-dynamic to gcc for link
On Mon, Aug 01, 2005 at 05:13:15PM -0500, Nicholas Riley wrote:> The attached patch fixes this....but had tabs in it. Misha kindly reminded me off-list that this was bad. Try this one instead. -- Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley> -------------- next part -------------- Index: tools/gccld/GenerateCode.cpp ==================================================================RCS file: /var/cvs/llvm/llvm/tools/gccld/GenerateCode.cpp,v retrieving revision 1.50 diff -u -r1.50 GenerateCode.cpp --- tools/gccld/GenerateCode.cpp 8 Jul 2005 16:48:52 -0000 1.50 +++ tools/gccld/GenerateCode.cpp 2 Aug 2005 04:11:11 -0000 @@ -325,8 +325,7 @@ return sys::Program::ExecuteAndWait(llc, &args[0]); } -/// GenerateAssembly - generates a native assembly language source file from the -/// specified bytecode file. +/// GenerateCFile - generates a C source file from the specified bytecode file. int llvm::GenerateCFile(const std::string &OutputFile, const std::string &InputFile, const sys::Path &llc, @@ -344,8 +343,8 @@ return sys::Program::ExecuteAndWait(llc, &args[0]); } -/// GenerateNative - generates a native assembly language source file from the -/// specified assembly source file. +/// GenerateNative - generates a native executable file from the specified +/// assembly source file. /// /// Inputs: /// InputFilename - The name of the output bytecode file. @@ -365,6 +364,7 @@ const std::vector<std::string> &Libraries, const sys::Path &gcc, char ** const envp, bool Shared, + bool ExportAllAsDynamic, const std::string &RPath, const std::string &SOName, bool Verbose) { @@ -400,6 +400,7 @@ args.push_back(InputFilename.c_str()); if (Shared) args.push_back("-shared"); + if (ExportAllAsDynamic) args.push_back("-export-dynamic"); if (!RPath.empty()) { std::string rp = "-Wl,-rpath," + RPath; args.push_back(rp.c_str()); Index: tools/gccld/gccld.cpp ==================================================================RCS file: /var/cvs/llvm/llvm/tools/gccld/gccld.cpp,v retrieving revision 1.102 diff -u -r1.102 gccld.cpp --- tools/gccld/gccld.cpp 8 Jul 2005 03:08:58 -0000 1.102 +++ tools/gccld/gccld.cpp 2 Aug 2005 04:11:11 -0000 @@ -308,8 +308,8 @@ Verbose); if (Verbose) std::cout << "Generating Native Code\n"; GenerateNative(OutputFilename, AssemblyFile.toString(), - LibPaths, Libraries, gcc, envp, LinkAsLibrary, RPath, - SOName, Verbose); + LibPaths, Libraries, gcc, envp, LinkAsLibrary, + NoInternalize, RPath, SOName, Verbose); if (!SaveTemps) { // Remove the assembly language file. @@ -340,8 +340,8 @@ GenerateCFile(CFile.toString(), RealBytecodeOutput, llc, Verbose); if (Verbose) std::cout << "Generating Native Code\n"; GenerateNative(OutputFilename, CFile.toString(), - LibPaths, Libraries, gcc, envp, LinkAsLibrary, RPath, - SOName, Verbose); + LibPaths, Libraries, gcc, envp, LinkAsLibrary, + NoInternalize, RPath, SOName, Verbose); if (!SaveTemps) { // Remove the assembly language file. Index: tools/gccld/gccld.h ==================================================================RCS file: /var/cvs/llvm/llvm/tools/gccld/gccld.h,v retrieving revision 1.16 diff -u -r1.16 gccld.h --- tools/gccld/gccld.h 21 Apr 2005 23:59:28 -0000 1.16 +++ tools/gccld/gccld.h 2 Aug 2005 04:11:11 -0000 @@ -45,6 +45,7 @@ const sys::Path &gcc, char ** const envp, bool Shared, + bool ExportAllAsDynamic, const std::string &RPath, const std::string &SOName, bool Verbose=false);
Chris Lattner
2005-Aug-02 22:08 UTC
[LLVMdev] [patch] gccld not passing -export-dynamic to gcc for link
On Mon, 1 Aug 2005, Nicholas Riley wrote:> On Mon, Aug 01, 2005 at 05:13:15PM -0500, Nicholas Riley wrote: >> The attached patch fixes this. > > ...but had tabs in it. Misha kindly reminded me off-list that this > was bad. Try this one instead.Patch looks great, applied: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20050801/027367.html Thanks Nicholas! -Chris -- http://nondot.org/sabre/ http://llvm.org/
Apparently Analagous Threads
- [LLVMdev] [patch] gccld not passing -export-dynamic to gcc for link
- [LLVMdev] [patch] gccld not properly constructing paths when checking for bytecode
- [LLVMdev] Re: a linking problem of LLVM
- [LLVMdev] opt, llcc, ll++, -O1, -O2, -O3
- [LLVMdev] question about gccld and external libraries