From 4e8c2a06948071561fb3619eea7a10470e4646a0 Mon Sep 17 00:00:00 2001 From: Richard Chapman Date: Wed, 31 Jul 2024 14:02:22 +0100 Subject: [PATCH] HPCC-32274 Pass generateClang as a parameter to resource generation Signed-off-by: Richard Chapman --- ecl/eclcc/eclcc.cpp | 2 +- ecl/hqlcpp/hqlcpp.cpp | 8 ++++---- ecl/hqlcpp/hqlcpp.hpp | 2 +- ecl/hqlcpp/hqlcpp.ipp | 3 ++- ecl/hqlcpp/hqlecl.cpp | 17 +++++++++-------- ecl/hqlcpp/hqlecl.hpp | 2 +- ecl/hqlcpp/hqlres.cpp | 11 +++-------- ecl/hqlcpp/hqlres.hpp | 2 +- 8 files changed, 22 insertions(+), 25 deletions(-) diff --git a/ecl/eclcc/eclcc.cpp b/ecl/eclcc/eclcc.cpp index 14e7d101633..792d0aec1af 100644 --- a/ecl/eclcc/eclcc.cpp +++ b/ecl/eclcc/eclcc.cpp @@ -961,7 +961,7 @@ void EclCC::instantECL(EclCompileInstance & instance, IWorkUnit *wu, const char bool optSaveCpp = optPublishCpp || !optCompileBatchOut.isEmpty(); //New scope - testing things are linked correctly { - Owned generator = createDllGenerator(&errorProcessor, processName.str(), NULL, wu, optTargetClusterType, &instance, false, false); + Owned generator = createDllGenerator(&errorProcessor, processName.str(), NULL, wu, optTargetClusterType, &instance, false, false, optTargetCompiler); setWorkunitHash(wu, instance.query); if (!optShared) diff --git a/ecl/hqlcpp/hqlcpp.cpp b/ecl/hqlcpp/hqlcpp.cpp index 5009be858f4..302108fe992 100644 --- a/ecl/hqlcpp/hqlcpp.cpp +++ b/ecl/hqlcpp/hqlcpp.cpp @@ -1143,7 +1143,7 @@ void insertUniqueString(StringAttrArray & array, const char * text) array.append(* new StringAttrItem(text)); } -HqlCppInstance::HqlCppInstance(IWorkUnit *_wu, const char * _wupathname) : resources(*this) +HqlCppInstance::HqlCppInstance(IWorkUnit *_wu, const char * _wupathname, CompilerType _compilerType) : resources(*this), compilerType(_compilerType) { workunit.set(_wu); wupathname.set(_wupathname); @@ -1437,7 +1437,7 @@ void HqlCppInstance::flushResources(const char *filename, ICodegenContextCallbac bool target64bit = workunit->getDebugValueBool("target64bit", false); #endif StringBuffer resname; - bool isObjectFile = resources.flush(resname, filename, flushText, target64bit); + bool isObjectFile = resources.flush(resname, filename, flushText, target64bit, compilerType); StringBuffer resTextName; if (flushText && resources.queryWriteText(resTextName, resname)) @@ -1452,9 +1452,9 @@ void HqlCppInstance::flushResources(const char *filename, ICodegenContextCallbac } } -IHqlCppInstance * createCppInstance(IWorkUnit *wu, const char * wupathname) +IHqlCppInstance * createCppInstance(IWorkUnit *wu, const char * wupathname, CompilerType compiler) { - return new HqlCppInstance(wu, wupathname); + return new HqlCppInstance(wu, wupathname, compiler); } //=========================================================================== diff --git a/ecl/hqlcpp/hqlcpp.hpp b/ecl/hqlcpp/hqlcpp.hpp index a478caff43e..6a4af020906 100644 --- a/ecl/hqlcpp/hqlcpp.hpp +++ b/ecl/hqlcpp/hqlcpp.hpp @@ -140,7 +140,7 @@ interface HQLCPP_API IHqlCppTranslator : public IInterface virtual bool buildCpp(IHqlCppInstance & _code, HqlQueryContext & query) = 0; }; -extern HQLCPP_API IHqlCppInstance * createCppInstance(IWorkUnit * wu, const char * wupathname); +extern HQLCPP_API IHqlCppInstance * createCppInstance(IWorkUnit * wu, const char * wupathname, CompilerType compilerType); extern HQLCPP_API IHqlExpression * ensureIndexable(IHqlExpression * expr); extern HQLCPP_API bool isChildOf(IHqlExpression * parent, IHqlExpression * child); diff --git a/ecl/hqlcpp/hqlcpp.ipp b/ecl/hqlcpp/hqlcpp.ipp index ce13dba6eef..c2b5773c53b 100644 --- a/ecl/hqlcpp/hqlcpp.ipp +++ b/ecl/hqlcpp/hqlcpp.ipp @@ -140,7 +140,7 @@ public: class HQLCPP_API HqlCppInstance : public IHqlCppInstance, public CInterface { public: - HqlCppInstance(IWorkUnit * _workunit, const char * _wupathname); + HqlCppInstance(IWorkUnit * _workunit, const char * _wupathname, CompilerType _compiler); IMPLEMENT_IINTERFACE virtual HqlStmts * ensureSection(IAtom * section); @@ -193,6 +193,7 @@ public: Owned plugins; Owned hintFile; CIArrayOf cppInfo; + CompilerType compilerType; }; //--------------------------------------------------------------------------- diff --git a/ecl/hqlcpp/hqlecl.cpp b/ecl/hqlcpp/hqlecl.cpp index e52ac773ca9..e4d028541d0 100644 --- a/ecl/hqlcpp/hqlecl.cpp +++ b/ecl/hqlcpp/hqlecl.cpp @@ -163,15 +163,15 @@ class NullContextCallback : implements ICodegenContextCallback, public CInterfac class HqlDllGenerator : implements IHqlExprDllGenerator, implements IAbortRequestCallback, public CInterface { public: - HqlDllGenerator(IErrorReceiver * _errs, const char * _wuname, const char * _targetdir, IWorkUnit * _wu, ClusterType _targetClusterType, ICodegenContextCallback * _ctxCallback, bool _checkForLocalFileUploads, bool _okToAbort) : - errs(_errs), wuname(_wuname), targetDir(_targetdir), wu(_wu), targetClusterType(_targetClusterType), ctxCallback(_ctxCallback), checkForLocalFileUploads(_checkForLocalFileUploads), okToAbort(_okToAbort) + HqlDllGenerator(IErrorReceiver * _errs, const char * _wuname, const char * _targetdir, IWorkUnit * _wu, ClusterType _targetClusterType, ICodegenContextCallback * _ctxCallback, bool _checkForLocalFileUploads, bool _okToAbort, CompilerType _compilerType) : + errs(_errs), wuname(_wuname), targetDir(_targetdir), wu(_wu), targetClusterType(_targetClusterType), ctxCallback(_ctxCallback), checkForLocalFileUploads(_checkForLocalFileUploads), okToAbort(_okToAbort), compilerType(_compilerType) { if (!ctxCallback) ctxCallback.setown(new NullContextCallback(_wu)); noOutput = true; defaultMaxCompileThreads = 1; generateTarget = EclGenerateNone; - code.setown(createCppInstance(wu, wuname)); + code.setown(createCppInstance(wu, wuname, compilerType)); totalGeneratedSize = 0; } IMPLEMENT_IINTERFACE @@ -229,6 +229,7 @@ class HqlDllGenerator : implements IHqlExprDllGenerator, implements IAbortReques bool deleteGenerated = false; bool publishGenerated = false; bool okToAbort; + CompilerType compilerType; }; @@ -419,7 +420,7 @@ IPropertyTree * HqlDllGenerator::generateSingleFieldUsageStatistics(IHqlExpressi // Owned localWu = createLocalWorkUnit(); IWorkUnit * localWu = wu; //Generate the code into a new instance each time so it doesn't hang around eating memory - Owned localCode = createCppInstance(localWu, wuname); + Owned localCode = createCppInstance(localWu, wuname, compilerType); HqlQueryContext query; @@ -781,7 +782,7 @@ void HqlDllGenerator::setWuState(bool ok) double HqlDllGenerator::getECLcomplexity(IHqlExpression * exprs) { - Owned code = createCppInstance(wu, NULL); + Owned code = createCppInstance(wu, NULL, compilerType); HqlCppTranslator translator(errs, "temp", code, targetClusterType, NULL); @@ -799,14 +800,14 @@ offset_t HqlDllGenerator::getGeneratedSize() const extern HQLCPP_API double getECLcomplexity(IHqlExpression * exprs, IErrorReceiver * errs, IWorkUnit *wu, ClusterType targetClusterType) { - HqlDllGenerator generator(errs, "unknown", NULL, wu, targetClusterType, NULL, false, false); + HqlDllGenerator generator(errs, "unknown", NULL, wu, targetClusterType, NULL, false, false, DEFAULT_COMPILER); return generator.getECLcomplexity(exprs); } -extern HQLCPP_API IHqlExprDllGenerator * createDllGenerator(IErrorReceiver * errs, const char *wuname, const char * targetdir, IWorkUnit *wu, ClusterType targetClusterType, ICodegenContextCallback *ctxCallback, bool checkForLocalFileUploads, bool okToAbort) +extern HQLCPP_API IHqlExprDllGenerator * createDllGenerator(IErrorReceiver * errs, const char *wuname, const char * targetdir, IWorkUnit *wu, ClusterType targetClusterType, ICodegenContextCallback *ctxCallback, bool checkForLocalFileUploads, bool okToAbort, CompilerType compilerType) { - return new HqlDllGenerator(errs, wuname, targetdir, wu, targetClusterType, ctxCallback, checkForLocalFileUploads, okToAbort); + return new HqlDllGenerator(errs, wuname, targetdir, wu, targetClusterType, ctxCallback, checkForLocalFileUploads, okToAbort, compilerType); } /* diff --git a/ecl/hqlcpp/hqlecl.hpp b/ecl/hqlcpp/hqlecl.hpp index 4b4191e763c..9222e603713 100644 --- a/ecl/hqlcpp/hqlecl.hpp +++ b/ecl/hqlcpp/hqlecl.hpp @@ -53,7 +53,7 @@ interface IHqlExprDllGenerator : extends IInterface virtual void addArchiveAsResource(StringBuffer &buf) = 0; }; -extern HQLCPP_API IHqlExprDllGenerator * createDllGenerator(IErrorReceiver * errs, const char *wuname, const char * targetdir, IWorkUnit *wu, ClusterType targetClusterType, ICodegenContextCallback * ctxCallback, bool checkForLocalFileUploads, bool okToAbort); +extern HQLCPP_API IHqlExprDllGenerator * createDllGenerator(IErrorReceiver * errs, const char *wuname, const char * targetdir, IWorkUnit *wu, ClusterType targetClusterType, ICodegenContextCallback * ctxCallback, bool checkForLocalFileUploads, bool okToAbort, CompilerType compilerType); //Extract a single level of external libraries. diff --git a/ecl/hqlcpp/hqlres.cpp b/ecl/hqlcpp/hqlres.cpp index 87c485a3dca..5c61222ca20 100644 --- a/ecl/hqlcpp/hqlres.cpp +++ b/ecl/hqlcpp/hqlres.cpp @@ -545,7 +545,7 @@ void ResourceManager::flushAsText(const char *filename) fclose(f); } -bool ResourceManager::flush(StringBuffer &filename, const char *basename, bool flushText, bool target64bit) +bool ResourceManager::flush(StringBuffer &filename, const char *basename, bool flushText, bool target64bit, CompilerType compilerType) { finalize(); @@ -606,11 +606,6 @@ bool ResourceManager::flush(StringBuffer &filename, const char *basename, bool f throwError1(HQLERR_ResourceCreateFailed, filename.str()); //MORE: This should really use targetCompiler instead -#if defined(__APPLE__) - const bool generateClang = true; -#else - const bool generateClang = false; -#endif ForEachItemIn(idx, resources) { ResourceItem &s = (ResourceItem &) resources.item(idx); @@ -618,7 +613,7 @@ bool ResourceManager::flush(StringBuffer &filename, const char *basename, bool f unsigned id = s.id; VStringBuffer binfile("%s_%s_%u.bin", filename.str(), type, id); VStringBuffer label("%s_%u_txt_start", type, id); - if (generateClang) + if (compilerType == ClangCppCompiler) { #ifdef __APPLE__ if (id <= 1200) // There is a limit of 255 sections before linker complains - and some are used elsewhere @@ -648,7 +643,7 @@ bool ResourceManager::flush(StringBuffer &filename, const char *basename, bool f } fwrite(s.data.get(), 1, s.data.length(), bin); fclose(bin); - if (!generateClang) + if (compilerType != ClangCppCompiler) fprintf(f, " .size %s,%u\n", label.str(), (unsigned)s.data.length()); } fclose(f); diff --git a/ecl/hqlcpp/hqlres.hpp b/ecl/hqlcpp/hqlres.hpp index 4fd9e1fb72a..ad215f8415e 100644 --- a/ecl/hqlcpp/hqlres.hpp +++ b/ecl/hqlcpp/hqlres.hpp @@ -42,7 +42,7 @@ class ResourceManager void finalize(); unsigned count(); - bool flush(StringBuffer &filename, const char *basename, bool flushText, bool target64bit); + bool flush(StringBuffer &filename, const char *basename, bool flushText, bool target64bit, CompilerType compilerType); void flushAsText(const char *filename); bool queryWriteText(StringBuffer & resTextName, const char * filename); private: