diff options
Diffstat (limited to 'source/core/slang-cpp-compiler.cpp')
| -rw-r--r-- | source/core/slang-cpp-compiler.cpp | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/source/core/slang-cpp-compiler.cpp b/source/core/slang-cpp-compiler.cpp index 4bcdd068c..18cb9cdae 100644 --- a/source/core/slang-cpp-compiler.cpp +++ b/source/core/slang-cpp-compiler.cpp @@ -33,7 +33,15 @@ SlangResult GenericCPPCompiler::compile(const CompileOptions& options, ExecuteRe } #endif - return ProcessUtil::execute(cmdLine, outResult); + SlangResult res = ProcessUtil::execute(cmdLine, outResult); + +#if 0 + { + printf("stdout=\"%s\"\nstderr=\"%s\"\nret=%d\n", outResult.standardOutput.getBuffer(), outResult.standardError.getBuffer(), int(outResult.resultCode)); + } +#endif + + return res; } /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CPPCompilerUtil !!!!!!!!!!!!!!!!!!!!!!*/ @@ -153,6 +161,16 @@ SlangResult CPPCompilerUtil::calcGCCFamilyVersion(const String& exeName, CPPComp // Display full path of source files in diagnostics cmdLine.addArg("/FC"); + if (options.flags & CompileOptions::Flag::EnableExceptionHandling) + { + if (options.sourceType == SourceType::CPP) + { + // https://docs.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model?view=vs-2019 + // Assumes c functions cannot throw + cmdLine.addArg("/EHsc"); + } + } + switch (options.optimizationLevel) { case OptimizationLevel::Debug: @@ -277,28 +295,12 @@ SlangResult CPPCompilerUtil::calcGCCFamilyVersion(const String& exeName, CPPComp { case TargetType::SharedLibrary: { + // Shared library + cmdLine.addArg("-shared"); // Position independent cmdLine.addArg("-fPIC"); - String sharedLibraryPath; - - // Work out the shared library name - { - String moduleDir = Path::getParentDirectory(options.modulePath); - String moduleFilename = Path::getFileName(options.modulePath); - - StringBuilder sharedLibraryFilename; - SharedLibrary::appendPlatformFileName(moduleFilename.getUnownedSlice(), sharedLibraryFilename); - - if (moduleDir.getLength() > 0) - { - sharedLibraryPath = Path::combine(moduleDir, sharedLibraryFilename); - } - else - { - sharedLibraryPath = sharedLibraryFilename; - } - } + String sharedLibraryPath = SharedLibrary::calcPlatformPath(options.modulePath.getUnownedSlice()); cmdLine.addArg("-o"); cmdLine.addArg(sharedLibraryPath); @@ -366,6 +368,12 @@ SlangResult CPPCompilerUtil::calcGCCFamilyVersion(const String& exeName, CPPComp cmdLine.addArg("-F"); cmdLine.addArg(libPath); } + + if (options.sourceType == SourceType::CPP) + { + // Make STD libs available + cmdLine.addArg("-lstdc++"); + } } static CPPCompiler::Desc _calcCompiledWithDesc() |
