Skip to content

Commit

Permalink
Merge pull request hpcc-systems#18941 from richardkchapman/hpcc32274
Browse files Browse the repository at this point in the history
HPCC-32274 Pass generateClang as a parameter to resource generation

Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Sep 4, 2024
2 parents f4a1690 + 4e8c2a0 commit dc89635
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 25 deletions.
2 changes: 1 addition & 1 deletion ecl/eclcc/eclcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<IHqlExprDllGenerator> generator = createDllGenerator(&errorProcessor, processName.str(), NULL, wu, optTargetClusterType, &instance, false, false);
Owned<IHqlExprDllGenerator> generator = createDllGenerator(&errorProcessor, processName.str(), NULL, wu, optTargetClusterType, &instance, false, false, optTargetCompiler);

setWorkunitHash(wu, instance.query);
if (!optShared)
Expand Down
8 changes: 4 additions & 4 deletions ecl/hqlcpp/hqlcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand All @@ -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);
}

//===========================================================================
Expand Down
2 changes: 1 addition & 1 deletion ecl/hqlcpp/hqlcpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion ecl/hqlcpp/hqlcpp.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -193,6 +193,7 @@ public:
Owned<IPropertyTree> plugins;
Owned<IFileIOStream> hintFile;
CIArrayOf<CppFileInfo> cppInfo;
CompilerType compilerType;
};

//---------------------------------------------------------------------------
Expand Down
17 changes: 9 additions & 8 deletions ecl/hqlcpp/hqlecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -229,6 +229,7 @@ class HqlDllGenerator : implements IHqlExprDllGenerator, implements IAbortReques
bool deleteGenerated = false;
bool publishGenerated = false;
bool okToAbort;
CompilerType compilerType;
};


Expand Down Expand Up @@ -419,7 +420,7 @@ IPropertyTree * HqlDllGenerator::generateSingleFieldUsageStatistics(IHqlExpressi
// Owned<IWorkUnit> localWu = createLocalWorkUnit();
IWorkUnit * localWu = wu;
//Generate the code into a new instance each time so it doesn't hang around eating memory
Owned<IHqlCppInstance> localCode = createCppInstance(localWu, wuname);
Owned<IHqlCppInstance> localCode = createCppInstance(localWu, wuname, compilerType);


HqlQueryContext query;
Expand Down Expand Up @@ -781,7 +782,7 @@ void HqlDllGenerator::setWuState(bool ok)

double HqlDllGenerator::getECLcomplexity(IHqlExpression * exprs)
{
Owned<IHqlCppInstance> code = createCppInstance(wu, NULL);
Owned<IHqlCppInstance> code = createCppInstance(wu, NULL, compilerType);

HqlCppTranslator translator(errs, "temp", code, targetClusterType, NULL);

Expand All @@ -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);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion ecl/hqlcpp/hqlecl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 3 additions & 8 deletions ecl/hqlcpp/hqlres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -606,19 +606,14 @@ 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);
const char *type = s.type.str();
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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ecl/hqlcpp/hqlres.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit dc89635

Please sign in to comment.