From 1662183a83063313af24708c323817daf4bad195 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Sun, 15 Jun 2008 13:48:12 +0000 Subject: Make sure all produced executable files have "exe" suffix on Windows. With this more general way, -native and -native-cbe options are handled too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52287 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-ld/llvm-ld.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'tools/llvm-ld/llvm-ld.cpp') diff --git a/tools/llvm-ld/llvm-ld.cpp b/tools/llvm-ld/llvm-ld.cpp index f15281dffd..0b8269c7f2 100644 --- a/tools/llvm-ld/llvm-ld.cpp +++ b/tools/llvm-ld/llvm-ld.cpp @@ -403,11 +403,7 @@ static void EmitShellScript(char **argv) { if (llvmstub.isEmpty()) PrintAndExit("Could not find llvm-stub.exe executable!"); - sys::Path OutPath(OutputFilename); - if (OutPath.getSuffix() != "exe") - OutPath.appendSuffix("exe"); - - if (0 != sys::CopyFile(OutPath, llvmstub, &ErrMsg)) + if (0 != sys::CopyFile(sys::Path(OutputFilename), llvmstub, &ErrMsg)) PrintAndExit(ErrMsg); return; @@ -534,14 +530,24 @@ int main(int argc, char **argv, char **envp) { // Optimize the module Optimize(Composite.get()); - // Generate the bitcode for the optimized module. - std::string RealBitcodeOutput = OutputFilename; - #if defined(_WIN32) || defined(__CYGWIN__) - if (!LinkAsLibrary && sys::Path(OutputFilename).getSuffix() != "exe") - RealBitcodeOutput += ".exe"; + if (!LinkAsLibrary) { + // Make sure the output executable has an "exe" suffix. + sys::Path ExeFile( OutputFilename ); + if (ExeFile.getSuffix() != "exe") { + if (OutputFilename == "a.out") { + OutputFilename = "a.exe"; + } else { + ExeFile.appendSuffix("exe"); + OutputFilename = ExeFile.toString(); + } + } + } #endif + // Generate the bitcode for the optimized module. + std::string RealBitcodeOutput = OutputFilename; + if (!LinkAsLibrary) RealBitcodeOutput += ".bc"; GenerateBitcode(Composite.get(), RealBitcodeOutput); -- cgit v1.2.3